VariableManager: Do not try to expand Prefixes

Resolving "Prefix:<value>" does not make any sense, so let's not
do that.

Task-number: QTCREATORBUG-15072
Change-Id: Ia9741f9b48d269a7be31163ad73c3bc232856419
Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2015-09-17 13:48:02 +02:00
parent 39e8a3abf3
commit 3f1b622fb7
3 changed files with 20 additions and 5 deletions

View File

@@ -302,6 +302,14 @@ QString MacroExpander::expandProcessArgs(const QString &argsWithVariables) const
return QtcProcess::expandMacros(argsWithVariables, d);
}
static QByteArray fullPrefix(const QByteArray &prefix)
{
QByteArray result = prefix;
if (!result.endsWith(':'))
result.append(':');
return result;
}
/*!
* Makes the given string-valued \a prefix known to the variable manager,
* together with a localized \a description.
@@ -314,9 +322,7 @@ QString MacroExpander::expandProcessArgs(const QString &argsWithVariables) const
void MacroExpander::registerPrefix(const QByteArray &prefix, const QString &description,
const MacroExpander::PrefixFunction &value)
{
QByteArray tmp = prefix;
if (!tmp.endsWith(':'))
tmp.append(':');
QByteArray tmp = fullPrefix(prefix);
d->m_descriptions.insert(tmp + "<value>", description);
d->m_prefixMap.insert(tmp, value);
}
@@ -430,6 +436,11 @@ QString MacroExpander::variableDescription(const QByteArray &variable) const
return d->m_descriptions.value(variable);
}
bool MacroExpander::isPrefixVariable(const QByteArray &variable) const
{
return d->m_prefixMap.contains(fullPrefix(variable));
}
MacroExpanderProviders MacroExpander::subProviders() const
{
return d->m_subProviders;

View File

@@ -89,6 +89,7 @@ public:
QList<QByteArray> visibleVariables() const;
QString variableDescription(const QByteArray &variable) const;
bool isPrefixVariable(const QByteArray &variable) const;
MacroExpanderProviders subProviders() const;

View File

@@ -177,8 +177,11 @@ public:
}
if (role == Qt::ToolTipRole) {
QString description = m_expander->variableDescription(m_variable.toUtf8());
const QString value = m_expander->value(m_variable.toUtf8()).toHtmlEscaped();
const QByteArray var = m_variable.toUtf8();
QString description = m_expander->variableDescription(var);
QString value;
if (!m_expander->isPrefixVariable(var))
value = m_expander->value(var).toHtmlEscaped();
if (!value.isEmpty())
description += QLatin1String("<p>") + VariableChooser::tr("Current Value: %1").arg(value);
return description;