Commit bb81a618 authored by hjk's avatar hjk
Browse files

Provide a facility to hide macros in the chooser



... and use it for the Current* fallbacks in the Kit expander.

Change-Id: I1d346aa56647f6d3030bd4384eb89e2a27db6418
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent a12344ce
......@@ -101,6 +101,7 @@ public:
QHash<QByteArray, MacroExpander::StringFunction> m_map;
QHash<QByteArray, MacroExpander::PrefixFunction> m_prefixMap;
QSet<QByteArray> m_invisbleInChooser;
QVector<MacroExpander::ResolverFunction> m_extraResolvers;
QMap<QByteArray, QString> m_descriptions;
QString m_displayName;
......@@ -301,8 +302,10 @@ void MacroExpander::registerPrefix(const QByteArray &prefix, const QString &desc
* \sa registerFileVariables(), registerIntVariable(), registerPrefix()
*/
void MacroExpander::registerVariable(const QByteArray &variable,
const QString &description, const StringFunction &value)
const QString &description, const StringFunction &value, bool visibleInChooser)
{
if (!visibleInChooser)
d->m_invisbleInChooser.insert(variable);
d->m_descriptions.insert(variable, description);
d->m_map.insert(variable, value);
}
......@@ -362,9 +365,15 @@ void MacroExpander::registerExtraResolver(const MacroExpander::ResolverFunction
* \sa registerVariable()
* \sa registerFileVariables()
*/
QList<QByteArray> MacroExpander::variables() const
QList<QByteArray> MacroExpander::visibleVariables() const
{
return d->m_descriptions.keys();
QList<QByteArray> res;
for (auto it = d->m_descriptions.begin(), end = d->m_descriptions.end(); it != end; ++it) {
if (!d->m_invisbleInChooser.contains(it.key()))
res.append(it.key());
}
return res;
}
/*!
......
......@@ -74,7 +74,8 @@ public:
const QString &description, const PrefixFunction &value);
void registerVariable(const QByteArray &variable,
const QString &description, const StringFunction &value);
const QString &description, const StringFunction &value,
bool visibleInChooser = true);
void registerIntVariable(const QByteArray &variable,
const QString &description, const IntFunction &value);
......@@ -84,7 +85,7 @@ public:
void registerExtraResolver(const ResolverFunction &value);
QList<QByteArray> variables() const;
QList<QByteArray> visibleVariables() const;
QString variableDescription(const QByteArray &variable) const;
MacroExpanders subExpanders() const;
......
......@@ -260,7 +260,7 @@ VariableChooserPrivate::VariableChooserPrivate(VariableChooser *parent)
void VariableGroupItem::populateGroup(MacroExpander *expander)
{
foreach (const QByteArray &variable, expander->variables()) {
foreach (const QByteArray &variable, expander->visibleVariables()) {
auto item = new VariableItem;
item->m_variable = QString::fromUtf8(variable);
item->m_expander = expander;
......
......@@ -103,13 +103,16 @@ public:
// without relying on the currentKit() discovery process there.
m_macroExpander.registerVariable(Constants::VAR_CURRENTKIT_NAME,
tr("The name of the currently active kit."),
[kit] { return kit->displayName(); });
[kit] { return kit->displayName(); },
false);
m_macroExpander.registerVariable(Constants::VAR_CURRENTKIT_FILESYSTEMNAME,
tr("The name of the currently active kit in a filesystem friendly version."),
[kit] { return kit->fileSystemFriendlyName(); });
[kit] { return kit->fileSystemFriendlyName(); },
false);
m_macroExpander.registerVariable(Constants::VAR_CURRENTKIT_ID,
tr("The id of the currently active kit."),
[kit] { return kit->id().toString(); });
[kit] { return kit->id().toString(); },
false);
}
QString m_unexpandedDisplayName;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment