forked from qt-creator/qt-creator
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:
@@ -302,6 +302,14 @@ QString MacroExpander::expandProcessArgs(const QString &argsWithVariables) const
|
|||||||
return QtcProcess::expandMacros(argsWithVariables, d);
|
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,
|
* Makes the given string-valued \a prefix known to the variable manager,
|
||||||
* together with a localized \a description.
|
* 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,
|
void MacroExpander::registerPrefix(const QByteArray &prefix, const QString &description,
|
||||||
const MacroExpander::PrefixFunction &value)
|
const MacroExpander::PrefixFunction &value)
|
||||||
{
|
{
|
||||||
QByteArray tmp = prefix;
|
QByteArray tmp = fullPrefix(prefix);
|
||||||
if (!tmp.endsWith(':'))
|
|
||||||
tmp.append(':');
|
|
||||||
d->m_descriptions.insert(tmp + "<value>", description);
|
d->m_descriptions.insert(tmp + "<value>", description);
|
||||||
d->m_prefixMap.insert(tmp, value);
|
d->m_prefixMap.insert(tmp, value);
|
||||||
}
|
}
|
||||||
@@ -430,6 +436,11 @@ QString MacroExpander::variableDescription(const QByteArray &variable) const
|
|||||||
return d->m_descriptions.value(variable);
|
return d->m_descriptions.value(variable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MacroExpander::isPrefixVariable(const QByteArray &variable) const
|
||||||
|
{
|
||||||
|
return d->m_prefixMap.contains(fullPrefix(variable));
|
||||||
|
}
|
||||||
|
|
||||||
MacroExpanderProviders MacroExpander::subProviders() const
|
MacroExpanderProviders MacroExpander::subProviders() const
|
||||||
{
|
{
|
||||||
return d->m_subProviders;
|
return d->m_subProviders;
|
||||||
|
@@ -89,6 +89,7 @@ public:
|
|||||||
|
|
||||||
QList<QByteArray> visibleVariables() const;
|
QList<QByteArray> visibleVariables() const;
|
||||||
QString variableDescription(const QByteArray &variable) const;
|
QString variableDescription(const QByteArray &variable) const;
|
||||||
|
bool isPrefixVariable(const QByteArray &variable) const;
|
||||||
|
|
||||||
MacroExpanderProviders subProviders() const;
|
MacroExpanderProviders subProviders() const;
|
||||||
|
|
||||||
|
@@ -177,8 +177,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (role == Qt::ToolTipRole) {
|
if (role == Qt::ToolTipRole) {
|
||||||
QString description = m_expander->variableDescription(m_variable.toUtf8());
|
const QByteArray var = m_variable.toUtf8();
|
||||||
const QString value = m_expander->value(m_variable.toUtf8()).toHtmlEscaped();
|
QString description = m_expander->variableDescription(var);
|
||||||
|
QString value;
|
||||||
|
if (!m_expander->isPrefixVariable(var))
|
||||||
|
value = m_expander->value(var).toHtmlEscaped();
|
||||||
if (!value.isEmpty())
|
if (!value.isEmpty())
|
||||||
description += QLatin1String("<p>") + VariableChooser::tr("Current Value: %1").arg(value);
|
description += QLatin1String("<p>") + VariableChooser::tr("Current Value: %1").arg(value);
|
||||||
return description;
|
return description;
|
||||||
|
Reference in New Issue
Block a user