Show values as floats in watch

This commit is contained in:
Pokechu22 2019-06-28 14:04:23 -07:00
parent 58c78a495d
commit ae0843f53d
2 changed files with 19 additions and 17 deletions

View File

@ -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,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);

View File

@ -50,4 +50,6 @@ private:
QTableWidget* m_table;
bool m_updating = false;
static constexpr size_t NUM_COLUMNS = 6;
};