summaryrefslogtreecommitdiff
path: root/gui/digitlabeldelegate.cc
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-27 15:20:37 -0400
committerbd <bdunahu@operationnull.com>2025-04-27 15:20:37 -0400
commit64efd868deec8921eac16b181f3a2e6d29f90b99 (patch)
tree096c73c3e74a2afedabd85bd62dbb6720a365ed5 /gui/digitlabeldelegate.cc
parent7aaa516c0de444c956dff88342a57e9313a19e34 (diff)
parent5653b2a033e7a4173d2f178b5ce52384666d3d7b (diff)
Merge remote-tracking branch 'origin/master' into vector_ext
Diffstat (limited to 'gui/digitlabeldelegate.cc')
-rw-r--r--gui/digitlabeldelegate.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/gui/digitlabeldelegate.cc b/gui/digitlabeldelegate.cc
new file mode 100644
index 0000000..430946c
--- /dev/null
+++ b/gui/digitlabeldelegate.cc
@@ -0,0 +1,51 @@
+// Simulator for the RISC-V[ECTOR] mini-ISA
+// Copyright (C) 2025 Siddarth Suresh
+// Copyright (C) 2025 bdunahu
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+#include "digitlabeldelegate.h"
+#include "util.h"
+#include <QString>
+
+void DigitLabelDelegate::set_hex_display(bool hex)
+{
+ if (this->is_hex != hex) {
+ this->is_hex = hex;
+ if (auto v = qobject_cast<QAbstractItemView *>(parent()))
+ v->viewport()->update();
+ }
+}
+
+void DigitLabelDelegate::paint(
+ QPainter *painter,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
+{
+ int v;
+ QString t;
+ QStyleOptionViewItem o;
+ QStyle *s;
+
+ v = index.data(Qt::DisplayRole).toInt();
+ t = format_toggled_value(v, this->is_hex);
+
+ o = option;
+ initStyleOption(&o, index);
+ o.text = t;
+
+ const QWidget *w = option.widget;
+ s = w ? w->style() : QApplication::style();
+ s->drawControl(QStyle::CE_ItemViewItem, &o, painter, w);
+}