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)
{
// Label
case 0:
case COLUMN_INDEX_LABEL:
if (item->text().isEmpty())
DeleteWatch(row);
else
PowerPC::debug_interface.UpdateWatchName(row, item->text().toStdString());
break;
// Address
// Hexadecimal
// Decimal
case 1:
case 2:
case 3:
case COLUMN_INDEX_ADDRESS:
case COLUMN_INDEX_HEX:
case COLUMN_INDEX_DECIMAL:
{
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 (column == 1)
if (column == COLUMN_INDEX_ADDRESS)
PowerPC::debug_interface.UpdateWatchAddress(row, value);
else
PowerPC::HostWrite_U32(value, PowerPC::debug_interface.GetWatch(row).address);

View File

@ -62,4 +62,10 @@ private:
bool m_updating = false;
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;
};