diff options
author | hjk <hjk@theqtcompany.com> | 2015-03-03 16:49:59 +0100 |
---|---|---|
committer | hjk <hjk@theqtcompany.com> | 2015-03-04 13:01:13 +0000 |
commit | 04532fe60424a6a254b3077c741bfb8bf9d0a8fe (patch) | |
tree | ee4d2ff9b77a57d3012f5fe6a25d8fd369125611 /src/plugins/debugger/debuggeritem.cpp | |
parent | 3ddbba14158b83a1426b54cfa356909fd42f811d (diff) | |
download | qt-creator-04532fe60424a6a254b3077c741bfb8bf9d0a8fe.tar.gz |
Debugger: Add some expandable macros to Debugger options page
New %{Debugger:Name} for global use, %{Debugger:{Type,Version,...}}
for expansion within the name. Also re-initialize from file if the
saved version is empty (e.g. if the debugger was registered before
the version field was present)
Change-Id: I45568d78147597b30074a2ce4ddcf569bce15192
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Diffstat (limited to 'src/plugins/debugger/debuggeritem.cpp')
-rw-r--r-- | src/plugins/debugger/debuggeritem.cpp | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/plugins/debugger/debuggeritem.cpp b/src/plugins/debugger/debuggeritem.cpp index 971a48e0d5..67b1f51d15 100644 --- a/src/plugins/debugger/debuggeritem.cpp +++ b/src/plugins/debugger/debuggeritem.cpp @@ -35,8 +35,10 @@ #include "debuggerprotocol.h" #include <projectexplorer/abi.h> + #include <utils/fileutils.h> #include <utils/hostosinfo.h> +#include <utils/macroexpander.h> #include <utils/qtcassert.h> #include <QProcess> @@ -83,7 +85,7 @@ DebuggerItem::DebuggerItem(const QVariantMap &data) { m_command = FileName::fromUserInput(data.value(QLatin1String(DEBUGGER_INFORMATION_COMMAND)).toString()); m_id = data.value(QLatin1String(DEBUGGER_INFORMATION_ID)).toString(); - m_displayName = data.value(QLatin1String(DEBUGGER_INFORMATION_DISPLAYNAME)).toString(); + m_unexpandedDisplayName = data.value(QLatin1String(DEBUGGER_INFORMATION_DISPLAYNAME)).toString(); m_isAutoDetected = data.value(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTED), false).toBool(); m_autoDetectionSource = data.value(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTION_SOURCE)).toString(); m_version = data.value(QLatin1String(DEBUGGER_INFORMATION_VERSION)).toString(); @@ -95,6 +97,9 @@ DebuggerItem::DebuggerItem(const QVariantMap &data) if (!abi.isNull()) m_abis.append(abi); } + + if (m_version.isEmpty()) + reinitializeFromFile(); } void DebuggerItem::createId() @@ -204,7 +209,7 @@ QStringList DebuggerItem::abiNames() const bool DebuggerItem::operator==(const DebuggerItem &other) const { return m_id == other.m_id - && m_displayName == other.m_displayName + && m_unexpandedDisplayName == other.m_unexpandedDisplayName && m_isAutoDetected == other.m_isAutoDetected && m_command == other.m_command; } @@ -212,7 +217,7 @@ bool DebuggerItem::operator==(const DebuggerItem &other) const QVariantMap DebuggerItem::toMap() const { QVariantMap data; - data.insert(QLatin1String(DEBUGGER_INFORMATION_DISPLAYNAME), m_displayName); + data.insert(QLatin1String(DEBUGGER_INFORMATION_DISPLAYNAME), m_unexpandedDisplayName); data.insert(QLatin1String(DEBUGGER_INFORMATION_ID), m_id); data.insert(QLatin1String(DEBUGGER_INFORMATION_COMMAND), m_command.toString()); data.insert(QLatin1String(DEBUGGER_INFORMATION_ENGINETYPE), int(m_engineType)); @@ -223,9 +228,26 @@ QVariantMap DebuggerItem::toMap() const return data; } -void DebuggerItem::setDisplayName(const QString &displayName) +QString DebuggerItem::displayName() const +{ + if (!m_unexpandedDisplayName.contains(QLatin1Char('%'))) + return m_unexpandedDisplayName; + + MacroExpander expander; + expander.registerVariable("Debugger:Type", DebuggerKitInformation::tr("Type of Debugger Backend"), + [this] { return engineTypeName(); }); + expander.registerVariable("Debugger:Version", DebuggerKitInformation::tr("Debugger"), + [this] { return !m_version.isEmpty() ? m_version : + DebuggerKitInformation::tr("Unknown debugger version"); }); + expander.registerVariable("Debugger:Abi", DebuggerKitInformation::tr("Debugger"), + [this] { return !m_abis.isEmpty() ? abiNames().join(QLatin1Char(' ')) : + DebuggerKitInformation::tr("Unknown debugger ABI"); }); + return expander.expand(m_unexpandedDisplayName); +} + +void DebuggerItem::setUnexpandedDisplayName(const QString &displayName) { - m_displayName = displayName; + m_unexpandedDisplayName = displayName; } void DebuggerItem::setEngineType(const DebuggerEngineType &engineType) |