diff --git a/src/plugins/debugger/breakwindow.cpp b/src/plugins/debugger/breakwindow.cpp index 8f3b533f581c3fa7bb536e59cb090b17942a768a..92fe3c7cb1595b3f93decd8386021f70b74dbb0f 100644 --- a/src/plugins/debugger/breakwindow.cpp +++ b/src/plugins/debugger/breakwindow.cpp @@ -101,7 +101,7 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev) menu.addAction(act1); menu.addAction(act2); menu.addAction(act4); - menu.addAction(theDebuggerSetting(SettingsDialog)->action()); + menu.addAction(theDebuggerAction(SettingsDialog)); QAction *act = menu.exec(ev->globalPos()); diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index 7a563d37f27c3227c83c6002c0950f5a3d968af1..47a72dc0a9b32a07b51eff19ca7e5d6bdc5924dc 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -44,28 +44,27 @@ namespace Internal { ////////////////////////////////////////////////////////////////////////// // -// QtcSettingsItem +// DebuggerAction // ////////////////////////////////////////////////////////////////////////// -QtcSettingsItem::QtcSettingsItem(QObject *parent) - : QObject(parent) +DebuggerAction::DebuggerAction(QObject *parent) + : QAction(parent) { - m_action = new QAction(this); - connect(m_action, SIGNAL(triggered(bool)), this, SLOT(actionTriggered(bool))); + connect(this, SIGNAL(triggered(bool)), this, SLOT(actionTriggered(bool))); } -QVariant QtcSettingsItem::value() const +QVariant DebuggerAction::value() const { return m_value; } -void QtcSettingsItem::setValue(const QVariant &value, bool doemit) +void DebuggerAction::setValue(const QVariant &value, bool doemit) { if (value != m_value) { m_value = value; - if (m_action->isCheckable()) - m_action->setChecked(m_value.toBool()); + if (this->isCheckable()) + this->setChecked(m_value.toBool()); if (doemit) { emit valueChanged(m_value); emit boolValueChanged(m_value.toBool()); @@ -74,63 +73,53 @@ void QtcSettingsItem::setValue(const QVariant &value, bool doemit) } } -QVariant QtcSettingsItem::defaultValue() const +QVariant DebuggerAction::defaultValue() const { return m_defaultValue; } -void QtcSettingsItem::setDefaultValue(const QVariant &value) +void DebuggerAction::setDefaultValue(const QVariant &value) { m_defaultValue = value; } -QString QtcSettingsItem::settingsKey() const +QString DebuggerAction::settingsKey() const { return m_settingsKey; } -void QtcSettingsItem::setSettingsKey(const QString &key) +void DebuggerAction::setSettingsKey(const QString &key) { m_settingsKey = key; } -void QtcSettingsItem::setSettingsKey(const QString &group, const QString &key) +void DebuggerAction::setSettingsKey(const QString &group, const QString &key) { m_settingsKey = key; m_settingsGroup = group; } -QString QtcSettingsItem::settingsGroup() const +QString DebuggerAction::settingsGroup() const { return m_settingsGroup; } -void QtcSettingsItem::setSettingsGroup(const QString &group) +void DebuggerAction::setSettingsGroup(const QString &group) { m_settingsGroup = group; } -QString QtcSettingsItem::text() const -{ - return m_action->text(); -} - -void QtcSettingsItem::setText(const QString &value) -{ - m_action->setText(value); -} - -QString QtcSettingsItem::textPattern() const +QString DebuggerAction::textPattern() const { return m_textPattern; } -void QtcSettingsItem::setTextPattern(const QString &value) +void DebuggerAction::setTextPattern(const QString &value) { m_textPattern = value; } -QAction *QtcSettingsItem::updatedAction(const QString &text0) +QAction *DebuggerAction::updatedAction(const QString &text0) { QString text = text0; bool enabled = true; @@ -144,13 +133,13 @@ QAction *QtcSettingsItem::updatedAction(const QString &text0) text = m_textPattern.arg(text0); } } - m_action->setEnabled(enabled); - m_action->setData(text0); - m_action->setText(text); - return m_action; + this->setEnabled(enabled); + this->setData(text0); + this->setText(text); + return this; } -void QtcSettingsItem::readSettings(QSettings *settings) +void DebuggerAction::readSettings(QSettings *settings) { if (m_settingsGroup.isEmpty() || m_settingsKey.isEmpty()) return; @@ -160,7 +149,7 @@ void QtcSettingsItem::readSettings(QSettings *settings) settings->endGroup(); } -void QtcSettingsItem::writeSettings(QSettings *settings) +void DebuggerAction::writeSettings(QSettings *settings) { if (m_settingsGroup.isEmpty() || m_settingsKey.isEmpty()) return; @@ -170,12 +159,7 @@ void QtcSettingsItem::writeSettings(QSettings *settings) settings->endGroup(); } -QAction *QtcSettingsItem::action() -{ - return m_action; -} - -void QtcSettingsItem::connectWidget(QWidget *widget, ApplyMode applyMode) +void DebuggerAction::connectWidget(QWidget *widget, ApplyMode applyMode) { using namespace Core::Utils; //qDebug() << "CONNECT WIDGET " << widget << " TO " << m_settingsKey; @@ -206,22 +190,22 @@ void QtcSettingsItem::connectWidget(QWidget *widget, ApplyMode applyMode) } } -void QtcSettingsItem::apply(QSettings *s) +void DebuggerAction::apply(QSettings *s) { setValue(m_deferedValue); if (s) writeSettings(s); } -void QtcSettingsItem::uncheckableButtonClicked() +void DebuggerAction::uncheckableButtonClicked() { QAbstractButton *button = qobject_cast<QAbstractButton *>(sender()); QTC_ASSERT(button, return); //qDebug() << "UNCHECKABLE BUTTON: " << sender(); - m_action->trigger(); + QAction::trigger(); } -void QtcSettingsItem::checkableButtonClicked(bool) +void DebuggerAction::checkableButtonClicked(bool) { QAbstractButton *button = qobject_cast<QAbstractButton *>(sender()); QTC_ASSERT(button, return); @@ -232,7 +216,7 @@ void QtcSettingsItem::checkableButtonClicked(bool) setValue(button->isChecked()); } -void QtcSettingsItem::lineEditEditingFinished() +void DebuggerAction::lineEditEditingFinished() { QLineEdit *lineEdit = qobject_cast<QLineEdit *>(sender()); QTC_ASSERT(lineEdit, return); @@ -243,7 +227,7 @@ void QtcSettingsItem::lineEditEditingFinished() setValue(lineEdit->text()); } -void QtcSettingsItem::pathChooserEditingFinished() +void DebuggerAction::pathChooserEditingFinished() { using namespace Core::Utils; PathChooser *pathChooser = qobject_cast<PathChooser *>(sender()); @@ -255,61 +239,63 @@ void QtcSettingsItem::pathChooserEditingFinished() setValue(pathChooser->path()); } -void QtcSettingsItem::actionTriggered(bool on) +void DebuggerAction::actionTriggered(bool) { - Q_UNUSED(on); - if (QAction *action = qobject_cast<QAction *>(sender())) { - if (action->isCheckable()) - setValue(action->isChecked()); - } + if (this->isCheckable()) + setValue(this->isChecked()); } +void DebuggerAction::trigger(const QVariant &data) +{ + setData(data); + QAction::trigger(); +} ////////////////////////////////////////////////////////////////////////// // -// QtcSettingsPool +// DebuggerSettings // ////////////////////////////////////////////////////////////////////////// -QtcSettingsPool::QtcSettingsPool(QObject *parent) +DebuggerSettings::DebuggerSettings(QObject *parent) : QObject(parent) {} -QtcSettingsPool::~QtcSettingsPool() +DebuggerSettings::~DebuggerSettings() { qDeleteAll(m_items); } -void QtcSettingsPool::insertItem(int code, QtcSettingsItem *item) +void DebuggerSettings::insertItem(int code, DebuggerAction *item) { m_items[code] = item; } -void QtcSettingsPool::readSettings(QSettings *settings) +void DebuggerSettings::readSettings(QSettings *settings) { - foreach (QtcSettingsItem *item, m_items) + foreach (DebuggerAction *item, m_items) item->readSettings(settings); } -void QtcSettingsPool::writeSettings(QSettings *settings) +void DebuggerSettings::writeSettings(QSettings *settings) { - foreach (QtcSettingsItem *item, m_items) + foreach (DebuggerAction *item, m_items) item->writeSettings(settings); } -QtcSettingsItem *QtcSettingsPool::item(int code) +DebuggerAction *DebuggerSettings::item(int code) { QTC_ASSERT(m_items.value(code, 0), return 0); return m_items.value(code, 0); } -QString QtcSettingsPool::dump() +QString DebuggerSettings::dump() { QString out; QTextStream ts(&out); ts << "Debugger settings: "; - foreach (QtcSettingsItem *item, m_items) + foreach (DebuggerAction *item, m_items) ts << "\n" << item->value().toString(); return out; } @@ -318,175 +304,156 @@ QString QtcSettingsPool::dump() ////////////////////////////////////////////////////////////////////////// // -// Debugger specific stuff +// Debugger specific actions and settings // ////////////////////////////////////////////////////////////////////////// -#if 0 - QString dump(); - - QString m_gdbCmd; - QString m_gdbEnv; - bool m_autoRun; - bool m_autoQuit; - - bool m_useDumpers; - bool m_skipKnownFrames; - bool m_debugDumpers; - bool m_useToolTips; - bool m_listSourceFiles; - QString m_scriptFile; - - bool m_pluginAllBreakpoints; - bool m_pluginSelectedBreakpoints; - bool m_pluginNoBreakpoints; - QString m_pluginSelectedBreakpointsPattern; -#endif - - -QtcSettingsPool *theDebuggerSettings() +DebuggerSettings *theDebuggerSettings() { - static QtcSettingsPool *instance = 0; + static DebuggerSettings *instance = 0; if (instance) return instance; - instance = new QtcSettingsPool; + instance = new DebuggerSettings; - QtcSettingsItem *item = 0; + DebuggerAction *item = 0; - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(AdjustColumnWidths, item); item->setText(QObject::tr("Adjust column widths to contents")); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(AlwaysAdjustColumnWidths, item); item->setText(QObject::tr("Always adjust column widths to contents")); - item->action()->setCheckable(true); + item->setCheckable(true); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(WatchExpression, item); item->setTextPattern(QObject::tr("Watch expression \"%1\"")); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(RemoveWatchExpression, item); item->setTextPattern(QObject::tr("Remove watch expression \"%1\"")); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(WatchExpressionInWindow, item); item->setTextPattern(QObject::tr("Watch expression \"%1\" in separate window")); + item = new DebuggerAction(instance); + instance->insertItem(AssignValue, item); + // // Dumpers // - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(SettingsDialog, item); item->setText(QObject::tr("Debugger properties...")); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(DebugDumpers, item); item->setText(QObject::tr("Debug custom dumpers")); - item->action()->setCheckable(true); + item->setCheckable(true); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(RecheckDumpers, item); item->setText(QObject::tr("Recheck custom dumper availability")); // // Breakpoints // - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(SynchronizeBreakpoints, item); item->setText(QObject::tr("Syncronize breakpoints")); // - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(AutoQuit, item); item->setText(QObject::tr("Automatically quit debugger")); - item->action()->setCheckable(true); + item->setCheckable(true); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(SkipKnownFrames, item); item->setText(QObject::tr("Skip known frames")); - item->action()->setCheckable(true); + item->setCheckable(true); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(UseToolTips, item); item->setText(QObject::tr("Use tooltips when debugging")); - item->action()->setCheckable(true); + item->setCheckable(true); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(ListSourceFiles, item); item->setText(QObject::tr("List source files")); - item->action()->setCheckable(true); + item->setCheckable(true); // // Settings // - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(GdbLocation, item); item->setSettingsKey("DebugMode", "Location"); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(GdbEnvironment, item); item->setSettingsKey("DebugMode", "Environment"); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(GdbScriptFile, item); item->setSettingsKey("DebugMode", "ScriptFile"); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(GdbAutoQuit, item); item->setSettingsKey("DebugMode", "AutoQuit"); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(GdbAutoRun, item); item->setSettingsKey("DebugMode", "AutoRun"); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(UseToolTips, item); item->setSettingsKey("DebugMode", "UseToolTips"); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(UseDumpers, item); item->setSettingsKey("DebugMode", "UseCustomDumpers"); item->setText(QObject::tr("Use custom dumpers")); - item->action()->setCheckable(true); + item->setCheckable(true); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(ListSourceFiles, item); item->setSettingsKey("DebugMode", "ListSourceFiles"); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(SkipKnownFrames, item); item->setSettingsKey("DebugMode", "SkipKnownFrames"); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(DebugDumpers, item); item->setSettingsKey("DebugMode", "DebugDumpers"); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(AllPluginBreakpoints, item); item->setSettingsKey("DebugMode", "AllPluginBreakpoints"); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(SelectedPluginBreakpoints, item); item->setSettingsKey("DebugMode", "SelectedPluginBreakpoints"); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(NoPluginBreakpoints, item); item->setSettingsKey("DebugMode", "NoPluginBreakpoints"); - item = new QtcSettingsItem(instance); + item = new DebuggerAction(instance); instance->insertItem(SelectedPluginBreakpointsPattern, item); item->setSettingsKey("DebugMode", "SelectedPluginBreakpointsPattern"); return instance; } -QtcSettingsItem *theDebuggerSetting(int code) +DebuggerAction *theDebuggerAction(int code) { return theDebuggerSettings()->item(code); } diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index 49ae6ed116f471b2880aeb561ed1c00ac45bf1c0..2a64e45c2ae5222ba025e3c5eae28b625c73165a 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -35,8 +35,9 @@ #include <QtCore/QVariant> #include <QtCore/QList> +#include <QtGui/QAction> + QT_BEGIN_NAMESPACE -class QAction; class QSettings; QT_END_NAMESPACE @@ -46,12 +47,12 @@ namespace Internal { enum ApplyMode { ImmediateApply, DeferedApply }; -class QtcSettingsItem : public QObject +class DebuggerAction : public QAction { Q_OBJECT public: - QtcSettingsItem(QObject *parent = 0); + DebuggerAction(QObject *parent = 0); virtual QVariant value() const; Q_SLOT virtual void setValue(const QVariant &value, bool doemit = true); @@ -59,8 +60,8 @@ public: virtual QVariant defaultValue() const; Q_SLOT virtual void setDefaultValue(const QVariant &value); - virtual QAction *action(); virtual QAction *updatedAction(const QString &newText); + Q_SLOT virtual void trigger(const QVariant &data); // used for persistency virtual QString settingsKey() const; @@ -76,9 +77,6 @@ public: virtual void connectWidget(QWidget *widget, ApplyMode applyMode = DeferedApply); Q_SLOT virtual void apply(QSettings *settings); - virtual QString text() const; - Q_SLOT virtual void setText(const QString &value); - virtual QString textPattern() const; Q_SLOT virtual void setTextPattern(const QString &value); @@ -101,20 +99,19 @@ private: QString m_settingsGroup; QString m_textPattern; QString m_textData; - QAction *m_action; QHash<QObject *, ApplyMode> m_applyModes; }; -class QtcSettingsPool : public QObject +class DebuggerSettings : public QObject { Q_OBJECT public: - QtcSettingsPool(QObject *parent = 0); - ~QtcSettingsPool(); + DebuggerSettings(QObject *parent = 0); + ~DebuggerSettings(); - void insertItem(int code, QtcSettingsItem *item); - QtcSettingsItem *item(int code); + void insertItem(int code, DebuggerAction *item); + DebuggerAction *item(int code); QString dump(); @@ -123,13 +120,13 @@ public slots: void writeSettings(QSettings *settings); private: - QHash<int, QtcSettingsItem *> m_items; + QHash<int, DebuggerAction *> m_items; }; /////////////////////////////////////////////////////////// -enum DebuggerSettingsCode +enum DebuggerActionCode { // General SettingsDialog, @@ -154,6 +151,7 @@ enum DebuggerSettingsCode UseDumpers, DebugDumpers, UseToolTips, + AssignValue, // Source List ListSourceFiles, @@ -172,8 +170,8 @@ enum DebuggerSettingsCode }; // singleton access -QtcSettingsPool *theDebuggerSettings(); -QtcSettingsItem *theDebuggerSetting(int code); +DebuggerSettings *theDebuggerSettings(); +DebuggerAction *theDebuggerAction(int code); // convienience bool theDebuggerBoolSetting(int code); diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 8369eb33111a7c09e24d25f721adb9d15433744e..5b7bb4be8ed236a70bcd5f1b980b9e37d6fb30eb 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -255,14 +255,10 @@ void DebuggerManager::init() this, SLOT(expandChildren(QModelIndex))); connect(localsView, SIGNAL(requestCollapseChildren(QModelIndex)), this, SLOT(collapseChildren(QModelIndex))); - connect(localsView, SIGNAL(requestAssignValue(QString,QString)), - this, SLOT(assignValueInDebugger(QString,QString))); // Watchers QTreeView *watchersView = qobject_cast<QTreeView *>(m_watchersWindow); watchersView->setModel(m_watchHandler->model()); - connect(watchersView, SIGNAL(requestAssignValue(QString,QString)), - this, SLOT(assignValueInDebugger(QString,QString))); connect(watchersView, SIGNAL(requestExpandChildren(QModelIndex)), this, SLOT(expandChildren(QModelIndex))); connect(watchersView, SIGNAL(requestCollapseChildren(QModelIndex)), @@ -271,6 +267,8 @@ void DebuggerManager::init() this, SIGNAL(sessionValueRequested(QString,QVariant*))); connect(m_watchHandler, SIGNAL(setSessionValueRequested(QString,QVariant)), this, SIGNAL(setSessionValueRequested(QString,QVariant))); + connect(theDebuggerAction(AssignValue), SIGNAL(triggered()), + this, SLOT(assignValueInDebugger())); // Tooltip QTreeView *tooltipView = qobject_cast<QTreeView *>(m_tooltipWindow); @@ -965,6 +963,15 @@ void DebuggerManager::exitDebugger() emit debuggingFinished(); } +void DebuggerManager::assignValueInDebugger() +{ + if (QAction *action = qobject_cast<QAction *>(sender())) { + QString str = action->data().toString(); + int i = str.indexOf('='); + if (i != -1) + assignValueInDebugger(str.left(i), str.mid(i + 1)); + } +} void DebuggerManager::assignValueInDebugger(const QString &expr, const QString &value) { QTC_ASSERT(m_engine, return); @@ -1092,7 +1099,7 @@ void DebuggerManager::addToWatchWindow() if (!editor) return; QTextCursor tc = editor->textCursor(); - theDebuggerSetting(WatchExpression)->setValue(tc.selectedText()); + theDebuggerAction(WatchExpression)->setValue(tc.selectedText()); } void DebuggerManager::setBreakpoint(const QString &fileName, int lineNumber) diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index deeb4375e7e4feb3984ae6bf5745d0fffb533f93..77e629e38e501eedc93fe38613cdc65e6fba08eb 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -237,6 +237,7 @@ public slots: void sessionLoaded(); void aboutToSaveSession(); + void assignValueInDebugger(); void assignValueInDebugger(const QString &expr, const QString &value); void executeDebuggerCommand(const QString &command); diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index ff3d08e50d14fcbb88bb92a654751a5337aeaf1c..13de5d0c8e762f6dbd5c121c85ce85fc45b288f5 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -269,35 +269,35 @@ QWidget *GdbOptionPage::createPage(QWidget *parent) m_ui.scriptFileChooser->setExpectedKind(Core::Utils::PathChooser::File); m_ui.scriptFileChooser->setPromptDialogTitle(tr("Choose Location of Startup Script File")); - theDebuggerSetting(GdbLocation) + theDebuggerAction(GdbLocation) ->connectWidget(m_ui.gdbLocationChooser); - theDebuggerSetting(GdbScriptFile) + theDebuggerAction(GdbScriptFile) ->connectWidget(m_ui.scriptFileChooser); - theDebuggerSetting(GdbEnvironment) + theDebuggerAction(GdbEnvironment) ->connectWidget(m_ui.environmentEdit); - theDebuggerSetting(AllPluginBreakpoints) + theDebuggerAction(AllPluginBreakpoints) ->connectWidget(m_ui.radioButtonAllPluginBreakpoints); - theDebuggerSetting(SelectedPluginBreakpoints) + theDebuggerAction(SelectedPluginBreakpoints) ->connectWidget(m_ui.radioButtonSelectedPluginBreakpoints); - theDebuggerSetting(NoPluginBreakpoints) + theDebuggerAction(NoPluginBreakpoints) ->connectWidget(m_ui.radioButtonNoPluginBreakpoints); - theDebuggerSetting(SelectedPluginBreakpointsPattern) + theDebuggerAction(SelectedPluginBreakpointsPattern) ->connectWidget(m_ui.lineEditSelectedPluginBreakpointsPattern); - theDebuggerSetting(UseDumpers) + theDebuggerAction(UseDumpers) ->connectWidget(m_ui.checkBoxUseDumpers); - theDebuggerSetting(SkipKnownFrames) + theDebuggerAction(SkipKnownFrames) ->connectWidget(m_ui.checkBoxSkipKnownFrames); - theDebuggerSetting(UseToolTips) + theDebuggerAction(UseToolTips) ->connectWidget(m_ui.checkBoxUseToolTips); - theDebuggerSetting(DebugDumpers) + theDebuggerAction(DebugDumpers) ->connectWidget(m_ui.checkBoxDebugDumpers); - theDebuggerSetting(SelectedPluginBreakpointsPattern) + theDebuggerAction(SelectedPluginBreakpointsPattern) ->connectWidget(m_ui.lineEditSelectedPluginBreakpointsPattern); m_ui.lineEditSelectedPluginBreakpointsPattern-> - setEnabled(theDebuggerSetting(SelectedPluginBreakpoints)->value().toBool()); + setEnabled(theDebuggerAction(SelectedPluginBreakpoints)->value().toBool()); connect(m_ui.radioButtonSelectedPluginBreakpoints, SIGNAL(toggled(bool)), m_ui.lineEditSelectedPluginBreakpointsPattern, SLOT(setEnabled(bool))); @@ -325,20 +325,20 @@ void GdbOptionPage::apply() { QSettings *s = ICore::instance()->settings(); - theDebuggerSetting(GdbLocation)->apply(s); - theDebuggerSetting(GdbScriptFile)->apply(s); - theDebuggerSetting(GdbEnvironment)->apply(s); + theDebuggerAction(GdbLocation)->apply(s); + theDebuggerAction(GdbScriptFile)->apply(s); + theDebuggerAction(GdbEnvironment)->apply(s); - theDebuggerSetting(AllPluginBreakpoints)->apply(s); - theDebuggerSetting(SelectedPluginBreakpoints)->apply(s); - theDebuggerSetting(NoPluginBreakpoints)->apply(s); - theDebuggerSetting(SelectedPluginBreakpointsPattern)->apply(s); + theDebuggerAction(AllPluginBreakpoints)->apply(s); + theDebuggerAction(SelectedPluginBreakpoints)->apply(s); + theDebuggerAction(NoPluginBreakpoints)->apply(s); + theDebuggerAction(SelectedPluginBreakpointsPattern)->apply(s); - theDebuggerSetting(UseDumpers)->apply(s); - theDebuggerSetting(SkipKnownFrames)->apply(s); - theDebuggerSetting(UseToolTips)->apply(s); - theDebuggerSetting(DebugDumpers)->apply(s); - theDebuggerSetting(SelectedPluginBreakpointsPattern)->apply(s); + theDebuggerAction(UseDumpers)->apply(s); + theDebuggerAction(SkipKnownFrames)->apply(s); + theDebuggerAction(UseToolTips)->apply(s); + theDebuggerAction(DebugDumpers)->apply(s); + theDebuggerAction(SelectedPluginBreakpointsPattern)->apply(s); } } // namespace Internal @@ -715,7 +715,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess connect(m_manager, SIGNAL(debugModeRequested()), this, SLOT(activateDebugMode())); - connect(theDebuggerSetting(SettingsDialog)->action(), SIGNAL(triggered()), + connect(theDebuggerAction(SettingsDialog), SIGNAL(triggered()), this, SLOT(showSettingsDialog())); return true; @@ -809,7 +809,7 @@ void DebuggerPlugin::requestMark(TextEditor::ITextEditor *editor, int lineNumber void DebuggerPlugin::showToolTip(TextEditor::ITextEditor *editor, const QPoint &point, int pos) { - if (!theDebuggerSetting(UseToolTips)->value().toBool()) + if (!theDebuggerBoolSetting(UseToolTips)) return; QPlainTextEdit *plaintext = qobject_cast<QPlainTextEdit*>(editor->widget()); diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index f6cb80deb5052fbe95ca2096db05935ef13c4f45..8b5ed5ea018d2c05d3a4bff9f7d9fd602e560667 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -285,11 +285,11 @@ void GdbEngine::initializeConnections() q, SLOT(showApplicationOutput(QString)), Qt::QueuedConnection); - connect(theDebuggerSetting(UseDumpers), SIGNAL(boolValueChanged(bool)), + connect(theDebuggerAction(UseDumpers), SIGNAL(boolValueChanged(bool)), this, SLOT(setUseDumpers(bool))); - connect(theDebuggerSetting(DebugDumpers), SIGNAL(boolValueChanged(bool)), + connect(theDebuggerAction(DebugDumpers), SIGNAL(boolValueChanged(bool)), this, SLOT(setDebugDumpers(bool))); - connect(theDebuggerSetting(RecheckDumpers)->action(), SIGNAL(triggered()), + connect(theDebuggerAction(RecheckDumpers), SIGNAL(triggered()), this, SLOT(recheckCustomDumperAvailability())); } @@ -320,7 +320,7 @@ void GdbEngine::gdbProcError(QProcess::ProcessError error) msg = QString(tr("The Gdb process failed to start. Either the " "invoked program '%1' is missing, or you may have insufficient " "permissions to invoke the program.")) - .arg(theDebuggerSetting(GdbLocation)->value().toString()); + .arg(theDebuggerStringSetting(GdbLocation)); break; case QProcess::Crashed: msg = tr("The Gdb process crashed some time after starting " @@ -1235,12 +1235,11 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) QString msg = data.findChild("consolestreamoutput").data(); if (msg.contains("Stopped due to shared library event") || reason.isEmpty()) { - if (theDebuggerSetting(SelectedPluginBreakpoints)->value().toBool()) { + if (theDebuggerBoolSetting(SelectedPluginBreakpoints)) { debugMessage("SHARED LIBRARY EVENT: " + data.toString()); - QString pattern = theDebuggerSetting(SelectedPluginBreakpointsPattern) - ->value().toString(); - debugMessage("PATTERN: " + pattern); - sendCommand("sharedlibrary " + pattern); + QString pat = theDebuggerStringSetting(SelectedPluginBreakpointsPattern); + debugMessage("PATTERN: " + pat); + sendCommand("sharedlibrary " + pat); continueInferior(); q->showStatusMessage(tr("Loading %1...").arg(QString(data.toString()))); return; @@ -1306,7 +1305,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) frame.findChild("func").data() + '%'; QApplication::alert(q->mainWindow(), 3000); - if (theDebuggerSetting(ListSourceFiles)->value().toBool()) + if (theDebuggerAction(ListSourceFiles)->value().toBool()) reloadSourceFiles(); sendCommand("-break-list", BreakList); QVariant var = QVariant::fromValue<GdbMi>(data); diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 7c58e2ee7a7633e8c0870a6eb9fb61a01078786a..9dcec117d3b488596011ecd21a5cd7c70238e9fe 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -368,30 +368,13 @@ WatchHandler::WatchHandler() m_incompleteSet.clear(); m_displaySet = m_completeSet; - connect(theDebuggerSetting(WatchExpression)->action(), + connect(theDebuggerAction(WatchExpression), SIGNAL(triggered()), this, SLOT(watchExpression())); - connect(theDebuggerSetting(RemoveWatchExpression)->action(), + connect(theDebuggerAction(RemoveWatchExpression), SIGNAL(triggered()), this, SLOT(removeWatchExpression())); } -bool WatchHandler::setData(const QModelIndex &idx, - const QVariant &value, int role) -{ -/* - Q_UNUSED(idx); - Q_UNUSED(value); - Q_UNUSED(role); - if (role == VisualRole) { - QString iname = inameFromIndex(index); - setDisplayedIName(iname, value.toBool()); - return true; - } - return true; -*/ - return QAbstractItemModel::setData(idx, value, role); -} - static QString niceType(QString type) { if (type.contains("std::")) { @@ -510,6 +493,9 @@ QVariant WatchHandler::data(const QModelIndex &idx, int role) const break; } + case ExpressionRole: + return data.exp; + case INameRole: return data.iname; @@ -543,7 +529,7 @@ Qt::ItemFlags WatchHandler::flags(const QModelIndex &idx) const // enabled, editable, selectable, checkable, and can be used both as the // source of a drag and drop operation and as a drop target. - static const ItemFlags DefaultNotEditable = + static const ItemFlags notEditable = ItemIsSelectable | ItemIsDragEnabled | ItemIsDropEnabled @@ -551,12 +537,15 @@ Qt::ItemFlags WatchHandler::flags(const QModelIndex &idx) const // | ItemIsTristate | ItemIsEnabled; - static const ItemFlags DefaultEditable = - DefaultNotEditable | ItemIsEditable; + static const ItemFlags editable = notEditable | ItemIsEditable; const WatchData &data = m_displaySet.at(node); - return idx.column() == 1 && - data.isWatcher() ? DefaultEditable : DefaultNotEditable; + + if (data.isWatcher() && idx.column() == 0) + return editable; // watcher names are + if (idx.column() == 1) + return editable; // values are editable + return notEditable; } QVariant WatchHandler::headerData(int section, Qt::Orientation orientation, diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index 04bbfa6c3ff93c33e9f570471c9da75a2737f3d7..4cac4a87f9942e4331882ce59cbba550524366ae 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -132,7 +132,7 @@ public: bool changed; }; -enum { INameRole = Qt::UserRole, VisualRole, ExpandedRole }; +enum { INameRole = Qt::UserRole, ExpressionRole, VisualRole, ExpandedRole }; class WatchHandler : public QAbstractItemModel @@ -146,7 +146,6 @@ public: // // QAbstractItemModel // - bool setData(const QModelIndex &index, const QVariant &value, int role); QVariant data(const QModelIndex &index, int role) const; QModelIndex index(int, int, const QModelIndex &idx) const; QModelIndex parent(const QModelIndex &idx) const; diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index e06becfa5d813ea224d0bf71ddd4e637728b4e4b..ceef4bc1f8ab271e47961200203de0c34786e748 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -31,12 +31,15 @@ #include "debuggeractions.h" +#include <utils/qtcassert.h> + #include <QtCore/QDebug> #include <QtCore/QTimer> #include <QtGui/QAction> #include <QtGui/QContextMenuEvent> #include <QtGui/QHeaderView> +#include <QtGui/QItemDelegate> #include <QtGui/QLineEdit> #include <QtGui/QMenu> #include <QtGui/QResizeEvent> @@ -44,7 +47,60 @@ using namespace Debugger::Internal; -enum { INameRole = Qt::UserRole, VisualRole, ExpandedRole }; + +///////////////////////////////////////////////////////////////////// +// +// WatchDelegate +// +///////////////////////////////////////////////////////////////////// + +enum { INameRole = Qt::UserRole, ExpressionRole, VisualRole, ExpandedRole }; + +class WatchDelegate : public QItemDelegate +{ +public: + WatchDelegate(QObject *parent) : QItemDelegate(parent) {} + + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, + const QModelIndex &) const + { + return new QLineEdit(parent); + } + + void setEditorData(QWidget *editor, const QModelIndex &index) const + { + QLineEdit *lineEdit = qobject_cast<QLineEdit *>(editor); + QTC_ASSERT(lineEdit, return); + if (index.column() == 1) + lineEdit->setText(index.model()->data(index, Qt::DisplayRole).toString()); + else + lineEdit->setText(index.model()->data(index, ExpressionRole).toString()); + } + + void setModelData(QWidget *editor, QAbstractItemModel *, + const QModelIndex &index) const + { + QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor); + QTC_ASSERT(lineEdit, return); + QString value = lineEdit->text(); + QString exp = index.model()->data(index, ExpressionRole).toString(); + if (index.column() == 1) { + // the value column + theDebuggerAction(AssignValue)->trigger(exp + '=' + value); + } else if (index.column() == 0) { + // the watcher name column + theDebuggerAction(RemoveWatchExpression)->trigger(exp); + theDebuggerAction(WatchExpression)->trigger(lineEdit->text()); + } + } + + void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, + const QModelIndex &) const + { + editor->setGeometry(option.rect); + } +}; + ///////////////////////////////////////////////////////////////////// // @@ -53,16 +109,14 @@ enum { INameRole = Qt::UserRole, VisualRole, ExpandedRole }; ///////////////////////////////////////////////////////////////////// WatchWindow::WatchWindow(Type type, QWidget *parent) - : QTreeView(parent) - , m_alwaysResizeColumnsToContents(true), m_type(type) + : QTreeView(parent), m_alwaysResizeColumnsToContents(true), m_type(type) { setWindowTitle(tr("Locals and Watchers")); setAlternatingRowColors(true); setIndentation(indentation() * 9/10); setUniformRowHeights(true); + setItemDelegate(new WatchDelegate(this)); - connect(itemDelegate(), SIGNAL(commitData(QWidget *)), - this, SLOT(handleChangedItem(QWidget *))); connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(expandNode(QModelIndex))); connect(this, SIGNAL(collapsed(QModelIndex)), @@ -92,7 +146,7 @@ void WatchWindow::keyPressEvent(QKeyEvent *ev) QModelIndex idx = currentIndex(); QModelIndex idx1 = idx.sibling(idx.row(), 0); QString exp = model()->data(idx1).toString(); - theDebuggerSetting(RemoveWatchExpression)->setValue(exp); + theDebuggerAction(RemoveWatchExpression)->setValue(exp); } QTreeView::keyPressEvent(ev); } @@ -104,6 +158,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) QAction *act2 = new QAction("Always adjust column widths to contents", &menu); act2->setCheckable(true); act2->setChecked(m_alwaysResizeColumnsToContents); + //QAction *act3 = 0; QAction *act4 = 0; menu.addAction(act1); @@ -118,19 +173,22 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) menu.addSeparator(); int type = (m_type == LocalsType) ? WatchExpression : RemoveWatchExpression; - menu.addAction(theDebuggerSetting(type)->updatedAction(exp)); + menu.addAction(theDebuggerAction(type)->updatedAction(exp)); visual = model()->data(mi0, VisualRole).toBool(); - //act4 = theDebuggerSetting(WatchExpressionInWindow)->action(); + //act4 = theDebuggerAction(WatchExpressionInWindow)->action(); //act4->setCheckable(true); //act4->setChecked(visual); - // FIXME: menu.addAction(act4); + //menu.addAction(act4); + + //act3 = new QAction(tr("Add to watch window..."), &menu); + //menu.addAction(act3); menu.addSeparator(); - menu.addAction(theDebuggerSetting(RecheckDumpers)->action()); - menu.addAction(theDebuggerSetting(UseDumpers)->action()); + menu.addAction(theDebuggerAction(RecheckDumpers)); + menu.addAction(theDebuggerAction(UseDumpers)); menu.addSeparator(); - menu.addAction(theDebuggerSetting(SettingsDialog)->action()); + menu.addAction(theDebuggerAction(SettingsDialog)); QAction *act = menu.exec(ev->globalPos()); @@ -140,6 +198,8 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents); else if (act == act4) model()->setData(mi0, !visual, VisualRole); + else if (act == act4) + model()->setData(mi0, !visual, VisualRole); } void WatchWindow::resizeColumnsToContents() @@ -200,10 +260,3 @@ void WatchWindow::resetHelper(const QModelIndex &idx) } } -void WatchWindow::handleChangedItem(QWidget *widget) -{ - QLineEdit *lineEdit = qobject_cast<QLineEdit *>(widget); - if (lineEdit) - requestAssignValue("foo", lineEdit->text()); -} - diff --git a/src/plugins/debugger/watchwindow.h b/src/plugins/debugger/watchwindow.h index 71beffb43f047c7e88661d8f9cdb37b073cb5f7f..bf6995edb4adae1bee3eb4310b771bac9e595cc2 100644 --- a/src/plugins/debugger/watchwindow.h +++ b/src/plugins/debugger/watchwindow.h @@ -58,12 +58,10 @@ public slots: void setModel(QAbstractItemModel *model); signals: - void requestAssignValue(const QString &exp, const QString &value); void requestExpandChildren(const QModelIndex &idx); void requestCollapseChildren(const QModelIndex &idx); private slots: - void handleChangedItem(QWidget *); void expandNode(const QModelIndex &index); void collapseNode(const QModelIndex &index); diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp index 4115a49a50853b155ed20815b97609922075f05b..50191f91d12cfb52225e01126961544ca2b744a0 100644 --- a/tests/manual/gdbdebugger/simple/app.cpp +++ b/tests/manual/gdbdebugger/simple/app.cpp @@ -702,6 +702,7 @@ void testStdVector() void testQString() { + int i = 0; QString str = "Hello "; str += " big, "; str += " fat ";