forked from qt-creator/qt-creator
Debugger: Refactor DebuggerItemManager class
Task-number: QTCREATORBUG-10252 Change-Id: Ia8545fd0255f59290a6bab6e35ef1c082649f794 Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -73,15 +73,6 @@ static const char DEBUGGER_FILE_VERSION_KEY[] = "Version";
|
|||||||
static const char DEBUGGER_FILENAME[] = "/qtcreator/debuggers.xml";
|
static const char DEBUGGER_FILENAME[] = "/qtcreator/debuggers.xml";
|
||||||
static const char DEBUGGER_LEGACY_FILENAME[] = "/qtcreator/profiles.xml";
|
static const char DEBUGGER_LEGACY_FILENAME[] = "/qtcreator/profiles.xml";
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
// Helpers
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static DebuggerItemManager *theDebuggerItemManager()
|
|
||||||
{
|
|
||||||
static DebuggerItemManager *manager = new DebuggerItemManager(0);
|
|
||||||
return manager;
|
|
||||||
}
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// DebuggerKitInformation
|
// DebuggerKitInformation
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@@ -101,8 +92,9 @@ QVariant DebuggerKitInformation::defaultValue(Kit *k) const
|
|||||||
// QTC_ASSERT(item, return QVariant());
|
// QTC_ASSERT(item, return QVariant());
|
||||||
// return item->id;
|
// return item->id;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
ToolChain *tc = ToolChainKitInformation::toolChain(k);
|
ToolChain *tc = ToolChainKitInformation::toolChain(k);
|
||||||
return theDebuggerItemManager()->defaultDebugger(tc);
|
return DebuggerItemManager::defaultDebugger(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerKitInformation::setup(Kit *k)
|
void DebuggerKitInformation::setup(Kit *k)
|
||||||
@@ -144,7 +136,7 @@ static unsigned debuggerConfigurationErrors(const Kit *k)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(k, return NoDebugger);
|
QTC_ASSERT(k, return NoDebugger);
|
||||||
|
|
||||||
const DebuggerItem *item = DebuggerItemManager::debuggerFromKit(k);
|
const DebuggerItem *item = DebuggerKitInformation::debugger(k);
|
||||||
if (!item)
|
if (!item)
|
||||||
return NoDebugger;
|
return NoDebugger;
|
||||||
|
|
||||||
@@ -171,6 +163,20 @@ static unsigned debuggerConfigurationErrors(const Kit *k)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DebuggerItem *DebuggerKitInformation::debugger(const Kit *kit)
|
||||||
|
{
|
||||||
|
if (!kit)
|
||||||
|
return 0;
|
||||||
|
QVariant pathOrId = debuggerPathOrId(kit);
|
||||||
|
foreach (const DebuggerItem &item, DebuggerItemManager::debuggers()) {
|
||||||
|
if (item.id() == pathOrId)
|
||||||
|
return &item;
|
||||||
|
if (item.command() == FileName::fromUserInput(pathOrId.toString()))
|
||||||
|
return &item;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool DebuggerKitInformation::isValidDebugger(const Kit *k)
|
bool DebuggerKitInformation::isValidDebugger(const Kit *k)
|
||||||
{
|
{
|
||||||
return debuggerConfigurationErrors(k) == 0;
|
return debuggerConfigurationErrors(k) == 0;
|
||||||
@@ -185,7 +191,7 @@ QList<Task> DebuggerKitInformation::validateDebugger(const Kit *k)
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
QString path;
|
QString path;
|
||||||
if (const DebuggerItem *item = DebuggerItemManager::debuggerFromKit(k))
|
if (const DebuggerItem *item = debugger(k))
|
||||||
path = item->command().toUserOutput();
|
path = item->command().toUserOutput();
|
||||||
|
|
||||||
const Core::Id id = ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM;
|
const Core::Id id = ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM;
|
||||||
@@ -219,21 +225,21 @@ KitInformation::ItemList DebuggerKitInformation::toUserOutput(const Kit *k) cons
|
|||||||
|
|
||||||
FileName DebuggerKitInformation::debuggerCommand(const ProjectExplorer::Kit *k)
|
FileName DebuggerKitInformation::debuggerCommand(const ProjectExplorer::Kit *k)
|
||||||
{
|
{
|
||||||
const DebuggerItem *item = DebuggerItemManager::debuggerFromKit(k);
|
const DebuggerItem *item = debugger(k);
|
||||||
QTC_ASSERT(item, return FileName());
|
QTC_ASSERT(item, return FileName());
|
||||||
return item->command();
|
return item->command();
|
||||||
}
|
}
|
||||||
|
|
||||||
DebuggerEngineType DebuggerKitInformation::engineType(const ProjectExplorer::Kit *k)
|
DebuggerEngineType DebuggerKitInformation::engineType(const ProjectExplorer::Kit *k)
|
||||||
{
|
{
|
||||||
const DebuggerItem *item = DebuggerItemManager::debuggerFromKit(k);
|
const DebuggerItem *item = debugger(k);
|
||||||
QTC_ASSERT(item, return NoEngineType);
|
QTC_ASSERT(item, return NoEngineType);
|
||||||
return item->engineType();
|
return item->engineType();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DebuggerKitInformation::displayString(const Kit *k)
|
QString DebuggerKitInformation::displayString(const Kit *k)
|
||||||
{
|
{
|
||||||
const DebuggerItem *item = DebuggerItemManager::debuggerFromKit(k);
|
const DebuggerItem *item = debugger(k);
|
||||||
if (!item)
|
if (!item)
|
||||||
return tr("No Debugger");
|
return tr("No Debugger");
|
||||||
QString binary = item->command().toUserOutput();
|
QString binary = item->command().toUserOutput();
|
||||||
@@ -243,15 +249,14 @@ QString DebuggerKitInformation::displayString(const Kit *k)
|
|||||||
|
|
||||||
void DebuggerKitInformation::setDebugger(Kit *k, const DebuggerItem &item)
|
void DebuggerKitInformation::setDebugger(Kit *k, const DebuggerItem &item)
|
||||||
{
|
{
|
||||||
DebuggerItemManager *manager = theDebuggerItemManager();
|
|
||||||
// Only register reasonably complete debuggers.
|
// Only register reasonably complete debuggers.
|
||||||
QTC_ASSERT(!item.id().isValid(), return);
|
QTC_ASSERT(!item.id().isValid(), return);
|
||||||
QTC_ASSERT(!item.command().isEmpty(), return);
|
QTC_ASSERT(!item.command().isEmpty(), return);
|
||||||
QTC_ASSERT(!item.displayName().isEmpty(), return);
|
QTC_ASSERT(!item.displayName().isEmpty(), return);
|
||||||
QTC_ASSERT(item.engineType() != NoEngineType, return);
|
QTC_ASSERT(item.engineType() != NoEngineType, return);
|
||||||
QVariant id = manager->registerDebugger(item);
|
// Only set registered/existing debuggers
|
||||||
QTC_CHECK(id.isValid());
|
QTC_ASSERT(DebuggerItemManager::findByCommand(item.command()), return);
|
||||||
k->setValue(DebuggerKitInformation::id(), id);
|
k->setValue(DebuggerKitInformation::id(), item.id());
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Id DebuggerKitInformation::id()
|
Core::Id DebuggerKitInformation::id()
|
||||||
@@ -259,7 +264,11 @@ Core::Id DebuggerKitInformation::id()
|
|||||||
return "Debugger.Information";
|
return "Debugger.Information";
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Internal {
|
// --------------------------------------------------------------------------
|
||||||
|
// DebuggerItemManager
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static DebuggerItemManager *m_instance = 0;
|
||||||
|
|
||||||
static FileName userSettingsFileName()
|
static FileName userSettingsFileName()
|
||||||
{
|
{
|
||||||
@@ -267,62 +276,53 @@ static FileName userSettingsFileName()
|
|||||||
return FileName::fromString(settingsLocation.absolutePath() + QLatin1String(DEBUGGER_FILENAME));
|
return FileName::fromString(settingsLocation.absolutePath() + QLatin1String(DEBUGGER_FILENAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
static QList<QStandardItem *> describeItem(const DebuggerItem &item)
|
static QList<DebuggerItem> readDebuggers(const FileName &fileName)
|
||||||
{
|
{
|
||||||
QList<QStandardItem *> row;
|
QList<DebuggerItem> result;
|
||||||
row.append(new QStandardItem(item.displayName()));
|
|
||||||
row.append(new QStandardItem(item.command().toUserOutput()));
|
PersistentSettingsReader reader;
|
||||||
row.append(new QStandardItem(item.engineTypeName()));
|
if (!reader.load(fileName))
|
||||||
row.at(0)->setData(item.id());
|
return result;
|
||||||
row.at(0)->setEditable(false);
|
QVariantMap data = reader.restoreValues();
|
||||||
row.at(1)->setEditable(false);
|
|
||||||
row.at(2)->setEditable(false);
|
// Check version
|
||||||
row.at(0)->setSelectable(true);
|
int version = data.value(QLatin1String(DEBUGGER_FILE_VERSION_KEY), 0).toInt();
|
||||||
row.at(1)->setSelectable(true);
|
if (version < 1)
|
||||||
row.at(2)->setSelectable(true);
|
return result;
|
||||||
return row;
|
|
||||||
|
int count = data.value(QLatin1String(DEBUGGER_COUNT_KEY), 0).toInt();
|
||||||
|
for (int i = 0; i < count; ++i) {
|
||||||
|
const QString key = QString::fromLatin1(DEBUGGER_DATA_KEY) + QString::number(i);
|
||||||
|
if (!data.contains(key))
|
||||||
|
break;
|
||||||
|
const QVariantMap dbMap = data.value(key).toMap();
|
||||||
|
DebuggerItem item;
|
||||||
|
item.fromMap(dbMap);
|
||||||
|
result.append(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QList<QStandardItem *> createRow(const QString &display)
|
QList<DebuggerItem> DebuggerItemManager::m_debuggers;
|
||||||
{
|
DebuggerItemModel* DebuggerItemManager::m_model = 0;
|
||||||
QList<QStandardItem *> row;
|
PersistentSettingsWriter * DebuggerItemManager::m_writer = 0;
|
||||||
row.append(new QStandardItem(display));
|
|
||||||
row.append(new QStandardItem());
|
|
||||||
row.append(new QStandardItem());
|
|
||||||
row.at(0)->setEditable(false);
|
|
||||||
row.at(1)->setEditable(false);
|
|
||||||
row.at(2)->setEditable(false);
|
|
||||||
row.at(0)->setSelectable(false);
|
|
||||||
row.at(1)->setSelectable(false);
|
|
||||||
row.at(2)->setSelectable(false);
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
|
|
||||||
class DebuggerItemConfigWidget;
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
// DebuggerItemManager
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
|
|
||||||
DebuggerItemManager::DebuggerItemManager(QObject *parent)
|
DebuggerItemManager::DebuggerItemManager(QObject *parent)
|
||||||
: QStandardItemModel(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
setColumnCount(3);
|
m_instance = this;
|
||||||
|
|
||||||
QList<QStandardItem *> row = createRow(tr("Auto-detected"));
|
|
||||||
m_autoRoot = row.at(0);
|
|
||||||
appendRow(row);
|
|
||||||
|
|
||||||
row = createRow(tr("Manual"));
|
|
||||||
m_manualRoot = row.at(0);
|
|
||||||
appendRow(row);
|
|
||||||
|
|
||||||
m_writer = new PersistentSettingsWriter(userSettingsFileName(), QLatin1String("QtCreatorDebugger"));
|
m_writer = new PersistentSettingsWriter(userSettingsFileName(), QLatin1String("QtCreatorDebugger"));
|
||||||
|
m_model = new Debugger::Internal::DebuggerItemModel(this);
|
||||||
connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()),
|
connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()),
|
||||||
this, SLOT(saveDebuggers()));
|
this, SLOT(saveDebuggers()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject *DebuggerItemManager::instance()
|
||||||
|
{
|
||||||
|
return m_instance;
|
||||||
|
}
|
||||||
|
|
||||||
DebuggerItemManager::~DebuggerItemManager()
|
DebuggerItemManager::~DebuggerItemManager()
|
||||||
{
|
{
|
||||||
disconnect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()),
|
disconnect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()),
|
||||||
@@ -330,28 +330,14 @@ DebuggerItemManager::~DebuggerItemManager()
|
|||||||
delete m_writer;
|
delete m_writer;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant DebuggerItemManager::headerData(int section, Qt::Orientation orientation, int role) const
|
QList<DebuggerItem> DebuggerItemManager::debuggers()
|
||||||
{
|
{
|
||||||
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
|
return m_debuggers;
|
||||||
switch (section) {
|
|
||||||
case 0:
|
|
||||||
return tr("Name");
|
|
||||||
case 1:
|
|
||||||
return tr("Path");
|
|
||||||
case 2:
|
|
||||||
return tr("Type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return QVariant();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DebuggerItemManager::uniqueDisplayName(const QString &base) const
|
DebuggerItemModel *DebuggerItemManager::model()
|
||||||
{
|
{
|
||||||
foreach (const DebuggerItem &item, m_debuggers)
|
return m_model;
|
||||||
if (item.displayName() == base)
|
|
||||||
return uniqueDisplayName(base + QLatin1String(" (1)"));
|
|
||||||
|
|
||||||
return base;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerItemManager::autoDetectCdbDebugger()
|
void DebuggerItemManager::autoDetectCdbDebugger()
|
||||||
@@ -408,7 +394,7 @@ void DebuggerItemManager::autoDetectCdbDebugger()
|
|||||||
item.setCommand(cdb);
|
item.setCommand(cdb);
|
||||||
item.setEngineType(CdbEngineType);
|
item.setEngineType(CdbEngineType);
|
||||||
item.setDisplayName(uniqueDisplayName(tr("Auto-detected CDB at %1").arg(cdb.toUserOutput())));
|
item.setDisplayName(uniqueDisplayName(tr("Auto-detected CDB at %1").arg(cdb.toUserOutput())));
|
||||||
doAddDebugger(item);
|
addDebugger(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,7 +429,7 @@ void DebuggerItemManager::autoDetectDebuggers()
|
|||||||
item.setDisplayName(tr("System %1 at %2")
|
item.setDisplayName(tr("System %1 at %2")
|
||||||
.arg(item.engineTypeName()).arg(QDir::toNativeSeparators(fi.absoluteFilePath())));
|
.arg(item.engineTypeName()).arg(QDir::toNativeSeparators(fi.absoluteFilePath())));
|
||||||
item.setAutoDetected(true);
|
item.setAutoDetected(true);
|
||||||
doAddDebugger(item);
|
addDebugger(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -479,22 +465,10 @@ void DebuggerItemManager::readLegacyDebuggers()
|
|||||||
item.setAutoDetected(true);
|
item.setAutoDetected(true);
|
||||||
item.reinitializeFromFile();
|
item.reinitializeFromFile();
|
||||||
item.setDisplayName(tr("Extracted from Kit %1").arg(kitName));
|
item.setDisplayName(tr("Extracted from Kit %1").arg(kitName));
|
||||||
doAddDebugger(item);
|
addDebugger(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant DebuggerItemManager::doAddDebugger(const DebuggerItem &item0)
|
|
||||||
{
|
|
||||||
DebuggerItem item = item0;
|
|
||||||
if (item.id().isNull())
|
|
||||||
item.setId(QUuid::createUuid().toString());
|
|
||||||
QList<QStandardItem *> row = describeItem(item);
|
|
||||||
(item.isAutoDetected() ? m_autoRoot : m_manualRoot)->appendRow(row);
|
|
||||||
m_debuggers.append(item);
|
|
||||||
emit debuggerAdded(item.id(), item.displayName());
|
|
||||||
return item.id();
|
|
||||||
}
|
|
||||||
|
|
||||||
const DebuggerItem *DebuggerItemManager::findByCommand(const FileName &command)
|
const DebuggerItem *DebuggerItemManager::findByCommand(const FileName &command)
|
||||||
{
|
{
|
||||||
foreach (const DebuggerItem &item, m_debuggers)
|
foreach (const DebuggerItem &item, m_debuggers)
|
||||||
@@ -513,64 +487,6 @@ const DebuggerItem *DebuggerItemManager::findById(const QVariant &id)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStandardItem *DebuggerItemManager::currentStandardItem() const
|
|
||||||
{
|
|
||||||
for (int i = 0, n = m_autoRoot->rowCount(); i != n; ++i) {
|
|
||||||
QStandardItem *sitem = m_autoRoot->child(i);
|
|
||||||
if (sitem->data() == m_currentDebugger)
|
|
||||||
return sitem;
|
|
||||||
}
|
|
||||||
for (int i = 0, n = m_manualRoot->rowCount(); i != n; ++i) {
|
|
||||||
QStandardItem *sitem = m_manualRoot->child(i);
|
|
||||||
if (sitem->data() == m_currentDebugger)
|
|
||||||
return sitem;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static QList<DebuggerItem> readDebuggers(const FileName &fileName)
|
|
||||||
{
|
|
||||||
QList<DebuggerItem> result;
|
|
||||||
|
|
||||||
PersistentSettingsReader reader;
|
|
||||||
if (!reader.load(fileName))
|
|
||||||
return result;
|
|
||||||
QVariantMap data = reader.restoreValues();
|
|
||||||
|
|
||||||
// Check version
|
|
||||||
int version = data.value(QLatin1String(DEBUGGER_FILE_VERSION_KEY), 0).toInt();
|
|
||||||
if (version < 1)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
// Read default debugger settings (if any)
|
|
||||||
// int count = data.value(QLatin1String(DEFAULT_DEBUGGER_COUNT_KEY)).toInt();
|
|
||||||
// for (int i = 0; i < count; ++i) {
|
|
||||||
// const QString abiKey = QString::fromLatin1(DEFAULT_DEBUGGER_ABI_KEY) + QString::number(i);
|
|
||||||
// if (!data.contains(abiKey))
|
|
||||||
// continue;
|
|
||||||
// const QString pathKey = QString::fromLatin1(DEFAULT_DEBUGGER_PATH_KEY) + QString::number(i);
|
|
||||||
// if (!data.contains(pathKey))
|
|
||||||
// continue;
|
|
||||||
// m_abiToDebugger.insert(data.value(abiKey).toString(),
|
|
||||||
// FileName::fromString(data.value(pathKey).toString()));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// QList<DebuggerFactory *> factories = ExtensionSystem::PluginManager::getObjects<DebuggerFactory>();
|
|
||||||
|
|
||||||
int count = data.value(QLatin1String(DEBUGGER_COUNT_KEY), 0).toInt();
|
|
||||||
for (int i = 0; i < count; ++i) {
|
|
||||||
const QString key = QString::fromLatin1(DEBUGGER_DATA_KEY) + QString::number(i);
|
|
||||||
if (!data.contains(key))
|
|
||||||
break;
|
|
||||||
const QVariantMap dbMap = data.value(key).toMap();
|
|
||||||
DebuggerItem item;
|
|
||||||
item.fromMap(dbMap);
|
|
||||||
result.append(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerItemManager::restoreDebuggers()
|
void DebuggerItemManager::restoreDebuggers()
|
||||||
{
|
{
|
||||||
QList<DebuggerItem> dbsToCheck;
|
QList<DebuggerItem> dbsToCheck;
|
||||||
@@ -594,36 +510,6 @@ void DebuggerItemManager::restoreDebuggers()
|
|||||||
dbsToRegister.append(item);
|
dbsToRegister.append(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove debuggers configured by the SDK.
|
|
||||||
// foreach (const DebuggerItem &item, dbsToRegister) {
|
|
||||||
// for (int i = dbsToCheck.count(); --i >= 0; ) {
|
|
||||||
// if (dbsToCheck.at(i).id == item.id)
|
|
||||||
// dbsToCheck.removeAt(i);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// QList<DebuggerItem *> detectedDbs;
|
|
||||||
// QList<DebuggerFactory *> factories = ExtensionSystem::PluginManager::getObjects<DebuggerFactory>();
|
|
||||||
// foreach (DebuggerFactory *f, factories)
|
|
||||||
// detectedDbs.append(f->autoDetect());
|
|
||||||
|
|
||||||
// Find/update autodetected debuggers
|
|
||||||
// DebuggerItem *toStore = 0;
|
|
||||||
// foreach (DebuggerItem *currentDetected, detectedDbs) {
|
|
||||||
// toStore = currentDetected;
|
|
||||||
|
|
||||||
// // Check whether we had this debugger stored and prefer the old one with the old id:
|
|
||||||
// for (int i = 0; i < dbsToCheck.count(); ++i) {
|
|
||||||
// if (*(dbsToCheck.at(i)) == *currentDetected) {
|
|
||||||
// toStore = dbsToCheck.at(i);
|
|
||||||
// dbsToCheck.removeAt(i);
|
|
||||||
// delete currentDetected;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// dbsToRegister += toStore;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Keep debuggers that were not rediscovered but are still executable and delete the rest
|
// Keep debuggers that were not rediscovered but are still executable and delete the rest
|
||||||
foreach (const DebuggerItem &item, dbsToCheck) {
|
foreach (const DebuggerItem &item, dbsToCheck) {
|
||||||
if (!item.isValid()) {
|
if (!item.isValid()) {
|
||||||
@@ -634,20 +520,18 @@ void DebuggerItemManager::restoreDebuggers()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store manual debuggers
|
|
||||||
DebuggerItemManager *manager = theDebuggerItemManager();
|
|
||||||
for (int i = 0, n = dbsToRegister.size(); i != n; ++i) {
|
for (int i = 0, n = dbsToRegister.size(); i != n; ++i) {
|
||||||
DebuggerItem item = dbsToRegister.at(i);
|
DebuggerItem item = dbsToRegister.at(i);
|
||||||
if (manager->findByCommand(item.command()))
|
if (findByCommand(item.command()))
|
||||||
continue;
|
continue;
|
||||||
manager->doAddDebugger(item);
|
addDebugger(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto detect current.
|
// Auto detect current.
|
||||||
manager->autoDetectDebuggers();
|
autoDetectDebuggers();
|
||||||
|
|
||||||
// Add debuggers from pre-3.x profiles.xml
|
// Add debuggers from pre-3.x profiles.xml
|
||||||
manager->readLegacyDebuggers();
|
readLegacyDebuggers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerItemManager::saveDebuggers()
|
void DebuggerItemManager::saveDebuggers()
|
||||||
@@ -672,57 +556,31 @@ void DebuggerItemManager::saveDebuggers()
|
|||||||
// Do not save default debuggers as they are set by the SDK.
|
// Do not save default debuggers as they are set by the SDK.
|
||||||
}
|
}
|
||||||
|
|
||||||
const DebuggerItem *DebuggerItemManager::debuggerFromKit(const Kit *kit)
|
void DebuggerItemManager::registerDebugger(const DebuggerItem &item)
|
||||||
{
|
{
|
||||||
if (!kit)
|
if (findByCommand(item.command()))
|
||||||
return 0;
|
return;
|
||||||
QVariant pathOrId = debuggerPathOrId(kit);
|
|
||||||
foreach (const DebuggerItem &item, theDebuggerItemManager()->m_debuggers) {
|
addDebugger(item);
|
||||||
if (item.id() == pathOrId)
|
|
||||||
return &item;
|
|
||||||
if (item.command() == FileName::fromUserInput(pathOrId.toString()))
|
|
||||||
return &item;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant DebuggerItemManager::registerDebugger(const DebuggerItem &item)
|
void DebuggerItemManager::deregisterDebugger(const DebuggerItem &item)
|
||||||
{
|
{
|
||||||
if (const DebuggerItem *found = findByCommand(item.command()))
|
if (findByCommand(item.command()))
|
||||||
return found->id();
|
removeDebugger(item.id());
|
||||||
|
|
||||||
return doAddDebugger(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex DebuggerItemManager::currentIndex() const
|
void DebuggerItemManager::addDebugger(const DebuggerItem& item0)
|
||||||
{
|
{
|
||||||
QStandardItem *current = currentStandardItem();
|
DebuggerItem item = item0;
|
||||||
return current ? current->index() : QModelIndex();
|
if (item.id().isNull())
|
||||||
|
item.setId(QUuid::createUuid().toString());
|
||||||
|
m_debuggers.append(item);
|
||||||
|
emit m_instance->debuggerAdded(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerItemManager::addDebugger()
|
void DebuggerItemManager::removeDebugger(const QVariant& id)
|
||||||
{
|
{
|
||||||
DebuggerItem item;
|
|
||||||
item.setEngineType(NoEngineType);
|
|
||||||
item.setDisplayName(uniqueDisplayName(tr("New Debugger")));
|
|
||||||
item.setAutoDetected(false);
|
|
||||||
doAddDebugger(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerItemManager::cloneDebugger()
|
|
||||||
{
|
|
||||||
const DebuggerItem *item = findById(m_currentDebugger);
|
|
||||||
QTC_ASSERT(item, return);
|
|
||||||
DebuggerItem newItem = *item;
|
|
||||||
newItem.setDisplayName(uniqueDisplayName(tr("Clone of %1").arg(item->displayName())));
|
|
||||||
newItem.setAutoDetected(false);
|
|
||||||
doAddDebugger(newItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerItemManager::removeDebugger()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(m_currentDebugger.isValid(), return);
|
|
||||||
QVariant id = m_currentDebugger;
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
for (int i = 0, n = m_debuggers.size(); i != n; ++i) {
|
for (int i = 0, n = m_debuggers.size(); i != n; ++i) {
|
||||||
if (m_debuggers.at(i).id() == id) {
|
if (m_debuggers.at(i).id() == id) {
|
||||||
@@ -731,55 +589,30 @@ void DebuggerItemManager::removeDebugger()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QTC_ASSERT(ok, return);
|
QTC_ASSERT(ok, return);
|
||||||
QStandardItem *sitem = currentStandardItem();
|
emit m_instance->debuggerRemoved(id);
|
||||||
QTC_ASSERT(sitem, return);
|
|
||||||
QStandardItem *parent = sitem->parent();
|
|
||||||
QTC_ASSERT(parent, return);
|
|
||||||
// This will trigger a change of m_currentDebugger via changing the
|
|
||||||
// view selection.
|
|
||||||
parent->removeRow(sitem->row());
|
|
||||||
emit debuggerRemoved(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerItemManager::markCurrentDirty()
|
QString DebuggerItemManager::uniqueDisplayName(const QString &base)
|
||||||
{
|
{
|
||||||
QStandardItem *sitem = currentStandardItem();
|
foreach (const DebuggerItem &item, m_debuggers)
|
||||||
QTC_ASSERT(sitem, return);
|
if (item.displayName() == base)
|
||||||
QFont font = sitem->font();
|
return uniqueDisplayName(base + QLatin1String(" (1)"));
|
||||||
font.setBold(true);
|
|
||||||
sitem->setFont(font);
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerItemManager::setCurrentIndex(const QModelIndex &index)
|
void DebuggerItemManager::setItemData(const QVariant &id, const QString &displayName, const FileName &fileName)
|
||||||
{
|
|
||||||
QStandardItem *sit = itemFromIndex(index);
|
|
||||||
m_currentDebugger = sit ? sit->data() : QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerItemManager::setCurrentData(const QString &displayName, const FileName &fileName)
|
|
||||||
{
|
{
|
||||||
for (int i = 0, n = m_debuggers.size(); i != n; ++i) {
|
for (int i = 0, n = m_debuggers.size(); i != n; ++i) {
|
||||||
DebuggerItem &item = m_debuggers[i];
|
DebuggerItem &item = m_debuggers[i];
|
||||||
if (item.id() == m_currentDebugger) {
|
if (item.id() == id) {
|
||||||
item.setDisplayName(displayName);
|
item.setDisplayName(displayName);
|
||||||
item.setCommand(fileName);
|
item.setCommand(fileName);
|
||||||
item.reinitializeFromFile();
|
item.reinitializeFromFile();
|
||||||
QStandardItem *sitem = currentStandardItem();
|
emit m_instance->debuggerUpdated(item.id());
|
||||||
QTC_ASSERT(sitem, return);
|
break;
|
||||||
QStandardItem *parent = sitem->parent();
|
|
||||||
QTC_ASSERT(parent, return);
|
|
||||||
int row = sitem->row();
|
|
||||||
QFont font = sitem->font();
|
|
||||||
font.setBold(false);
|
|
||||||
parent->child(row, 0)->setData(item.displayName(), Qt::DisplayRole);
|
|
||||||
parent->child(row, 0)->setFont(font);
|
|
||||||
parent->child(row, 1)->setData(item.command().toUserOutput(), Qt::DisplayRole);
|
|
||||||
parent->child(row, 1)->setFont(font);
|
|
||||||
parent->child(row, 2)->setData(item.engineTypeName(), Qt::DisplayRole);
|
|
||||||
parent->child(row, 2)->setFont(font);
|
|
||||||
emit debuggerUpdated(m_currentDebugger, displayName);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -850,6 +683,190 @@ QVariant DebuggerItemManager::defaultDebugger(ToolChain *tc)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
static QList<QStandardItem *> describeItem(const DebuggerItem &item)
|
||||||
|
{
|
||||||
|
QList<QStandardItem *> row;
|
||||||
|
row.append(new QStandardItem(item.displayName()));
|
||||||
|
row.append(new QStandardItem(item.command().toUserOutput()));
|
||||||
|
row.append(new QStandardItem(item.engineTypeName()));
|
||||||
|
row.at(0)->setData(item.id());
|
||||||
|
row.at(0)->setEditable(false);
|
||||||
|
row.at(1)->setEditable(false);
|
||||||
|
row.at(2)->setEditable(false);
|
||||||
|
row.at(0)->setSelectable(true);
|
||||||
|
row.at(1)->setSelectable(true);
|
||||||
|
row.at(2)->setSelectable(true);
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
static QList<QStandardItem *> createRow(const QString &display)
|
||||||
|
{
|
||||||
|
QList<QStandardItem *> row;
|
||||||
|
row.append(new QStandardItem(display));
|
||||||
|
row.append(new QStandardItem());
|
||||||
|
row.append(new QStandardItem());
|
||||||
|
row.at(0)->setEditable(false);
|
||||||
|
row.at(1)->setEditable(false);
|
||||||
|
row.at(2)->setEditable(false);
|
||||||
|
row.at(0)->setSelectable(false);
|
||||||
|
row.at(1)->setSelectable(false);
|
||||||
|
row.at(2)->setSelectable(false);
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DebuggerItemConfigWidget;
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
// DebuggerItemModel
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
DebuggerItemModel::DebuggerItemModel(QObject *parent)
|
||||||
|
: QStandardItemModel(parent)
|
||||||
|
{
|
||||||
|
setColumnCount(3);
|
||||||
|
|
||||||
|
QList<QStandardItem *> row = createRow(tr("Auto-detected"));
|
||||||
|
m_autoRoot = row.at(0);
|
||||||
|
appendRow(row);
|
||||||
|
|
||||||
|
row = createRow(tr("Manual"));
|
||||||
|
m_manualRoot = row.at(0);
|
||||||
|
appendRow(row);
|
||||||
|
|
||||||
|
foreach (const DebuggerItem& item, DebuggerItemManager::debuggers())
|
||||||
|
addDebugger(item);
|
||||||
|
|
||||||
|
connect(DebuggerItemManager::instance(), SIGNAL(debuggerAdded(DebuggerItem)), this, SLOT(onDebuggerAdded(DebuggerItem)));
|
||||||
|
connect(DebuggerItemManager::instance(), SIGNAL(debuggerRemoved(QVariant)), this, SLOT(onDebuggerRemoved(QVariant)));
|
||||||
|
connect(DebuggerItemManager::instance(), SIGNAL(debuggerUpdated(QVariant)), this, SLOT(onDebuggerUpdated(QVariant)));
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant DebuggerItemModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
|
{
|
||||||
|
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
|
||||||
|
switch (section) {
|
||||||
|
case 0:
|
||||||
|
return tr("Name");
|
||||||
|
case 1:
|
||||||
|
return tr("Path");
|
||||||
|
case 2:
|
||||||
|
return tr("Type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
QStandardItem *DebuggerItemModel::currentStandardItem() const
|
||||||
|
{
|
||||||
|
return findStandardItemById(m_currentDebugger);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStandardItem *DebuggerItemModel::findStandardItemById(const QVariant &id) const
|
||||||
|
{
|
||||||
|
for (int i = 0, n = m_autoRoot->rowCount(); i != n; ++i) {
|
||||||
|
QStandardItem *sitem = m_autoRoot->child(i);
|
||||||
|
if (sitem->data() == id)
|
||||||
|
return sitem;
|
||||||
|
}
|
||||||
|
for (int i = 0, n = m_manualRoot->rowCount(); i != n; ++i) {
|
||||||
|
QStandardItem *sitem = m_manualRoot->child(i);
|
||||||
|
if (sitem->data() == id)
|
||||||
|
return sitem;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex DebuggerItemModel::currentIndex() const
|
||||||
|
{
|
||||||
|
QStandardItem *current = currentStandardItem();
|
||||||
|
return current ? current->index() : QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerItemModel::addDebugger(const DebuggerItem &item)
|
||||||
|
{
|
||||||
|
DebuggerItemManager::addDebugger(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerItemModel::removeCurrentDebugger()
|
||||||
|
{
|
||||||
|
QTC_ASSERT(m_currentDebugger.isValid(), return);
|
||||||
|
DebuggerItemManager::removeDebugger(m_currentDebugger);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerItemModel::markCurrentDirty()
|
||||||
|
{
|
||||||
|
QStandardItem *sitem = currentStandardItem();
|
||||||
|
QTC_ASSERT(sitem, return);
|
||||||
|
QFont font = sitem->font();
|
||||||
|
font.setBold(true);
|
||||||
|
sitem->setFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerItemModel::cloneDebugger()
|
||||||
|
{
|
||||||
|
const DebuggerItem *item = DebuggerItemManager::findById(m_currentDebugger);
|
||||||
|
QTC_ASSERT(item, return);
|
||||||
|
DebuggerItem newItem = *item;
|
||||||
|
newItem.setDisplayName(DebuggerItemManager::uniqueDisplayName(tr("Clone of %1").arg(item->displayName())));
|
||||||
|
newItem.setAutoDetected(false);
|
||||||
|
DebuggerItemManager::addDebugger(newItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerItemModel::onDebuggerAdded(const DebuggerItem &item0)
|
||||||
|
{
|
||||||
|
DebuggerItem item = item0;
|
||||||
|
if (item.id().isNull())
|
||||||
|
item.setId(QUuid::createUuid().toString());
|
||||||
|
QList<QStandardItem *> row = describeItem(item);
|
||||||
|
(item.isAutoDetected() ? m_autoRoot : m_manualRoot)->appendRow(row);
|
||||||
|
emit debuggerAdded(item.id(), item.displayName());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerItemModel::onDebuggerRemoved(const QVariant &id)
|
||||||
|
{
|
||||||
|
QStandardItem *sitem = findStandardItemById(id);
|
||||||
|
QTC_ASSERT(sitem, return);
|
||||||
|
QStandardItem *parent = sitem->parent();
|
||||||
|
QTC_ASSERT(parent, return);
|
||||||
|
// This will trigger a change of m_currentDebugger via changing the
|
||||||
|
// view selection.
|
||||||
|
parent->removeRow(sitem->row());
|
||||||
|
emit debuggerRemoved(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerItemModel::onDebuggerUpdated(const QVariant &id)
|
||||||
|
{
|
||||||
|
QList<DebuggerItem> debuggers = DebuggerItemManager::debuggers();
|
||||||
|
for (int i = 0, n = debuggers.size(); i != n; ++i) {
|
||||||
|
DebuggerItem &item = debuggers[i];
|
||||||
|
if (item.id() == id) {
|
||||||
|
QStandardItem *sitem = findStandardItemById(id);
|
||||||
|
QTC_ASSERT(sitem, return);
|
||||||
|
QStandardItem *parent = sitem->parent();
|
||||||
|
QTC_ASSERT(parent, return);
|
||||||
|
int row = sitem->row();
|
||||||
|
QFont font = sitem->font();
|
||||||
|
font.setBold(false);
|
||||||
|
parent->child(row, 0)->setData(item.displayName(), Qt::DisplayRole);
|
||||||
|
parent->child(row, 0)->setFont(font);
|
||||||
|
parent->child(row, 1)->setData(item.command().toUserOutput(), Qt::DisplayRole);
|
||||||
|
parent->child(row, 1)->setFont(font);
|
||||||
|
parent->child(row, 2)->setData(item.engineTypeName(), Qt::DisplayRole);
|
||||||
|
parent->child(row, 2)->setFont(font);
|
||||||
|
emit debuggerUpdated(id, item.displayName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerItemModel::setCurrentIndex(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
QStandardItem *sit = itemFromIndex(index);
|
||||||
|
m_currentDebugger = sit ? sit->data() : QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
// DebuggerKitConfigWidget
|
// DebuggerKitConfigWidget
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@@ -857,14 +874,14 @@ QVariant DebuggerItemManager::defaultDebugger(ToolChain *tc)
|
|||||||
DebuggerKitConfigWidget::DebuggerKitConfigWidget(Kit *workingCopy, const KitInformation *ki)
|
DebuggerKitConfigWidget::DebuggerKitConfigWidget(Kit *workingCopy, const KitInformation *ki)
|
||||||
: KitConfigWidget(workingCopy, ki)
|
: KitConfigWidget(workingCopy, ki)
|
||||||
{
|
{
|
||||||
DebuggerItemManager *manager = theDebuggerItemManager();
|
DebuggerItemModel *model = DebuggerItemManager::model();
|
||||||
QTC_CHECK(manager);
|
QTC_CHECK(model);
|
||||||
|
|
||||||
m_comboBox = new QComboBox;
|
m_comboBox = new QComboBox;
|
||||||
m_comboBox->setEnabled(true);
|
m_comboBox->setEnabled(true);
|
||||||
m_comboBox->setToolTip(toolTip());
|
m_comboBox->setToolTip(toolTip());
|
||||||
m_comboBox->addItem(tr("None"), QString());
|
m_comboBox->addItem(tr("None"), QString());
|
||||||
foreach (const DebuggerItem &item, manager->m_debuggers)
|
foreach (const DebuggerItem &item, DebuggerItemManager::debuggers())
|
||||||
m_comboBox->addItem(item.displayName(), item.id());
|
m_comboBox->addItem(item.displayName(), item.id());
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
@@ -874,11 +891,11 @@ DebuggerKitConfigWidget::DebuggerKitConfigWidget(Kit *workingCopy, const KitInfo
|
|||||||
m_manageButton->setContentsMargins(0, 0, 0, 0);
|
m_manageButton->setContentsMargins(0, 0, 0, 0);
|
||||||
connect(m_manageButton, SIGNAL(clicked()), this, SLOT(manageDebuggers()));
|
connect(m_manageButton, SIGNAL(clicked()), this, SLOT(manageDebuggers()));
|
||||||
|
|
||||||
connect(manager, SIGNAL(debuggerAdded(QVariant,QString)),
|
connect(model, SIGNAL(debuggerAdded(QVariant,QString)),
|
||||||
this, SLOT(onDebuggerAdded(QVariant,QString)));
|
this, SLOT(onDebuggerAdded(QVariant,QString)));
|
||||||
connect(manager, SIGNAL(debuggerUpdated(QVariant,QString)),
|
connect(model, SIGNAL(debuggerUpdated(QVariant,QString)),
|
||||||
this, SLOT(onDebuggerUpdated(QVariant,QString)));
|
this, SLOT(onDebuggerUpdated(QVariant,QString)));
|
||||||
connect(manager, SIGNAL(debuggerRemoved(QVariant)),
|
connect(model, SIGNAL(debuggerRemoved(QVariant)),
|
||||||
this, SLOT(onDebuggerRemoved(QVariant)));
|
this, SLOT(onDebuggerRemoved(QVariant)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -906,7 +923,7 @@ void DebuggerKitConfigWidget::makeReadOnly()
|
|||||||
|
|
||||||
void DebuggerKitConfigWidget::refresh()
|
void DebuggerKitConfigWidget::refresh()
|
||||||
{
|
{
|
||||||
const DebuggerItem *item = DebuggerItemManager::debuggerFromKit(m_kit);
|
const DebuggerItem *item = DebuggerKitInformation::debugger(m_kit);
|
||||||
updateComboBox(item ? item->id() : QVariant());
|
updateComboBox(item ? item->id() : QVariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1030,26 +1047,26 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget()
|
|||||||
|
|
||||||
void DebuggerItemConfigWidget::connectDirty()
|
void DebuggerItemConfigWidget::connectDirty()
|
||||||
{
|
{
|
||||||
DebuggerItemManager *manager = theDebuggerItemManager();
|
DebuggerItemModel *model = DebuggerItemManager::model();
|
||||||
connect(m_displayNameLineEdit, SIGNAL(textChanged(QString)),
|
connect(m_displayNameLineEdit, SIGNAL(textChanged(QString)),
|
||||||
manager, SLOT(markCurrentDirty()));
|
model, SLOT(markCurrentDirty()));
|
||||||
connect(m_binaryChooser, SIGNAL(changed(QString)),
|
connect(m_binaryChooser, SIGNAL(changed(QString)),
|
||||||
manager, SLOT(markCurrentDirty()));
|
model, SLOT(markCurrentDirty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerItemConfigWidget::disconnectDirty()
|
void DebuggerItemConfigWidget::disconnectDirty()
|
||||||
{
|
{
|
||||||
DebuggerItemManager *manager = theDebuggerItemManager();
|
DebuggerItemModel *model = DebuggerItemManager::model();
|
||||||
disconnect(m_displayNameLineEdit, SIGNAL(textChanged(QString)),
|
disconnect(m_displayNameLineEdit, SIGNAL(textChanged(QString)),
|
||||||
manager, SLOT(markCurrentDirty()));
|
model, SLOT(markCurrentDirty()));
|
||||||
disconnect(m_binaryChooser, SIGNAL(changed(QString)),
|
disconnect(m_binaryChooser, SIGNAL(changed(QString)),
|
||||||
manager, SLOT(markCurrentDirty()));
|
model, SLOT(markCurrentDirty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerItemConfigWidget::loadItem()
|
void DebuggerItemConfigWidget::loadItem()
|
||||||
{
|
{
|
||||||
DebuggerItemManager *manager = theDebuggerItemManager();
|
DebuggerItemModel *model = DebuggerItemManager::model();
|
||||||
const DebuggerItem *item = manager->findById(manager->m_currentDebugger);
|
const DebuggerItem *item = DebuggerItemManager::findById(model->m_currentDebugger);
|
||||||
if (!item)
|
if (!item)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1089,7 +1106,11 @@ void DebuggerItemConfigWidget::loadItem()
|
|||||||
|
|
||||||
void DebuggerItemConfigWidget::saveItem()
|
void DebuggerItemConfigWidget::saveItem()
|
||||||
{
|
{
|
||||||
theDebuggerItemManager()->setCurrentData(m_displayNameLineEdit->text(), m_binaryChooser->fileName());
|
DebuggerItemModel *model = DebuggerItemManager::model();
|
||||||
|
const DebuggerItem *item = DebuggerItemManager::findById(model->m_currentDebugger);
|
||||||
|
QTC_ASSERT(item, return);
|
||||||
|
DebuggerItemManager::setItemData(item->id(), m_displayNameLineEdit->text(),
|
||||||
|
m_binaryChooser->fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@@ -1098,7 +1119,7 @@ void DebuggerItemConfigWidget::saveItem()
|
|||||||
|
|
||||||
DebuggerOptionsPage::DebuggerOptionsPage()
|
DebuggerOptionsPage::DebuggerOptionsPage()
|
||||||
{
|
{
|
||||||
m_manager = 0;
|
m_model = 0;
|
||||||
m_debuggerView = 0;
|
m_debuggerView = 0;
|
||||||
m_container = 0;
|
m_container = 0;
|
||||||
m_addButton = 0;
|
m_addButton = 0;
|
||||||
@@ -1125,10 +1146,10 @@ QWidget *DebuggerOptionsPage::createPage(QWidget *parent)
|
|||||||
m_container->setState(DetailsWidget::NoSummary);
|
m_container->setState(DetailsWidget::NoSummary);
|
||||||
m_container->setVisible(false);
|
m_container->setVisible(false);
|
||||||
|
|
||||||
m_manager = theDebuggerItemManager();
|
m_model = DebuggerItemManager::model();
|
||||||
|
|
||||||
m_debuggerView = new QTreeView(m_configWidget);
|
m_debuggerView = new QTreeView(m_configWidget);
|
||||||
m_debuggerView->setModel(m_manager);
|
m_debuggerView->setModel(m_model);
|
||||||
m_debuggerView->setUniformRowHeights(true);
|
m_debuggerView->setUniformRowHeights(true);
|
||||||
m_debuggerView->setSelectionMode(QAbstractItemView::SingleSelection);
|
m_debuggerView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
m_debuggerView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
m_debuggerView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
@@ -1181,19 +1202,23 @@ void DebuggerOptionsPage::apply()
|
|||||||
|
|
||||||
void DebuggerOptionsPage::cloneDebugger()
|
void DebuggerOptionsPage::cloneDebugger()
|
||||||
{
|
{
|
||||||
m_manager->cloneDebugger();
|
m_model->cloneDebugger();
|
||||||
debuggerModelChanged();
|
debuggerModelChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerOptionsPage::addDebugger()
|
void DebuggerOptionsPage::addDebugger()
|
||||||
{
|
{
|
||||||
m_manager->addDebugger();
|
DebuggerItem item;
|
||||||
|
item.setEngineType(NoEngineType);
|
||||||
|
item.setDisplayName(DebuggerItemManager::uniqueDisplayName(tr("New Debugger")));
|
||||||
|
item.setAutoDetected(false);
|
||||||
|
m_model->addDebugger(item);
|
||||||
debuggerModelChanged();
|
debuggerModelChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerOptionsPage::removeDebugger()
|
void DebuggerOptionsPage::removeDebugger()
|
||||||
{
|
{
|
||||||
m_manager->removeDebugger();
|
m_model->removeCurrentDebugger();
|
||||||
debuggerModelChanged();
|
debuggerModelChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1221,10 +1246,10 @@ void DebuggerOptionsPage::debuggerSelectionChanged()
|
|||||||
|
|
||||||
QModelIndex mi = m_debuggerView->currentIndex();
|
QModelIndex mi = m_debuggerView->currentIndex();
|
||||||
mi = mi.sibling(mi.row(), 0);
|
mi = mi.sibling(mi.row(), 0);
|
||||||
m_manager->setCurrentIndex(mi);
|
m_model->setCurrentIndex(mi);
|
||||||
|
|
||||||
m_itemConfigWidget->loadItem();
|
m_itemConfigWidget->loadItem();
|
||||||
m_container->setVisible(m_manager->m_currentDebugger.isValid());
|
m_container->setVisible(m_model->m_currentDebugger.isValid());
|
||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1233,8 +1258,8 @@ void DebuggerOptionsPage::debuggerModelChanged()
|
|||||||
QTC_ASSERT(m_container, return);
|
QTC_ASSERT(m_container, return);
|
||||||
|
|
||||||
m_itemConfigWidget->loadItem();
|
m_itemConfigWidget->loadItem();
|
||||||
m_container->setVisible(m_manager->m_currentDebugger.isValid());
|
m_container->setVisible(m_model->m_currentDebugger.isValid());
|
||||||
m_debuggerView->setCurrentIndex(m_manager->currentIndex());
|
m_debuggerView->setCurrentIndex(m_model->currentIndex());
|
||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1246,7 +1271,7 @@ void DebuggerOptionsPage::updateState()
|
|||||||
bool canCopy = false;
|
bool canCopy = false;
|
||||||
bool canDelete = false;
|
bool canDelete = false;
|
||||||
|
|
||||||
if (const DebuggerItem *item = m_manager->findById(m_manager->m_currentDebugger)) {
|
if (const DebuggerItem *item = DebuggerItemManager::findById(m_model->m_currentDebugger)) {
|
||||||
canCopy = item->isValid() && item->canClone();
|
canCopy = item->isValid() && item->canClone();
|
||||||
canDelete = !item->isAutoDetected();
|
canDelete = !item->isAutoDetected();
|
||||||
canDelete = true; // Do we want to remove auto-detected items?
|
canDelete = true; // Do we want to remove auto-detected items?
|
||||||
|
|||||||
@@ -38,7 +38,6 @@
|
|||||||
#include <utils/detailswidget.h>
|
#include <utils/detailswidget.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
#include <utils/persistentsettings.h>
|
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
@@ -57,37 +56,27 @@ class DebuggerItemConfigWidget;
|
|||||||
class DebuggerKitConfigWidget;
|
class DebuggerKitConfigWidget;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
// DebuggerItemManager
|
// DebuggerItemModel
|
||||||
// -----------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
class DebuggerItemModel : public QStandardItemModel
|
||||||
class DebuggerItemManager : public QStandardItemModel
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DebuggerItemManager(QObject *parent);
|
DebuggerItemModel(QObject *parent);
|
||||||
~DebuggerItemManager();
|
|
||||||
|
|
||||||
static const DebuggerItem *debuggerFromKit(const ProjectExplorer::Kit *kit);
|
|
||||||
// Returns id.
|
|
||||||
QVariant registerDebugger(const DebuggerItem &item);
|
|
||||||
|
|
||||||
QModelIndex currentIndex() const;
|
QModelIndex currentIndex() const;
|
||||||
void setCurrentIndex(const QModelIndex &index);
|
void setCurrentIndex(const QModelIndex &index);
|
||||||
void setCurrentData(const QString &displayName, const Utils::FileName &fileName);
|
|
||||||
|
|
||||||
// Returns id.
|
|
||||||
QVariant defaultDebugger(ProjectExplorer::ToolChain *tc);
|
|
||||||
static void restoreDebuggers();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void saveDebuggers();
|
void removeCurrentDebugger();
|
||||||
void autoDetectDebuggers();
|
|
||||||
void readLegacyDebuggers();
|
|
||||||
void addDebugger();
|
|
||||||
void cloneDebugger();
|
|
||||||
void removeDebugger();
|
|
||||||
void markCurrentDirty();
|
void markCurrentDirty();
|
||||||
|
void cloneDebugger();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onDebuggerAdded(const DebuggerItem &item);
|
||||||
|
void onDebuggerRemoved(const QVariant &id);
|
||||||
|
void onDebuggerUpdated(const QVariant &id);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void debuggerAdded(const QVariant &id, const QString &display);
|
void debuggerAdded(const QVariant &id, const QString &display);
|
||||||
@@ -100,16 +89,12 @@ private:
|
|||||||
friend class DebuggerItemConfigWidget;
|
friend class DebuggerItemConfigWidget;
|
||||||
friend class DebuggerOptionsPage;
|
friend class DebuggerOptionsPage;
|
||||||
|
|
||||||
QVariant doAddDebugger(const DebuggerItem &item);
|
void addDebugger(const DebuggerItem &item);
|
||||||
const DebuggerItem *findByCommand(const Utils::FileName &command);
|
void removeDebugger(const QVariant &id);
|
||||||
const DebuggerItem *findById(const QVariant &id);
|
|
||||||
QStandardItem *currentStandardItem() const;
|
QStandardItem *currentStandardItem() const;
|
||||||
|
QStandardItem *findStandardItemById(const QVariant &id) const;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||||
QString uniqueDisplayName(const QString &base) const;
|
|
||||||
void autoDetectCdbDebugger();
|
|
||||||
|
|
||||||
Utils::PersistentSettingsWriter *m_writer;
|
|
||||||
QList<DebuggerItem> m_debuggers;
|
|
||||||
QVariant m_currentDebugger;
|
QVariant m_currentDebugger;
|
||||||
|
|
||||||
QStandardItem *m_autoRoot;
|
QStandardItem *m_autoRoot;
|
||||||
@@ -182,7 +167,7 @@ private:
|
|||||||
QWidget *m_configWidget;
|
QWidget *m_configWidget;
|
||||||
QString m_searchKeywords;
|
QString m_searchKeywords;
|
||||||
|
|
||||||
DebuggerItemManager *m_manager;
|
DebuggerItemModel *m_model;
|
||||||
DebuggerItemConfigWidget *m_itemConfigWidget;
|
DebuggerItemConfigWidget *m_itemConfigWidget;
|
||||||
QTreeView *m_debuggerView;
|
QTreeView *m_debuggerView;
|
||||||
Utils::DetailsWidget *m_container;
|
Utils::DetailsWidget *m_container;
|
||||||
|
|||||||
@@ -36,9 +36,15 @@
|
|||||||
#include <projectexplorer/abi.h>
|
#include <projectexplorer/abi.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
|
|
||||||
|
#include <utils/persistentsettings.h>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
|
||||||
namespace Internal { class DebuggerItemManager; }
|
namespace Internal { class DebuggerItemModel; }
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
// DebuggerItem
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
class DEBUGGER_EXPORT DebuggerItem
|
class DEBUGGER_EXPORT DebuggerItem
|
||||||
{
|
{
|
||||||
@@ -74,7 +80,8 @@ public:
|
|||||||
QStringList abiNames() const;
|
QStringList abiNames() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Debugger::Internal::DebuggerItemManager;
|
friend class Debugger::Internal::DebuggerItemModel;
|
||||||
|
friend class DebuggerItemManager;
|
||||||
void setId(const QVariant &id);
|
void setId(const QVariant &id);
|
||||||
|
|
||||||
QVariant m_id;
|
QVariant m_id;
|
||||||
@@ -85,6 +92,56 @@ private:
|
|||||||
QList<ProjectExplorer::Abi> m_abis;
|
QList<ProjectExplorer::Abi> m_abis;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
// DebuggerItemManager
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
class DEBUGGER_EXPORT DebuggerItemManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
static QObject *instance();
|
||||||
|
~DebuggerItemManager();
|
||||||
|
|
||||||
|
static QList<DebuggerItem> debuggers();
|
||||||
|
static Debugger::Internal::DebuggerItemModel *model();
|
||||||
|
|
||||||
|
static void registerDebugger(const DebuggerItem &item);
|
||||||
|
static void deregisterDebugger(const DebuggerItem &item);
|
||||||
|
|
||||||
|
static const DebuggerItem *findByCommand(const Utils::FileName &command);
|
||||||
|
static const DebuggerItem *findById(const QVariant &id);
|
||||||
|
|
||||||
|
static QVariant defaultDebugger(ProjectExplorer::ToolChain *tc);
|
||||||
|
static void restoreDebuggers();
|
||||||
|
static QString uniqueDisplayName(const QString &base);
|
||||||
|
static void setItemData(const QVariant &id, const QString& displayName, const Utils::FileName &fileName);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void saveDebuggers();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void debuggerAdded(const DebuggerItem &item);
|
||||||
|
void debuggerRemoved(const QVariant &id);
|
||||||
|
void debuggerUpdated(const QVariant &id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit DebuggerItemManager(QObject *parent = 0);
|
||||||
|
static void autoDetectDebuggers();
|
||||||
|
static void autoDetectCdbDebugger();
|
||||||
|
static void readLegacyDebuggers();
|
||||||
|
static void addDebugger(const DebuggerItem &item);
|
||||||
|
static void removeDebugger(const QVariant &id);
|
||||||
|
|
||||||
|
static Utils::PersistentSettingsWriter *m_writer;
|
||||||
|
static QList<DebuggerItem> m_debuggers;
|
||||||
|
static Debugger::Internal::DebuggerItemModel *m_model;
|
||||||
|
|
||||||
|
friend class Internal::DebuggerItemModel;
|
||||||
|
friend class DebuggerPlugin; // Enable constrcutor for DebuggerPlugin
|
||||||
|
};
|
||||||
|
|
||||||
class DEBUGGER_EXPORT DebuggerKitInformation : public ProjectExplorer::KitInformation
|
class DEBUGGER_EXPORT DebuggerKitInformation : public ProjectExplorer::KitInformation
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -99,6 +156,8 @@ public:
|
|||||||
|
|
||||||
void setup(ProjectExplorer::Kit *k);
|
void setup(ProjectExplorer::Kit *k);
|
||||||
|
|
||||||
|
static const DebuggerItem *debugger(const ProjectExplorer::Kit *kit);
|
||||||
|
|
||||||
static QList<ProjectExplorer::Task> validateDebugger(const ProjectExplorer::Kit *k);
|
static QList<ProjectExplorer::Task> validateDebugger(const ProjectExplorer::Kit *k);
|
||||||
static bool isValidDebugger(const ProjectExplorer::Kit *k);
|
static bool isValidDebugger(const ProjectExplorer::Kit *k);
|
||||||
|
|
||||||
|
|||||||
@@ -3401,6 +3401,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
|||||||
mstart->addSeparator(globalcontext, Constants::G_GENERAL);
|
mstart->addSeparator(globalcontext, Constants::G_GENERAL);
|
||||||
mstart->addSeparator(globalcontext, Constants::G_SPECIAL);
|
mstart->addSeparator(globalcontext, Constants::G_SPECIAL);
|
||||||
|
|
||||||
|
addAutoReleasedObject(new DebuggerItemManager);
|
||||||
DebuggerItemManager::restoreDebuggers();
|
DebuggerItemManager::restoreDebuggers();
|
||||||
|
|
||||||
KitManager::registerKitInformation(new DebuggerKitInformation);
|
KitManager::registerKitInformation(new DebuggerKitInformation);
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace QtSupport;
|
using namespace QtSupport;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
using namespace Debugger;
|
||||||
|
|
||||||
namespace Qnx {
|
namespace Qnx {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -218,15 +219,17 @@ Kit *BlackBerryConfiguration::createKit(QnxAbstractQtVersion *version, ToolChain
|
|||||||
QtKitInformation::setQtVersion(kit, version);
|
QtKitInformation::setQtVersion(kit, version);
|
||||||
ToolChainKitInformation::setToolChain(kit, toolChain);
|
ToolChainKitInformation::setToolChain(kit, toolChain);
|
||||||
|
|
||||||
Debugger::DebuggerItem debugger;
|
DebuggerItem debugger;
|
||||||
debugger.setCommand(isSimulator ? m_simulatorDebugger : m_deviceDebugger);
|
debugger.setCommand(isSimulator ? m_simulatorDebugger : m_deviceDebugger);
|
||||||
debugger.setEngineType(Debugger::GdbEngineType);
|
debugger.setEngineType(GdbEngineType);
|
||||||
debugger.setAutoDetected(true);
|
debugger.setAutoDetected(true);
|
||||||
debugger.setAbi(toolChain->targetAbi());
|
debugger.setAbi(toolChain->targetAbi());
|
||||||
debugger.setDisplayName(tr("Debugger for Qt %1 for %2 %3 - %4").arg(
|
debugger.setDisplayName(tr("Debugger for Qt %1 for %2 %3 - %4").arg(
|
||||||
version->qtVersionString(), version->platformDisplayName(),
|
version->qtVersionString(), version->platformDisplayName(),
|
||||||
version->archString(), m_targetName));
|
version->archString(), m_targetName));
|
||||||
Debugger::DebuggerKitInformation::setDebugger(kit, debugger);
|
|
||||||
|
DebuggerItemManager::registerDebugger(debugger);
|
||||||
|
DebuggerKitInformation::setDebugger(kit, debugger);
|
||||||
|
|
||||||
if (isSimulator)
|
if (isSimulator)
|
||||||
Qt4ProjectManager::QmakeKitInformation::setMkspec(
|
Qt4ProjectManager::QmakeKitInformation::setMkspec(
|
||||||
@@ -247,7 +250,7 @@ Kit *BlackBerryConfiguration::createKit(QnxAbstractQtVersion *version, ToolChain
|
|||||||
kit->setSticky(ToolChainKitInformation::id(), true);
|
kit->setSticky(ToolChainKitInformation::id(), true);
|
||||||
kit->setSticky(DeviceTypeKitInformation::id(), true);
|
kit->setSticky(DeviceTypeKitInformation::id(), true);
|
||||||
kit->setSticky(SysRootKitInformation::id(), true);
|
kit->setSticky(SysRootKitInformation::id(), true);
|
||||||
kit->setSticky(Debugger::DebuggerKitInformation::id(), true);
|
kit->setSticky(DebuggerKitInformation::id(), true);
|
||||||
kit->setSticky(Qt4ProjectManager::QmakeKitInformation::id(), true);
|
kit->setSticky(Qt4ProjectManager::QmakeKitInformation::id(), true);
|
||||||
|
|
||||||
return kit;
|
return kit;
|
||||||
@@ -326,7 +329,10 @@ void BlackBerryConfiguration::deactivate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// unable to deregistering debuggers because of missing API
|
foreach (const DebuggerItem &item, DebuggerItemManager::debuggers())
|
||||||
|
if (item.isAutoDetected() &&
|
||||||
|
(item.command() == m_simulatorDebugger || item.command() == m_deviceDebugger))
|
||||||
|
DebuggerItemManager::deregisterDebugger(item);
|
||||||
|
|
||||||
foreach (ToolChain *toolChain, ToolChainManager::toolChains())
|
foreach (ToolChain *toolChain, ToolChainManager::toolChains())
|
||||||
if (toolChain->isAutoDetected()
|
if (toolChain->isAutoDetected()
|
||||||
@@ -335,6 +341,7 @@ void BlackBerryConfiguration::deactivate()
|
|||||||
|
|
||||||
foreach (BaseQtVersion *version, versions)
|
foreach (BaseQtVersion *version, versions)
|
||||||
QtVersionManager::removeVersion(version);
|
QtVersionManager::removeVersion(version);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user