summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-26 14:57:56 -0400
committerbd <bdunahu@operationnull.com>2025-04-26 14:57:56 -0400
commitae2aaecfc1b2402a55e99cf674eff7b6175b0b6d (patch)
tree651c14de4eb0467d898810bdb1e136f2e5089ded
parentb32bc409c18ceb4cd8147f11021e2c4b2746184b (diff)
Basic hex formatting on row headers for storage tables
-rw-r--r--gui/digitlabelhelper.h3
-rw-r--r--gui/gui.cc3
-rw-r--r--gui/storageview.cc15
-rw-r--r--gui/storageview.h7
4 files changed, 23 insertions, 5 deletions
diff --git a/gui/digitlabelhelper.h b/gui/digitlabelhelper.h
index 26e4637..4d45c68 100644
--- a/gui/digitlabelhelper.h
+++ b/gui/digitlabelhelper.h
@@ -36,8 +36,7 @@ class DigitLabelHelper
{
if (is_cleared)
return QString();
- return is_hex ? QString::asprintf("%X", value)
- : QString::number(value);
+ return is_hex ? QString::asprintf("%X", value) : QString::number(value);
}
};
diff --git a/gui/gui.cc b/gui/gui.cc
index 80d4a2a..2555435 100644
--- a/gui/gui.cc
+++ b/gui/gui.cc
@@ -353,7 +353,6 @@ void GUI::make_tabs(int num)
qDeleteAll(this->tab_boxes);
for (i = 0; i < num; ++i) {
- // make the name
if (i == 0) {
n = "Registers";
e = new StorageView(0, this);
@@ -371,6 +370,8 @@ void GUI::make_tabs(int num)
d = new DigitLabelDelegate(t);
connect(
+ this, &GUI::hex_toggled, e, &StorageView::set_hex_display);
+ connect(
this, &GUI::hex_toggled, d, &DigitLabelDelegate::set_hex_display);
t->setItemDelegate(d);
diff --git a/gui/storageview.cc b/gui/storageview.cc
index 43837a9..22baca0 100644
--- a/gui/storageview.cc
+++ b/gui/storageview.cc
@@ -17,6 +17,7 @@
#include "storageview.h"
#include "definitions.h"
+#include "digitlabelhelper.h"
#include <QAbstractTableModel>
#include <QVector>
@@ -59,12 +60,13 @@ QVariant StorageView::headerData(int section, Qt::Orientation o, int role) const
return QVariant();
if (o == Qt::Vertical) {
- return section * 4;
+ return DigitLabelHelper::format_value(section * 4, this->is_hex);
}
return QVariant();
}
-Qt::ItemFlags StorageView::flags(const QModelIndex &i) const {
+Qt::ItemFlags StorageView::flags(const QModelIndex &i) const
+{
(void)i;
return Qt::ItemIsEnabled;
}
@@ -75,3 +77,12 @@ void StorageView::set_data(const QVector<QVector<int>> &data)
this->d = data;
endResetModel();
}
+
+void StorageView::set_hex_display(bool hex)
+{
+ if (this->is_hex != hex) {
+ beginResetModel();
+ this->is_hex = hex;
+ endResetModel();
+ }
+}
diff --git a/gui/storageview.h b/gui/storageview.h
index 4956f23..0518d8f 100644
--- a/gui/storageview.h
+++ b/gui/storageview.h
@@ -72,12 +72,19 @@ class StorageView : public QAbstractTableModel
*/
void set_data(const QVector<QVector<int>> &data);
+ public slots:
+ void set_hex_display(bool hex);
+
private:
/**
* The number of rows in this table.
*/
int r;
/**
+ * Whether or not the headers should be displayed in hex.
+ */
+ bool is_hex = true;
+ /**
* The data this table displays.
*/
QVector<QVector<int>> d;