Commit eb387087 authored by hjk's avatar hjk
Browse files

debugger: use new action scheme for number base selections

parent f48ff339
......@@ -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);
......
......@@ -176,6 +176,8 @@ enum DebuggerActionCode
FormatDecimal,
FormatOctal,
FormatBinary,
FormatRaw,
FormatNatural,
};
// singleton access
......
......@@ -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 };
}
......
......@@ -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);
}
......
......@@ -265,7 +265,7 @@ private:
//
// Register specific stuff
//
void reloadRegisters();
Q_SLOT void reloadRegisters();
void handleRegisterListNames(const GdbResultRecord &record);
void handleRegisterListValues(const GdbResultRecord &record);
......
......@@ -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
{
......
......@@ -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()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment