summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorhjk <hjk@theqtcompany.com>2015-03-03 16:49:59 +0100
committerhjk <hjk@theqtcompany.com>2015-03-04 13:01:13 +0000
commit04532fe60424a6a254b3077c741bfb8bf9d0a8fe (patch)
treeee4d2ff9b77a57d3012f5fe6a25d8fd369125611 /src/plugins
parent3ddbba14158b83a1426b54cfa356909fd42f811d (diff)
downloadqt-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')
-rw-r--r--src/plugins/android/androidconfigurations.cpp4
-rw-r--r--src/plugins/debugger/debuggeritem.cpp32
-rw-r--r--src/plugins/debugger/debuggeritem.h11
-rw-r--r--src/plugins/debugger/debuggeritemmanager.cpp10
-rw-r--r--src/plugins/debugger/debuggerkitinformation.cpp8
-rw-r--r--src/plugins/debugger/debuggeroptionspage.cpp12
-rw-r--r--src/plugins/qnx/qnxbaseconfiguration.cpp2
7 files changed, 52 insertions, 27 deletions
diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp
index 557425ade6..833de15485 100644
--- a/src/plugins/android/androidconfigurations.cpp
+++ b/src/plugins/android/androidconfigurations.cpp
@@ -1183,7 +1183,7 @@ void AndroidConfigurations::updateAutomaticKitList()
Debugger::DebuggerItem debugger;
debugger.setCommand(tc->suggestedDebugger());
debugger.setEngineType(Debugger::GdbEngineType);
- debugger.setDisplayName(tr("Android Debugger for %1").arg(tc->displayName()));
+ debugger.setUnexpandedDisplayName(tr("Android Debugger for %1").arg(tc->displayName()));
debugger.setAutoDetected(true);
debugger.setAbi(tc->targetAbi());
QVariant id = Debugger::DebuggerItemManager::registerDebugger(debugger);
@@ -1229,7 +1229,7 @@ void AndroidConfigurations::updateAutomaticKitList()
Debugger::DebuggerItem debugger;
debugger.setCommand(tc->suggestedDebugger());
debugger.setEngineType(Debugger::GdbEngineType);
- debugger.setDisplayName(tr("Android Debugger for %1").arg(tc->displayName()));
+ debugger.setUnexpandedDisplayName(tr("Android Debugger for %1").arg(tc->displayName()));
debugger.setAutoDetected(true);
debugger.setAbi(tc->targetAbi());
QVariant id = Debugger::DebuggerItemManager::registerDebugger(debugger);
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)
diff --git a/src/plugins/debugger/debuggeritem.h b/src/plugins/debugger/debuggeritem.h
index fc3f85541b..6ffb2e7873 100644
--- a/src/plugins/debugger/debuggeritem.h
+++ b/src/plugins/debugger/debuggeritem.h
@@ -44,7 +44,9 @@
namespace Debugger {
class DebuggerItemManager;
+
namespace Internal {
+class DebuggerConfigWidget;
class DebuggerItemConfigWidget;
class DebuggerItemModel;
} // namespace Internal
@@ -68,8 +70,9 @@ public:
QVariant id() const { return m_id; }
- QString displayName() const { return m_displayName; }
- void setDisplayName(const QString &displayName);
+ QString displayName() const;
+ QString unexpandedDisplayName() const { return m_unexpandedDisplayName; }
+ void setUnexpandedDisplayName(const QString &unexpandedDisplayName);
DebuggerEngineType engineType() const { return m_engineType; }
void setEngineType(const DebuggerEngineType &engineType);
@@ -101,9 +104,10 @@ public:
private:
DebuggerItem(const QVariant &id);
void reinitializeFromFile();
+ void initMacroExpander();
QVariant m_id;
- QString m_displayName;
+ QString m_unexpandedDisplayName;
DebuggerEngineType m_engineType;
Utils::FileName m_command;
bool m_isAutoDetected;
@@ -111,6 +115,7 @@ private:
QString m_version;
QList<ProjectExplorer::Abi> m_abis;
+ friend class Internal::DebuggerConfigWidget;
friend class Internal::DebuggerItemConfigWidget;
friend class Internal::DebuggerItemModel;
friend class DebuggerItemManager;
diff --git a/src/plugins/debugger/debuggeritemmanager.cpp b/src/plugins/debugger/debuggeritemmanager.cpp
index 924d493b63..cc04db5bc9 100644
--- a/src/plugins/debugger/debuggeritemmanager.cpp
+++ b/src/plugins/debugger/debuggeritemmanager.cpp
@@ -191,7 +191,7 @@ void DebuggerItemManager::autoDetectCdbDebuggers()
item.setAbis(Abi::abisOfBinary(cdb));
item.setCommand(cdb);
item.setEngineType(CdbEngineType);
- item.setDisplayName(uniqueDisplayName(tr("Auto-detected CDB at %1").arg(cdb.toUserOutput())));
+ item.setUnexpandedDisplayName(uniqueDisplayName(tr("Auto-detected CDB at %1").arg(cdb.toUserOutput())));
addDebugger(item);
}
}
@@ -260,7 +260,7 @@ void DebuggerItemManager::autoDetectGdbOrLldbDebuggers()
item.setCommand(command);
item.reinitializeFromFile();
//: %1: Debugger engine type (GDB, LLDB, CDB...), %2: Path
- item.setDisplayName(tr("System %1 at %2")
+ item.setUnexpandedDisplayName(tr("System %1 at %2")
.arg(item.engineTypeName()).arg(command.toUserOutput()));
item.setAutoDetected(true);
addDebugger(item);
@@ -299,7 +299,7 @@ void DebuggerItemManager::readLegacyDebuggers(const FileName &file)
item.setCommand(command);
item.setAutoDetected(true);
item.reinitializeFromFile();
- item.setDisplayName(tr("Extracted from Kit %1").arg(kitName));
+ item.setUnexpandedDisplayName(tr("Extracted from Kit %1").arg(kitName));
addDebugger(item);
}
}
@@ -379,7 +379,7 @@ QVariant DebuggerItemManager::registerDebugger(const DebuggerItem &item)
if (d.command() == item.command()
&& d.isAutoDetected() == item.isAutoDetected()
&& d.engineType() == item.engineType()
- && d.displayName() == item.displayName()
+ && d.unexpandedDisplayName() == item.unexpandedDisplayName()
&& d.abis() == item.abis()) {
return d.id();
}
@@ -407,7 +407,7 @@ void DebuggerItemManager::deregisterDebugger(const QVariant &id)
QString DebuggerItemManager::uniqueDisplayName(const QString &base)
{
foreach (const DebuggerItem &item, m_debuggers)
- if (item.displayName() == base)
+ if (item.unexpandedDisplayName() == base)
return uniqueDisplayName(base + QLatin1String(" (1)"));
return base;
diff --git a/src/plugins/debugger/debuggerkitinformation.cpp b/src/plugins/debugger/debuggerkitinformation.cpp
index c477a14c74..7b22ae80b5 100644
--- a/src/plugins/debugger/debuggerkitinformation.cpp
+++ b/src/plugins/debugger/debuggerkitinformation.cpp
@@ -304,16 +304,16 @@ KitConfigWidget *DebuggerKitInformation::createConfigWidget(Kit *k) const
void DebuggerKitInformation::addToMacroExpander(Kit *kit, MacroExpander *expander) const
{
- expander->registerVariable("Debugger:Type", tr("Type of Debugger Backend"),
+ expander->registerVariable("Debugger:Name", tr("Name of Debugger"),
[this, kit]() -> QString {
const DebuggerItem *item = debugger(kit);
- return item ? item->engineTypeName() : tr("Unknown debugger type");
+ return item ? item->displayName() : tr("Unknown debugger");
});
- expander->registerVariable("Debugger:Name", tr("Debugger"),
+ expander->registerVariable("Debugger:Type", tr("Type of Debugger Backend"),
[this, kit]() -> QString {
const DebuggerItem *item = debugger(kit);
- return item ? item->displayName() : tr("Unknown debugger");
+ return item ? item->engineTypeName() : tr("Unknown debugger type");
});
expander->registerVariable("Debugger:Version", tr("Debugger"),
diff --git a/src/plugins/debugger/debuggeroptionspage.cpp b/src/plugins/debugger/debuggeroptionspage.cpp
index fc343cbfcb..be29c640bb 100644
--- a/src/plugins/debugger/debuggeroptionspage.cpp
+++ b/src/plugins/debugger/debuggeroptionspage.cpp
@@ -259,7 +259,7 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget(DebuggerItemModel *model)
DebuggerItem DebuggerItemConfigWidget::item() const
{
DebuggerItem item(m_id);
- item.setDisplayName(m_displayNameLineEdit->text());
+ item.setUnexpandedDisplayName(m_displayNameLineEdit->text());
item.setCommand(m_binaryChooser->fileName());
item.setAutoDetected(m_autodetected);
QList<ProjectExplorer::Abi> abiList;
@@ -295,7 +295,7 @@ void DebuggerItemConfigWidget::load(const DebuggerItem *item)
m_autodetected = item->isAutoDetected();
m_displayNameLineEdit->setEnabled(!item->isAutoDetected());
- m_displayNameLineEdit->setText(item->displayName());
+ m_displayNameLineEdit->setText(item->unexpandedDisplayName());
m_typeLineEdit->setText(item->engineTypeName());
@@ -435,11 +435,9 @@ void DebuggerConfigWidget::cloneDebugger()
DebuggerItem newItem;
newItem.createId();
- newItem.setAutoDetected(false);
newItem.setCommand(item->command());
- newItem.setEngineType(item->engineType());
- newItem.setAbis(item->abis());
- newItem.setDisplayName(DebuggerItemManager::uniqueDisplayName(tr("Clone of %1").arg(item->displayName())));
+ newItem.setUnexpandedDisplayName(DebuggerItemManager::uniqueDisplayName(tr("Clone of %1").arg(item->displayName())));
+ newItem.reinitializeFromFile();
newItem.setAutoDetected(false);
m_model.addDebugger(newItem, true);
m_debuggerView->setCurrentIndex(m_model.lastIndex());
@@ -451,7 +449,7 @@ void DebuggerConfigWidget::addDebugger()
item.createId();
item.setAutoDetected(false);
item.setEngineType(NoEngineType);
- item.setDisplayName(DebuggerItemManager::uniqueDisplayName(tr("New Debugger")));
+ item.setUnexpandedDisplayName(DebuggerItemManager::uniqueDisplayName(tr("New Debugger")));
item.setAutoDetected(false);
m_model.addDebugger(item, true);
m_debuggerView->setCurrentIndex(m_model.lastIndex());
diff --git a/src/plugins/qnx/qnxbaseconfiguration.cpp b/src/plugins/qnx/qnxbaseconfiguration.cpp
index b0509b7351..f98a7eb5b7 100644
--- a/src/plugins/qnx/qnxbaseconfiguration.cpp
+++ b/src/plugins/qnx/qnxbaseconfiguration.cpp
@@ -183,7 +183,7 @@ QVariant QnxBaseConfiguration::createDebuggerItem(QnxArchitecture arch,
debugger.setAbi(Abi(arch == Qnx::ArmLeV7 ? Abi::ArmArchitecture : Abi::X86Architecture,
Abi::LinuxOS, Abi::GenericLinuxFlavor, Abi::ElfFormat, 32));
debugger.setAutoDetected(true);
- debugger.setDisplayName(displayName);
+ debugger.setUnexpandedDisplayName(displayName);
return Debugger::DebuggerItemManager::registerDebugger(debugger);
}