From 0b603814a16b8603e4f654f5c72acd7a1e3a0ff6 Mon Sep 17 00:00:00 2001 From: morsisko Date: Fri, 30 Oct 2020 23:26:35 +0100 Subject: [PATCH] GUI: Added column enum to watch view --- src/gui/Src/Gui/WatchView.cpp | 52 +++++++++++++++++------------------ src/gui/Src/Gui/WatchView.h | 11 ++++++++ 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/src/gui/Src/Gui/WatchView.cpp b/src/gui/Src/Gui/WatchView.cpp index b675dcf5..8fa1394d 100644 --- a/src/gui/Src/Gui/WatchView.cpp +++ b/src/gui/Src/Gui/WatchView.cpp @@ -37,24 +37,24 @@ void WatchView::updateWatch() setSingleSelection(WatchList.Count() - 1); for(int i = 0; i < WatchList.Count(); i++) { - setCellContent(i, 0, QString(WatchList[i].WatchName)); - setCellContent(i, 1, QString(WatchList[i].Expression)); + setCellContent(i, ColName, QString(WatchList[i].WatchName)); + setCellContent(i, ColExpr, QString(WatchList[i].Expression)); switch(WatchList[i].varType) { case WATCHVARTYPE::TYPE_UINT: - setCellContent(i, 3, "UINT"); - setCellContent(i, 2, ToPtrString(WatchList[i].value)); + setCellContent(i, ColType, "UINT"); + setCellContent(i, ColValue, ToPtrString(WatchList[i].value)); break; case WATCHVARTYPE::TYPE_INT: - setCellContent(i, 3, "INT"); - setCellContent(i, 2, QString::number((dsint)WatchList[i].value)); + setCellContent(i, ColType, "INT"); + setCellContent(i, ColValue, QString::number((dsint)WatchList[i].value)); break; case WATCHVARTYPE::TYPE_FLOAT: - setCellContent(i, 3, "FLOAT"); - setCellContent(i, 2, ToFloatString(&WatchList[i].value)); + setCellContent(i, ColType, "FLOAT"); + setCellContent(i, ColValue, ToFloatString(&WatchList[i].value)); break; case WATCHVARTYPE::TYPE_ASCII: - setCellContent(i, 3, "ASCII"); + setCellContent(i, ColType, "ASCII"); { char buffer[128]; // zero the buffer @@ -68,14 +68,14 @@ void WatchView::updateWatch() // remove CRLF text.replace(QChar('\x13'), "\\r"); text.replace(QChar('\x10'), "\\n"); - setCellContent(i, 2, text); + setCellContent(i, ColValue, text); } else - setCellContent(i, 2, tr("%1 is not readable.").arg(ToPtrString(WatchList[i].value))); + setCellContent(i, ColValue, tr("%1 is not readable.").arg(ToPtrString(WatchList[i].value))); } break; case WATCHVARTYPE::TYPE_UNICODE: - setCellContent(i, 3, "UNICODE"); + setCellContent(i, ColType, "UNICODE"); { unsigned short buffer[128]; // zero the buffer @@ -93,38 +93,38 @@ void WatchView::updateWatch() // remove CRLF text.replace(QChar('\x13'), "\\r"); text.replace(QChar('\x10'), "\\n"); - setCellContent(i, 2, text); + setCellContent(i, ColValue, text); } else - setCellContent(i, 2, tr("%1 is not readable.").arg(ToPtrString(WatchList[i].value))); + setCellContent(i, ColValue, tr("%1 is not readable.").arg(ToPtrString(WatchList[i].value))); } break; case WATCHVARTYPE::TYPE_INVALID: default: - setCellContent(i, 3, "INVALID"); - setCellContent(i, 2, ""); + setCellContent(i, ColType, "INVALID"); + setCellContent(i, ColValue, ""); break; } switch(WatchList[i].watchdogMode) { case WATCHDOGMODE::MODE_DISABLED: default: - setCellContent(i, 4, tr("Disabled")); + setCellContent(i, ColWatchdog, tr("Disabled")); break; case WATCHDOGMODE::MODE_CHANGED: - setCellContent(i, 4, tr("Changed")); + setCellContent(i, ColWatchdog, tr("Changed")); break; case WATCHDOGMODE::MODE_ISTRUE: - setCellContent(i, 4, tr("Is true")); + setCellContent(i, ColWatchdog, tr("Is true")); break; case WATCHDOGMODE::MODE_ISFALSE: - setCellContent(i, 4, tr("Is false")); + setCellContent(i, ColWatchdog, tr("Is false")); break; case WATCHDOGMODE::MODE_UNCHANGED: - setCellContent(i, 4, tr("Not changed")); + setCellContent(i, ColWatchdog, tr("Not changed")); break; } - setCellContent(i, 5, QString::number(WatchList[i].id)); + setCellContent(i, ColId, QString::number(WatchList[i].id)); } reloadData(); } @@ -178,14 +178,14 @@ void WatchView::setupContextMenu() QString WatchView::getSelectedId() { - return QChar('.') + getCellContent(getInitialSelection(), 5); + return QChar('.') + getCellContent(getInitialSelection(), ColId); } QString WatchView::paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h) { QString ret = StdTable::paintContent(painter, rowBase, rowOffset, col, x, y, w, h); const dsint row = rowBase + rowOffset; - if(row != getInitialSelection() && DbgFunctions()->WatchIsWatchdogTriggered(getCellContent(row, 5).toUInt())) + if(row != getInitialSelection() && DbgFunctions()->WatchIsWatchdogTriggered(getCellContent(row, ColId).toUInt())) { painter->fillRect(QRect(x, y, w, h), mWatchTriggeredBackgroundColor); painter->setPen(mWatchTriggeredColor); //white text @@ -222,7 +222,7 @@ void WatchView::delWatchSlot() void WatchView::renameWatchSlot() { QString name; - QString originalName = getCellContent(getInitialSelection(), 0); + QString originalName = getCellContent(getInitialSelection(), ColName); if(SimpleInputBox(this, tr("Enter the name of the watch variable"), originalName, name, originalName)) DbgCmdExecDirect(QString("SetWatchName ").append(getSelectedId() + "," + name)); updateWatch(); @@ -248,7 +248,7 @@ void WatchView::modifyWatchSlot() void WatchView::editWatchSlot() { QString expr; - QString originalExpr = getCellContent(getInitialSelection(), 1); + QString originalExpr = getCellContent(getInitialSelection(), ColExpr); if(SimpleInputBox(this, tr("Enter the expression to watch"), originalExpr, expr, tr("Example: [EAX]"))) DbgCmdExecDirect(QString("SetWatchExpression ").append(getSelectedId()).append(",").append(expr)); updateWatch(); diff --git a/src/gui/Src/Gui/WatchView.h b/src/gui/Src/Gui/WatchView.h index e4e7120b..4e54b461 100644 --- a/src/gui/Src/Gui/WatchView.h +++ b/src/gui/Src/Gui/WatchView.h @@ -40,6 +40,17 @@ protected: MenuBuilder* mMenu; QPen mWatchTriggeredColor; QBrush mWatchTriggeredBackgroundColor; + +private: + enum + { + ColName = 0, + ColExpr, + ColValue, + ColType, + ColWatchdog, + ColId + }; }; #endif // WATCHVIEW_H