From ae0843f53d48582b6e87d0f2f1a0f42822655431 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Fri, 28 Jun 2019 14:04:23 -0700 Subject: [PATCH] Show values as floats in watch --- .../Core/DolphinQt/Debugger/WatchWidget.cpp | 34 +++++++++---------- Source/Core/DolphinQt/Debugger/WatchWidget.h | 2 ++ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Source/Core/DolphinQt/Debugger/WatchWidget.cpp b/Source/Core/DolphinQt/Debugger/WatchWidget.cpp index 810c431b12..c122318f20 100644 --- a/Source/Core/DolphinQt/Debugger/WatchWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/WatchWidget.cpp @@ -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 items = {label, address, hex, + decimal, string, floatValue}; QBrush brush = QPalette().brush(QPalette::Text); @@ -158,26 +164,20 @@ 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); - - int column = 0; - - for (auto* item : {label, address, hex, decimal, string}) - { - item->setData(Qt::UserRole, i); - item->setData(Qt::UserRole + 1, column++); - } - 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); + for (int column = 0; column < NUM_COLUMNS; column++) + { + auto* item = items[column]; + item->setData(Qt::UserRole, i); + item->setData(Qt::UserRole + 1, column); + m_table->setItem(i, column, item); + } } auto* label = new QTableWidgetItem; @@ -185,7 +185,7 @@ void WatchWidget::Update() 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); diff --git a/Source/Core/DolphinQt/Debugger/WatchWidget.h b/Source/Core/DolphinQt/Debugger/WatchWidget.h index a405f60fba..dbd0b4d805 100644 --- a/Source/Core/DolphinQt/Debugger/WatchWidget.h +++ b/Source/Core/DolphinQt/Debugger/WatchWidget.h @@ -50,4 +50,6 @@ private: QTableWidget* m_table; bool m_updating = false; + + static constexpr size_t NUM_COLUMNS = 6; };