From 164ccedf29c3861da30a0153c1463365f778d66c Mon Sep 17 00:00:00 2001 From: Torusrxxx Date: Sat, 29 Oct 2016 14:05:49 +0000 Subject: [PATCH] modify value of watch item (#1197) --- src/gui/Src/Gui/WatchView.cpp | 43 ++++++++++++++++++++++------------- src/gui/Src/Gui/WatchView.h | 1 + 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/gui/Src/Gui/WatchView.cpp b/src/gui/Src/Gui/WatchView.cpp index 73942262..2a016573 100644 --- a/src/gui/Src/Gui/WatchView.cpp +++ b/src/gui/Src/Gui/WatchView.cpp @@ -1,6 +1,7 @@ #include "Bridge.h" #include "WatchView.h" #include "CPUMultiDump.h" +#include "WordEditDialog.h" #include "MiscUtil.h" WatchView::WatchView(CPUMultiDump* parent) : StdTable(parent) @@ -138,23 +139,16 @@ void WatchView::setupContextMenu() { return DbgIsDebugging(); }); + const auto & nonEmptyFunc = [this](QMenu*) + { + return getRowCount() != 0; + }; mMenu->addAction(makeAction(tr("&Add..."), SLOT(addWatchSlot()))); - mMenu->addAction(makeAction(tr("&Delete"), SLOT(delWatchSlot())), [this](QMenu*) - { - return getRowCount() != 0; - }); - mMenu->addAction(makeAction(DIcon("labels.png"), tr("Rename"), SLOT(renameWatchSlot())), [this](QMenu*) - { - return getRowCount() != 0; - }); - mMenu->addAction(makeAction(DIcon("modify.png"), tr("&Edit..."), SLOT(editWatchSlot())), [this](QMenu*) - { - return getRowCount() != 0; - }); - MenuBuilder* watchdogBuilder = new MenuBuilder(this, [this](QMenu*) - { - return getRowCount() != 0; - }); + mMenu->addAction(makeAction(tr("&Delete"), SLOT(delWatchSlot())), nonEmptyFunc); + mMenu->addAction(makeAction(DIcon("labels.png"), tr("Rename"), SLOT(renameWatchSlot())), nonEmptyFunc); + mMenu->addAction(makeAction(DIcon("modify.png"), tr("&Edit..."), SLOT(editWatchSlot())), nonEmptyFunc); + mMenu->addAction(makeAction(DIcon("modify.png"), tr("&Modify..."), SLOT(modifyWatchSlot())), nonEmptyFunc); + MenuBuilder* watchdogBuilder = new MenuBuilder(this, nonEmptyFunc); QMenu* watchdogMenu = new QMenu(tr("Watchdog"), this); watchdogMenu->setIcon(DIcon("animal-dog.png")); watchdogBuilder->addAction(makeAction(DIcon("disable.png"), tr("Disabled"), SLOT(watchdogDisableSlot()))); @@ -223,6 +217,23 @@ void WatchView::renameWatchSlot() updateWatch(); } +void WatchView::modifyWatchSlot() +{ + BridgeList WatchList; + DbgGetWatchList(&WatchList); + auto sel = getInitialSelection(); + if(sel > WatchList.Count()) + return; + WordEditDialog modifyDialog(this); + modifyDialog.setup(tr("Modify \"%1\"").arg(QString(WatchList[sel].WatchName)), WatchList[sel].value, sizeof(duint)); + if(modifyDialog.exec() == QDialog::Accepted) + { + if(!DbgValToString(WatchList[sel].Expression, modifyDialog.getVal())) + SimpleErrorBox(this, tr("Cannot modify \"%1\"").arg(QString(WatchList[sel].WatchName)), tr("It might not possible to assign a value to \"%1\".").arg(QString(WatchList[sel].Expression))); + } + updateWatch(); +} + void WatchView::editWatchSlot() { QString expr; diff --git a/src/gui/Src/Gui/WatchView.h b/src/gui/Src/Gui/WatchView.h index 1119f46f..cdb63757 100644 --- a/src/gui/Src/Gui/WatchView.h +++ b/src/gui/Src/Gui/WatchView.h @@ -20,6 +20,7 @@ public slots: void delWatchSlot(); void renameWatchSlot(); void editWatchSlot(); + void modifyWatchSlot(); void watchdogDisableSlot(); void watchdogChangedSlot(); void watchdogUnchangedSlot();