Skip to content
Permalink
Browse files

Show values as floats in watch

  • Loading branch information...
Pokechu22 committed Jun 28, 2019
1 parent 58c78a4 commit ae0843f53d48582b6e87d0f2f1a0f42822655431
Showing with 17 additions and 15 deletions.
  1. +15 −15 Source/Core/DolphinQt/Debugger/WatchWidget.cpp
  2. +2 −0 Source/Core/DolphinQt/Debugger/WatchWidget.h
@@ -82,7 +82,7 @@ void WatchWidget::CreateWidgets()
m_table = new QTableWidget;

m_table->setContentsMargins(0, 0, 0, 0);
m_table->setColumnCount(5);
m_table->setColumnCount(NUM_COLUMNS);
m_table->verticalHeader()->setHidden(true);
m_table->setContextMenuPolicy(Qt::CustomContextMenu);
m_table->setSelectionMode(QAbstractItemView::SingleSelection);
@@ -132,7 +132,9 @@ void WatchWidget::Update()
// i18n: The base 10 numeral system. Not related to non-integer numbers
tr("Decimal"),
// i18n: Data type used in computing
tr("String")});
tr("String"),
// i18n: Floating-point (non-integer) number
tr("Float")});

for (int i = 0; i < size; i++)
{
@@ -144,6 +146,10 @@ void WatchWidget::Update()
auto* hex = new QTableWidgetItem;
auto* decimal = new QTableWidgetItem;
auto* string = new QTableWidgetItem;
auto* floatValue = new QTableWidgetItem;

std::array<QTableWidgetItem*, NUM_COLUMNS> items = {label, address, hex,
decimal, string, floatValue};

QBrush brush = QPalette().brush(QPalette::Text);

@@ -158,34 +164,28 @@ void WatchWidget::Update()
QLatin1Char('0')));
decimal->setText(QString::number(PowerPC::HostRead_U32(entry.address)));
string->setText(QString::fromStdString(PowerPC::HostGetString(entry.address, 32)));
floatValue->setText(QString::number(PowerPC::HostRead_F32(entry.address)));
}
}

address->setForeground(brush);
string->setFlags(Qt::ItemIsEnabled);

int column = 0;

for (auto* item : {label, address, hex, decimal, string})
for (int column = 0; column < NUM_COLUMNS; column++)
{
auto* item = items[column];
item->setData(Qt::UserRole, i);
item->setData(Qt::UserRole + 1, column++);
item->setData(Qt::UserRole + 1, column);
m_table->setItem(i, column, item);
}

string->setFlags(Qt::ItemIsEnabled);

m_table->setItem(i, 0, label);
m_table->setItem(i, 1, address);
m_table->setItem(i, 2, hex);
m_table->setItem(i, 3, decimal);
m_table->setItem(i, 4, string);
}

auto* label = new QTableWidgetItem;
label->setData(Qt::UserRole, -1);

m_table->setItem(size, 0, label);

for (int i = 1; i < 5; i++)
for (int i = 1; i < NUM_COLUMNS; i++)
{
auto* no_edit = new QTableWidgetItem;
no_edit->setFlags(Qt::ItemIsEnabled);
@@ -50,4 +50,6 @@ class WatchWidget : public QDockWidget
QTableWidget* m_table;

bool m_updating = false;

static constexpr size_t NUM_COLUMNS = 6;
};

0 comments on commit ae0843f

Please sign in to comment.
You can’t perform that action at this time.