aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/memorydock.cpp
blob: d0bad9c679b589ea52e2c4bb6764f97770f7e992 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "memorydock.h"

DataView::DataView(QWidget *parent) : MemoryView(parent) { }

QList<QWidget*> DataView::row_widget(std::uint32_t address, QWidget *parent) {
    QList<QWidget*> widgs;
    QLabel *l;

    l = new QLabel(QString("0x%1").arg(address, 8, 16, QChar('0')), parent);
    l->setTextInteractionFlags(Qt::TextSelectableByMouse);
    widgs.append(l);

    l = new QLabel(parent);
    l->setTextInteractionFlags(Qt::TextSelectableByMouse);
    if (memory != nullptr) {
        l->setText(QString("0x%1").arg(memory->read_word(address), 8, 16, QChar('0')));
    }
    else
        l->setText("        "); // Just fill it in with some plain text so we don't have just addresses there
    widgs.append(l);

    return widgs;
}

MemoryDock::MemoryDock(QWidget *parent) : QDockWidget(parent) {
    view = new DataView(this);
    setWidget(view);

    setObjectName("Memory");
    setWindowTitle("Memory");
}

void MemoryDock::setup(machine::QtMipsMachine *machine) {
    view->setup(machine);
}