From d35a19f9d3722468dc2bb4ec7449a0cee07b3b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Tue, 23 Jan 2018 15:36:48 +0100 Subject: Better layout registers This does dynamic layout of registers. This implemntation is just terrible. It works but it's almost unreadable. It's just too much code for such a small feature. But I can't be bothered to refactor it on top of hacking it. --- qtmips_gui/registersdock.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'qtmips_gui/registersdock.cpp') diff --git a/qtmips_gui/registersdock.cpp b/qtmips_gui/registersdock.cpp index 809b692..d9d3f2f 100644 --- a/qtmips_gui/registersdock.cpp +++ b/qtmips_gui/registersdock.cpp @@ -37,23 +37,23 @@ static const QString labels[] = { RegistersDock::RegistersDock(QWidget *parent) : QDockWidget(parent) { scrollarea = new QScrollArea(this); - widg = new QWidget(scrollarea); - layout = new QFormLayout(widg); - layout->setSizeConstraint(QLayout::SetMinAndMaxSize); + scrollarea->setWidgetResizable(true); + widg = new StaticTable(scrollarea); #define INIT(X, LABEL) do{ \ - X = new QLabel(widg); \ + X = new QLabel("0x00000000", widg); \ + X->setFixedSize(X->sizeHint()); \ + X->setText(""); \ X->setTextInteractionFlags(Qt::TextSelectableByMouse); \ - layout->addRow(LABEL, X); \ + widg->addRow({new QLabel(LABEL, widg), X}); \ } while(false) - INIT(pc, "pc:"); for (int i = 0; i < 32; i++) - INIT(gp[i], QString("$") + QString::number(i) + QString("/") + labels[i] + QString(":")); - INIT(lo, "lo:"); - INIT(hi, "hi:"); + INIT(gp[i], QString("$") + QString::number(i) + QString("/") + labels[i]); + INIT(pc, "pc"); + INIT(lo, "lo"); + INIT(hi, "hi"); #undef INIT - widg->setLayout(layout); scrollarea->setWidget(widg); setWidget(scrollarea); @@ -67,7 +67,6 @@ RegistersDock::~RegistersDock() { delete lo; for (int i = 0; i < 32; i++) delete gp[i]; - delete layout; delete widg; delete scrollarea; } -- cgit v1.2.3