MacroExpander: Remove tracking of 'invisible' variables

The 'invisible' flag is only ever used in the VariableChooser,
which iterates over visible descriptions. Not registering the
descriptions of the unwanted variables serves the same purpose
and simplify the code.

Change-Id: If5c38bc9b61ca66dae5068983181ec1a85a2c8e6
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
hjk
2016-01-04 13:57:57 +01:00
parent 8b847bcf19
commit e36662e97d

View File

@@ -108,7 +108,6 @@ public:
QHash<QByteArray, MacroExpander::StringFunction> m_map; QHash<QByteArray, MacroExpander::StringFunction> m_map;
QHash<QByteArray, MacroExpander::PrefixFunction> m_prefixMap; QHash<QByteArray, MacroExpander::PrefixFunction> m_prefixMap;
QSet<QByteArray> m_invisbleInChooser;
QVector<MacroExpander::ResolverFunction> m_extraResolvers; QVector<MacroExpander::ResolverFunction> m_extraResolvers;
QMap<QByteArray, QString> m_descriptions; QMap<QByteArray, QString> m_descriptions;
QString m_displayName; QString m_displayName;
@@ -336,9 +335,8 @@ void MacroExpander::registerPrefix(const QByteArray &prefix, const QString &desc
void MacroExpander::registerVariable(const QByteArray &variable, void MacroExpander::registerVariable(const QByteArray &variable,
const QString &description, const StringFunction &value, bool visibleInChooser) const QString &description, const StringFunction &value, bool visibleInChooser)
{ {
if (!visibleInChooser) if (visibleInChooser)
d->m_invisbleInChooser.insert(variable); d->m_descriptions.insert(variable, description);
d->m_descriptions.insert(variable, description);
d->m_map.insert(variable, value); d->m_map.insert(variable, value);
} }
@@ -419,13 +417,7 @@ void MacroExpander::registerExtraResolver(const MacroExpander::ResolverFunction
*/ */
QList<QByteArray> MacroExpander::visibleVariables() const QList<QByteArray> MacroExpander::visibleVariables() const
{ {
QList<QByteArray> res; return d->m_descriptions.keys();
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;
} }
/*! /*!