From eb3870875f0b972752d58f2395e61041c0a30000 Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Tue, 24 Mar 2009 16:39:01 +0100 Subject: [PATCH] debugger: use new action scheme for number base selections --- src/plugins/debugger/debuggeractions.cpp | 69 ++++++++++++++++++++++-- src/plugins/debugger/debuggeractions.h | 2 + src/plugins/debugger/debuggerconstants.h | 2 - src/plugins/debugger/gdbengine.cpp | 27 +++++++++- src/plugins/debugger/gdbengine.h | 2 +- src/plugins/debugger/registerhandler.cpp | 4 +- src/plugins/debugger/registerwindow.cpp | 49 ++++------------- 7 files changed, 104 insertions(+), 51 deletions(-) diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index 45997a0e121..77d29803d5c 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -34,7 +34,9 @@ #include <QtCore/QDebug> #include <QtCore/QSettings> + #include <QtGui/QAction> +#include <QtGui/QActionGroup> #include <QtGui/QAbstractButton> #include <QtGui/QRadioButton> #include <QtGui/QCheckBox> @@ -253,8 +255,15 @@ void DebuggerAction::pathChooserEditingFinished() void DebuggerAction::actionTriggered(bool) { - if (this->isCheckable()) - setValue(this->isChecked()); + //qDebug() << "TRIGGERING" << this << actionGroup(); + if (isCheckable()) + setValue(isChecked()); + if (actionGroup() && actionGroup()->isExclusive()) { + // FIXME: should be taken care of more directly + foreach (QAction *act, actionGroup()->actions()) + if (DebuggerAction *dact = qobject_cast<DebuggerAction *>(act)) + dact->setValue(bool(act == this)); + } } void DebuggerAction::trigger(const QVariant &data) @@ -369,16 +378,68 @@ DebuggerSettings *theDebuggerSettings() item->setCheckable(true); item = new DebuggerAction(instance); - instance->insertItem(RecheckDumpers, item); item->setText(QObject::tr("Recheck custom dumper availability")); + instance->insertItem(RecheckDumpers, item); // // Breakpoints // item = new DebuggerAction(instance); - instance->insertItem(SynchronizeBreakpoints, item); item->setText(QObject::tr("Syncronize breakpoints")); + instance->insertItem(SynchronizeBreakpoints, item); + // + // Registers + // + + QActionGroup *registerFormatGroup = new QActionGroup(instance); + registerFormatGroup->setExclusive(true); + + item = new DebuggerAction(instance); + item->setText(QObject::tr("Hexadecimal")); + item->setCheckable(true); + item->setSettingsKey("DebugMode", "FormatHexadecimal"); + item->setChecked(true); + instance->insertItem(FormatHexadecimal, item); + registerFormatGroup->addAction(item); + + item = new DebuggerAction(instance); + item->setText(QObject::tr("Decimal")); + item->setCheckable(true); + item->setSettingsKey("DebugMode", "FormatDecimal"); + instance->insertItem(FormatDecimal, item); + registerFormatGroup->addAction(item); + + item = new DebuggerAction(instance); + item->setText(QObject::tr("Octal")); + item->setCheckable(true); + item->setSettingsKey("DebugMode", "FormatOctal"); + instance->insertItem(FormatOctal, item); + registerFormatGroup->addAction(item); + + item = new DebuggerAction(instance); + item->setText(QObject::tr("Binary")); + item->setCheckable(true); + item->setSettingsKey("DebugMode", "FormatBinary"); + instance->insertItem(FormatBinary, item); + registerFormatGroup->addAction(item); + + item = new DebuggerAction(instance); + item->setText(QObject::tr("Raw")); + item->setCheckable(true); + item->setSettingsKey("DebugMode", "FormatRaw"); + instance->insertItem(FormatRaw, item); + registerFormatGroup->addAction(item); + + item = new DebuggerAction(instance); + item->setText(QObject::tr("Natural")); + item->setCheckable(true); + item->setSettingsKey("DebugMode", "FormatNatural"); + instance->insertItem(FormatNatural, item); + registerFormatGroup->addAction(item); + + // + // Misc // item = new DebuggerAction(instance); diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index 4782c096826..cdb3d99cca8 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -176,6 +176,8 @@ enum DebuggerActionCode FormatDecimal, FormatOctal, FormatBinary, + FormatRaw, + FormatNatural, }; // singleton access diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h index c1369aa3298..a17d1bb060c 100644 --- a/src/plugins/debugger/debuggerconstants.h +++ b/src/plugins/debugger/debuggerconstants.h @@ -51,8 +51,6 @@ const char * const M_DEBUG_VIEWS = "Debugger.Menu.View.Debug"; const char * const C_GDBDEBUGGER = "Gdb Debugger"; const char * const GDBRUNNING = "Gdb.Running"; -const char * const PROPERTY_REGISTER_FORMAT = "Debugger.Property.RegisterFormat"; - namespace Internal { enum { debug = 0 }; } diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 535276b326c..6889f9b16e9 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -291,6 +291,19 @@ void GdbEngine::initializeConnections() this, SLOT(setDebugDumpers(bool))); connect(theDebuggerAction(RecheckDumpers), SIGNAL(triggered()), this, SLOT(recheckCustomDumperAvailability())); + + connect(theDebuggerAction(FormatHexadecimal), SIGNAL(triggered()), + this, SLOT(reloadRegisters())); + connect(theDebuggerAction(FormatDecimal), SIGNAL(triggered()), + this, SLOT(reloadRegisters())); + connect(theDebuggerAction(FormatOctal), SIGNAL(triggered()), + this, SLOT(reloadRegisters())); + connect(theDebuggerAction(FormatBinary), SIGNAL(triggered()), + this, SLOT(reloadRegisters())); + connect(theDebuggerAction(FormatRaw), SIGNAL(triggered()), + this, SLOT(reloadRegisters())); + connect(theDebuggerAction(FormatNatural), SIGNAL(triggered()), + this, SLOT(reloadRegisters())); } void GdbEngine::initializeVariables() @@ -2656,7 +2669,19 @@ void GdbEngine::handleStackListThreads(const GdbResultRecord &record, int id) void GdbEngine::reloadRegisters() { - QString format = qq->registerHandler()->model()->property(PROPERTY_REGISTER_FORMAT).toString(); + QString format; + if (theDebuggerAction(FormatHexadecimal)->isChecked()) + format = "x"; + else if (theDebuggerAction(FormatDecimal)->isChecked()) + format = "d"; + else if (theDebuggerAction(FormatOctal)->isChecked()) + format = "o"; + else if (theDebuggerAction(FormatBinary)->isChecked()) + format = "t"; + else if (theDebuggerAction(FormatRaw)->isChecked()) + format = "r"; + else + format = "N"; sendCommand("-data-list-register-values " + format, RegisterListValues); } diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index 20c9c222877..d35f0f08271 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -265,7 +265,7 @@ private: // // Register specific stuff // - void reloadRegisters(); + Q_SLOT void reloadRegisters(); void handleRegisterListNames(const GdbResultRecord &record); void handleRegisterListValues(const GdbResultRecord &record); diff --git a/src/plugins/debugger/registerhandler.cpp b/src/plugins/debugger/registerhandler.cpp index 70bae1b2b38..12dd1d21316 100644 --- a/src/plugins/debugger/registerhandler.cpp +++ b/src/plugins/debugger/registerhandler.cpp @@ -51,9 +51,7 @@ using namespace Debugger::Constants; RegisterHandler::RegisterHandler(QObject *parent) : QAbstractTableModel(parent) -{ - setProperty(PROPERTY_REGISTER_FORMAT, "x"); -} +{} int RegisterHandler::rowCount(const QModelIndex &parent) const { diff --git a/src/plugins/debugger/registerwindow.cpp b/src/plugins/debugger/registerwindow.cpp index 13c83e28830..03239d8875a 100644 --- a/src/plugins/debugger/registerwindow.cpp +++ b/src/plugins/debugger/registerwindow.cpp @@ -74,14 +74,12 @@ void RegisterWindow::resizeEvent(QResizeEvent *ev) void RegisterWindow::contextMenuEvent(QContextMenuEvent *ev) { - enum { Hex, Bin, Dec, Raw, Oct, Nat, - Adjust, AlwaysAdjust, Reload, AlwaysReload, Count }; + enum { Adjust, AlwaysAdjust, Reload, AlwaysReload, Count }; QMenu menu; QAction *actions[Count]; - //QTreeWidgetItem *item = itemAt(ev->pos()); - QString format = model()->property(PROPERTY_REGISTER_FORMAT).toString(); - qDebug() << "FORMAT: " << format; + //QString format = model()->property(PROPERTY_REGISTER_FORMAT).toString(); + //qDebug() << "FORMAT: " << format; actions[Adjust] = menu.addAction("Adjust column widths to contents"); @@ -96,30 +94,12 @@ void RegisterWindow::contextMenuEvent(QContextMenuEvent *ev) actions[AlwaysReload]->setChecked(m_alwaysReloadContents); menu.addSeparator(); - - actions[Hex] = menu.addAction("Hexadecimal"); - actions[Hex]->setCheckable(true); - actions[Hex]->setChecked(format == "h"); - - actions[Bin] = menu.addAction("Binary"); - actions[Bin]->setCheckable(true); - actions[Bin]->setChecked(format == "t"); - - actions[Dec] = menu.addAction("Decimal"); - actions[Dec]->setCheckable(true); - actions[Dec]->setChecked(format == "d"); - - actions[Raw] = menu.addAction("Raw"); - actions[Raw]->setCheckable(true); - actions[Raw]->setChecked(format == "r"); - - actions[Nat] = menu.addAction("Natural"); - actions[Nat]->setCheckable(true); - actions[Nat]->setChecked(format == "N"); - - actions[Oct] = menu.addAction("Octal"); - actions[Oct]->setCheckable(true); - actions[Oct]->setChecked(format == "o"); + menu.addAction(theDebuggerAction(FormatHexadecimal)); + menu.addAction(theDebuggerAction(FormatDecimal)); + menu.addAction(theDebuggerAction(FormatOctal)); + menu.addAction(theDebuggerAction(FormatBinary)); + menu.addAction(theDebuggerAction(FormatRaw)); + menu.addAction(theDebuggerAction(FormatNatural)); menu.addSeparator(); menu.addAction(theDebuggerAction(SettingsDialog)); @@ -134,17 +114,6 @@ void RegisterWindow::contextMenuEvent(QContextMenuEvent *ev) reloadContents(); else if (act == actions[AlwaysReload]) setAlwaysReloadContents(!m_alwaysReloadContents); - else if (act == actions[Hex]) - model()->setProperty(PROPERTY_REGISTER_FORMAT, "h"); - else if (act == actions[Oct]) - model()->setProperty(PROPERTY_REGISTER_FORMAT, "o"); - else if (act == actions[Bin]) - model()->setProperty(PROPERTY_REGISTER_FORMAT, "t"); - else if (act == actions[Dec]) - model()->setProperty(PROPERTY_REGISTER_FORMAT, "d"); - else if (act == actions[Nat]) - model()->setProperty(PROPERTY_REGISTER_FORMAT, "N"); - } void RegisterWindow::resizeColumnsToContents() -- GitLab