DolphinQt: cleanup WatchWidget

This commit is contained in:
iwubcode
2022-12-22 20:50:16 -06:00
parent 3081a781fd
commit 41c9d706cb
2 changed files with 14 additions and 10 deletions

View File

@ -349,26 +349,24 @@ void WatchWidget::OnItemChanged(QTableWidgetItem* item)
{ {
switch (column) switch (column)
{ {
// Label case COLUMN_INDEX_LABEL:
case 0:
if (item->text().isEmpty()) if (item->text().isEmpty())
DeleteWatch(row); DeleteWatch(row);
else else
PowerPC::debug_interface.UpdateWatchName(row, item->text().toStdString()); PowerPC::debug_interface.UpdateWatchName(row, item->text().toStdString());
break; break;
// Address case COLUMN_INDEX_ADDRESS:
// Hexadecimal case COLUMN_INDEX_HEX:
// Decimal case COLUMN_INDEX_DECIMAL:
case 1:
case 2:
case 3:
{ {
bool good; bool good;
quint32 value = item->text().toUInt(&good, column < 3 ? 16 : 10); const bool column_uses_hex_formatting =
column == COLUMN_INDEX_ADDRESS || column == COLUMN_INDEX_HEX;
quint32 value = item->text().toUInt(&good, column_uses_hex_formatting ? 16 : 10);
if (good) if (good)
{ {
if (column == 1) if (column == COLUMN_INDEX_ADDRESS)
PowerPC::debug_interface.UpdateWatchAddress(row, value); PowerPC::debug_interface.UpdateWatchAddress(row, value);
else else
PowerPC::HostWrite_U32(value, PowerPC::debug_interface.GetWatch(row).address); PowerPC::HostWrite_U32(value, PowerPC::debug_interface.GetWatch(row).address);

View File

@ -62,4 +62,10 @@ private:
bool m_updating = false; bool m_updating = false;
static constexpr int NUM_COLUMNS = 6; static constexpr int NUM_COLUMNS = 6;
static constexpr int COLUMN_INDEX_LABEL = 0;
static constexpr int COLUMN_INDEX_ADDRESS = 1;
static constexpr int COLUMN_INDEX_HEX = 2;
static constexpr int COLUMN_INDEX_DECIMAL = 3;
static constexpr int COLUMN_INDEX_STRING = 4;
static constexpr int COLUMN_INDEX_FLOAT = 5;
}; };