Commit abdc85f0 authored by hjk's avatar hjk

debugger: register view cosmetics

Show the current number base in the view.
parent 6fd0433c
......@@ -1320,28 +1320,9 @@ QList<Symbol> CdbDebugEngine::moduleSymbols(const QString &moduleName)
return rc;
}
static inline int registerFormatBase()
{
switch(checkedRegisterFormatAction()) {
case FormatHexadecimal:
return 16;
case FormatDecimal:
return 10;
case FormatOctal:
return 8;
case FormatBinary:
return 2;
break;
case FormatRaw:
case FormatNatural:
break;
}
return 10;
}
void CdbDebugEngine::reloadRegisters()
{
const int intBase = registerFormatBase();
const int intBase = 10;
if (debugCDB)
qDebug() << Q_FUNC_INFO << intBase;
QList<Register> registers;
......
......@@ -36,7 +36,6 @@
#include <QtCore/QSettings>
#include <QtGui/QAction>
#include <QtGui/QActionGroup>
#include <QtGui/QAbstractButton>
#include <QtGui/QRadioButton>
#include <QtGui/QCheckBox>
......@@ -54,7 +53,7 @@ namespace Internal {
//////////////////////////////////////////////////////////////////////////
DebuggerSettings::DebuggerSettings(QObject *parent)
: QObject(parent), m_registerFormatGroup(0)
: QObject(parent)
{}
DebuggerSettings::~DebuggerSettings()
......@@ -222,68 +221,6 @@ DebuggerSettings *DebuggerSettings::instance()
instance->insertItem(SynchronizeBreakpoints, item);
//
// Registers
//
instance->m_registerFormatGroup = new QActionGroup(instance);
instance->m_registerFormatGroup->setExclusive(true);
item = new SavedAction(instance);
item->setText(tr("Hexadecimal"));
item->setCheckable(true);
item->setSettingsKey(debugModeGroup, QLatin1String("FormatHexadecimal"));
item->setChecked(true);
item->setDefaultValue(false);
item->setData(FormatHexadecimal);
instance->insertItem(FormatHexadecimal, item);
instance->m_registerFormatGroup->addAction(item);
item = new SavedAction(instance);
item->setText(tr("Decimal"));
item->setCheckable(true);
item->setSettingsKey(debugModeGroup, QLatin1String("FormatDecimal"));
item->setDefaultValue(false);
item->setData(FormatDecimal);
instance->insertItem(FormatDecimal, item);
instance->m_registerFormatGroup->addAction(item);
item = new SavedAction(instance);
item->setText(tr("Octal"));
item->setCheckable(true);
item->setSettingsKey(debugModeGroup, QLatin1String("FormatOctal"));
item->setDefaultValue(false);
item->setData(FormatOctal);
instance->insertItem(FormatOctal, item);
instance->m_registerFormatGroup->addAction(item);
item = new SavedAction(instance);
item->setText(tr("Binary"));
item->setCheckable(true);
item->setSettingsKey(debugModeGroup, QLatin1String("FormatBinary"));
item->setDefaultValue(false);
item->setData(FormatBinary);
instance->insertItem(FormatBinary, item);
instance->m_registerFormatGroup->addAction(item);
item = new SavedAction(instance);
item->setText(tr("Raw"));
item->setCheckable(true);
item->setSettingsKey(debugModeGroup, QLatin1String("FormatRaw"));
item->setDefaultValue(false);
item->setData(FormatRaw);
instance->insertItem(FormatRaw, item);
instance->m_registerFormatGroup->addAction(item);
item = new SavedAction(instance);
item->setText(tr("Natural"));
item->setCheckable(true);
item->setSettingsKey(debugModeGroup, QLatin1String("FormatNatural"));
item->setDefaultValue(true);
item->setData(FormatNatural);
instance->insertItem(FormatNatural, item);
instance->m_registerFormatGroup->addAction(item);
//
// Settings
//
......@@ -373,10 +310,6 @@ DebuggerSettings *DebuggerSettings::instance()
return instance;
}
int DebuggerSettings::checkedRegisterFormatAction() const
{
return m_registerFormatGroup->checkedAction()->data().toInt();
}
//////////////////////////////////////////////////////////////////////////
//
......@@ -389,11 +322,6 @@ SavedAction *theDebuggerAction(int code)
return DebuggerSettings::instance()->item(code);
}
int checkedRegisterFormatAction()
{
return DebuggerSettings::instance()->checkedRegisterFormatAction();
}
bool theDebuggerBoolSetting(int code)
{
return DebuggerSettings::instance()->item(code)->value().toBool();
......
......@@ -55,16 +55,12 @@ public:
static DebuggerSettings *instance();
// Return one of FormatHexadecimal, FormatDecimal,...
int checkedRegisterFormatAction() const;
public slots:
void readSettings(QSettings *settings);
void writeSettings(QSettings *settings) const;
private:
QHash<int, Core::Utils::SavedAction *> m_items;
QActionGroup *m_registerFormatGroup;
};
......@@ -120,22 +116,11 @@ enum DebuggerActionCode
SelectedPluginBreakpoints,
NoPluginBreakpoints,
SelectedPluginBreakpointsPattern,
// Registers
FormatHexadecimal,
FormatDecimal,
FormatOctal,
FormatBinary,
FormatRaw,
FormatNatural,
};
// singleton access
Core::Utils::SavedAction *theDebuggerAction(int code);
// Return one of FormatHexadecimal, FormatDecimal,...
int checkedRegisterFormatAction();
// convenience
bool theDebuggerBoolSetting(int code);
QString theDebuggerStringSetting(int code);
......
......@@ -762,20 +762,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
connect(resetToSimpleAction, SIGNAL(triggered()),
m_manager, SLOT(setSimpleDockWidgetArrangement()));
connect(theDebuggerAction(FormatHexadecimal), SIGNAL(triggered()),
m_manager, SLOT(reloadRegisters()));
connect(theDebuggerAction(FormatDecimal), SIGNAL(triggered()),
m_manager, SLOT(reloadRegisters()));
connect(theDebuggerAction(FormatOctal), SIGNAL(triggered()),
m_manager, SLOT(reloadRegisters()));
connect(theDebuggerAction(FormatBinary), SIGNAL(triggered()),
m_manager, SLOT(reloadRegisters()));
connect(theDebuggerAction(FormatRaw), SIGNAL(triggered()),
m_manager, SLOT(reloadRegisters()));
connect(theDebuggerAction(FormatNatural), SIGNAL(triggered()),
m_manager, SLOT(reloadRegisters()));
// FIXME:
// FIXME:
addAutoReleasedObject(new CommonOptionsPage);
addAutoReleasedObject(new DebuggingHelperOptionPage);
foreach (Core::IOptionsPage* op, engineOptionPages)
......
......@@ -2652,28 +2652,9 @@ void GdbEngine::handleStackListThreads(const GdbResultRecord &record, const QVar
//
//////////////////////////////////////////////////////////////////////
static inline char registerFormatChar()
{
switch(checkedRegisterFormatAction()) {
case FormatHexadecimal:
return 'x';
case FormatDecimal:
return 'd';
case FormatOctal:
return 'o';
case FormatBinary:
return 't';
case FormatRaw:
return 'r';
default:
break;
}
return 'N';
}
void GdbEngine::reloadRegisters()
{
postCommand(_("-data-list-register-values ") + _c(registerFormatChar()),
postCommand(_("-data-list-register-values d"),
Discardable, CB(handleRegisterListValues));
}
......
......@@ -50,8 +50,9 @@ using namespace Debugger::Constants;
//////////////////////////////////////////////////////////////////
RegisterHandler::RegisterHandler(QObject *parent)
: QAbstractTableModel(parent)
{}
: QAbstractTableModel(parent), m_base(16)
{
}
int RegisterHandler::rowCount(const QModelIndex &parent) const
{
......@@ -66,19 +67,33 @@ int RegisterHandler::columnCount(const QModelIndex &parent) const
QVariant RegisterHandler::data(const QModelIndex &index, int role) const
{
static const QVariant red = QColor(200, 0, 0);
if (role == Qt::UserRole)
return m_base;
if (!index.isValid() || index.row() >= m_registers.size())
return QVariant();
const Register &reg = m_registers.at(index.row());
const QString padding = " ";
if (role == Qt::DisplayRole) {
switch (index.column()) {
case 0: return reg.name;
case 1: return reg.value;
case 0: return padding + reg.name + padding;
case 1: {
bool ok = true;
qulonglong value = reg.value.toULongLong(&ok, 0);
return padding + QString::number(value, m_base) + padding;
}
}
}
if (role == Qt::TextAlignmentRole && index.column() == 1)
return Qt::AlignRight;
if (role == Qt::TextColorRole && reg.changed && index.column() == 1)
return red;
return QVariant();
}
......@@ -88,7 +103,7 @@ QVariant RegisterHandler::headerData(int section, Qt::Orientation orientation,
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch (section) {
case 0: return tr("Name");
case 1: return tr("Value");
case 1: return tr("Value (base %1)").arg(m_base);
};
}
return QVariant();
......@@ -115,3 +130,9 @@ QList<Register> RegisterHandler::registers() const
{
return m_registers;
}
void RegisterHandler::setNumberBase(int base)
{
m_base = base;
emit reset();
}
......@@ -60,6 +60,7 @@ public:
void setRegisters(const QList<Register> &registers);
QList<Register> registers() const;
void removeAll();
Q_SLOT void setNumberBase(int base);
private:
int rowCount(const QModelIndex &parent = QModelIndex()) const;
......@@ -67,8 +68,9 @@ private:
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
QList<Register> m_registers;
int m_base;
};
} // namespace Internal
......
......@@ -67,46 +67,51 @@ void RegisterWindow::resizeEvent(QResizeEvent *ev)
void RegisterWindow::contextMenuEvent(QContextMenuEvent *ev)
{
enum { Adjust, AlwaysAdjust, Reload, AlwaysReload, Count };
QMenu menu;
QAction *actions[Count];
//QString format = model()->property(PROPERTY_REGISTER_FORMAT).toString();
//qDebug() << "FORMAT: " << format;
actions[Adjust] = menu.addAction(tr("Adjust column widths to contents"));
actions[AlwaysAdjust] = menu.addAction(tr("Always adjust column widths to contents"));
actions[AlwaysAdjust]->setCheckable(true);
actions[AlwaysAdjust]->setChecked(m_alwaysResizeColumnsToContents);
actions[Reload] = menu.addAction(tr("Reload register listing"));
actions[AlwaysReload] = menu.addAction(tr("Always reload register listing"));
actions[AlwaysReload]->setCheckable(true);
actions[AlwaysReload]->setChecked(m_alwaysReloadContents);
QAction *actAdjust = menu.addAction(tr("Adjust column widths to contents"));
QAction *actAlwaysAdjust =
menu.addAction(tr("Always adjust column widths to contents"));
actAlwaysAdjust->setCheckable(true);
actAlwaysAdjust->setChecked(m_alwaysResizeColumnsToContents);
QAction *actReload = menu.addAction(tr("Reload register listing"));
QAction *actAlwaysReload = menu.addAction(tr("Always reload register listing"));
actAlwaysReload->setCheckable(true);
actAlwaysReload->setChecked(m_alwaysReloadContents);
menu.addSeparator();
menu.addAction(theDebuggerAction(FormatHexadecimal));
menu.addAction(theDebuggerAction(FormatDecimal));
menu.addAction(theDebuggerAction(FormatOctal));
menu.addAction(theDebuggerAction(FormatBinary));
menu.addAction(theDebuggerAction(FormatRaw));
menu.addAction(theDebuggerAction(FormatNatural));
int base = model()->data(QModelIndex(), Qt::UserRole).toInt();
QAction *act16 = menu.addAction(tr("Hexadecimal"));
act16->setCheckable(true);
act16->setChecked(base == 16);
QAction *act10 = menu.addAction(tr("Decimal"));
act10->setCheckable(true);
act10->setChecked(base == 10);
QAction *act8 = menu.addAction(tr("Octal"));
act8->setCheckable(true);
act8->setChecked(base == 8);
QAction *act2 = menu.addAction(tr("Binary"));
act2->setCheckable(true);
act2->setChecked(base == 2);
menu.addSeparator();
menu.addAction(theDebuggerAction(SettingsDialog));
QAction *act = menu.exec(ev->globalPos());
if (act == actions[Adjust])
if (act == actAdjust)
resizeColumnsToContents();
else if (act == actions[AlwaysAdjust])
else if (act == actAlwaysAdjust)
setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents);
else if (act == actions[Reload])
else if (act == actReload)
reloadContents();
else if (act == actions[AlwaysReload])
else if (act == actAlwaysReload)
setAlwaysReloadContents(!m_alwaysReloadContents);
else if (act) {
base = (act == act10 ? 10 : act == act8 ? 8 : act == act2 ? 2 : 16);
QMetaObject::invokeMethod(model(), "setNumberBase", Q_ARG(int, base));
}
}
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