aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/memorydock.cpp
blob: 3d885f30fb311f1d62f9cf51db57ece132d8e55b (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
36
37
38
39
40
41
42
43
#include "memorydock.h"

DataView::DataView(QWidget *parent, QSettings *settings) : MemoryView(parent, settings->value("DataViewAddr0", 0).toULongLong()) {
    this->settings = settings;
}

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

    QFont f;
    f.setStyleHint(QFont::Monospace);

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

    l = new QLabel(parent);
    l->setTextInteractionFlags(Qt::TextSelectableByMouse);
    l->setFont(f);
    if (memory != nullptr)
        l->setText(QString("0x") + QString("%1").arg(memory->read_word(address), 8, 16, QChar('0')).toUpper());
    widgs.append(l);

    return widgs;
}

void DataView::addr0_save_change(std::uint32_t val) {
    settings->setValue("DataViewAddr0", val);
}

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

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

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