diff options
-rw-r--r-- | qtmips_gui/mainwindow.cpp | 8 | ||||
-rw-r--r-- | qtmips_gui/memorydock.cpp | 12 | ||||
-rw-r--r-- | qtmips_gui/memorydock.h | 7 | ||||
-rw-r--r-- | qtmips_gui/memoryview.cpp | 14 | ||||
-rw-r--r-- | qtmips_gui/memoryview.h | 7 | ||||
-rw-r--r-- | qtmips_gui/programdock.cpp | 11 | ||||
-rw-r--r-- | qtmips_gui/programdock.h | 7 |
7 files changed, 47 insertions, 19 deletions
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index b3a134b..7a4a06c 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -16,9 +16,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { ndialog = new NewDialog(this, settings); registers = new RegistersDock(this); registers->hide(); - program = new ProgramDock(this); + program = new ProgramDock(this, settings); program->hide(); - memory = new MemoryDock(this); + memory = new MemoryDock(this, settings); memory->hide(); cache_program = new CacheDock(this, "Program"); cache_program->hide(); @@ -55,8 +55,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { } MainWindow::~MainWindow() { - settings->sync(); - delete settings; if (corescene != nullptr) delete corescene; if (coreview != nullptr) @@ -70,6 +68,8 @@ MainWindow::~MainWindow() { delete ui; if (machine != nullptr) delete machine; + settings->sync(); + delete settings; } void MainWindow::start() { diff --git a/qtmips_gui/memorydock.cpp b/qtmips_gui/memorydock.cpp index 92dcb20..3d885f3 100644 --- a/qtmips_gui/memorydock.cpp +++ b/qtmips_gui/memorydock.cpp @@ -1,6 +1,8 @@ #include "memorydock.h" -DataView::DataView(QWidget *parent) : MemoryView(parent) { } +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; @@ -24,8 +26,12 @@ QList<QWidget*> DataView::row_widget(std::uint32_t address, QWidget *parent) { return widgs; } -MemoryDock::MemoryDock(QWidget *parent) : QDockWidget(parent) { - view = new DataView(this); +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"); diff --git a/qtmips_gui/memorydock.h b/qtmips_gui/memorydock.h index 612f986..7ec71c8 100644 --- a/qtmips_gui/memorydock.h +++ b/qtmips_gui/memorydock.h @@ -10,19 +10,22 @@ class DataView : public MemoryView { Q_OBJECT public: - DataView(QWidget *parent); + DataView(QWidget *parent, QSettings *settings); protected: QList<QWidget*> row_widget(std::uint32_t address, QWidget *parent); + void addr0_save_change(std::uint32_t val); + private: QComboBox *cb_size; + QSettings *settings; }; class MemoryDock : public QDockWidget { Q_OBJECT public: - MemoryDock(QWidget *parent); + MemoryDock(QWidget *parent, QSettings *settings); void setup(machine::QtMipsMachine *machine); diff --git a/qtmips_gui/memoryview.cpp b/qtmips_gui/memoryview.cpp index d2f33d3..b2d0a66 100644 --- a/qtmips_gui/memoryview.cpp +++ b/qtmips_gui/memoryview.cpp @@ -9,9 +9,9 @@ #define ANGLE_SCROLL 4 /////////////////////////// -MemoryView::MemoryView(QWidget *parent) : QWidget(parent) { +MemoryView::MemoryView(QWidget *parent, std::uint32_t addr0) : QWidget(parent) { memory = nullptr; - addr_0 = 0; + addr_0 = addr0; layout = new QVBoxLayout(this); @@ -38,6 +38,7 @@ void MemoryView::set_focus(std::uint32_t address) { if (address < addr_0 || (address - addr_0)/4 > (unsigned)memf->widg->count()) { // This is outside of loaded area so just move it and reload everything addr_0 = address - 4*memf->focussed(); + addr0_save_change(addr_0); reload_content(); } else { memf->focus((address - addr_0) / 4); @@ -45,10 +46,14 @@ void MemoryView::set_focus(std::uint32_t address) { edit_load_focus(); } -std::uint32_t MemoryView::focus() { +std::uint32_t MemoryView::focus() const { return addr_0 + 4*memf->focussed(); } +std::uint32_t MemoryView::addr0() const { + return addr_0; +} + void MemoryView::edit_load_focus() { go_edit->setText(QString("0x%1").arg(focus(), 8, 16, QChar('0'))); } @@ -89,8 +94,11 @@ void MemoryView::update_content(int count, int shift) { else for (int i = 0; i > d_e; i--) memf->widg->removeRow(memf->widg->count() - 1); + addr0_save_change(addr_0); } +void MemoryView::addr0_save_change(std::uint32_t val) { /* ignore */ } + void MemoryView::go_edit_finish() { QString hex = go_edit->text(); hex.remove(0, 2); diff --git a/qtmips_gui/memoryview.h b/qtmips_gui/memoryview.h index 605adda..1aeaf10 100644 --- a/qtmips_gui/memoryview.h +++ b/qtmips_gui/memoryview.h @@ -17,12 +17,13 @@ class MemoryView : public QWidget { Q_OBJECT public: - MemoryView(QWidget *parent = nullptr); + MemoryView(QWidget *parent = nullptr, std::uint32_t addr0 = 0); virtual void setup(machine::QtMipsMachine*); void set_focus(std::uint32_t address); - std::uint32_t focus(); + std::uint32_t focus() const; + std::uint32_t addr0() const; void edit_load_focus(); // Set current focus to edit field @@ -36,6 +37,8 @@ protected: void reload_content(); // reload displayed data void update_content(int count, int shift); // update content to match given count and shift + virtual void addr0_save_change(std::uint32_t val); + private slots: void go_edit_finish(); diff --git a/qtmips_gui/programdock.cpp b/qtmips_gui/programdock.cpp index de24910..965e22e 100644 --- a/qtmips_gui/programdock.cpp +++ b/qtmips_gui/programdock.cpp @@ -1,7 +1,8 @@ #include "programdock.h" #include "qtmipsexception.h" -ProgramView::ProgramView(QWidget *parent) : MemoryView(parent) { +ProgramView::ProgramView(QWidget *parent, QSettings *settings) : MemoryView(parent, settings->value("ProgramViewAddr0", 0x8001FF80).toULongLong()) { + this->settings = settings; /* cb_single = new QComboBox(this); cb_single->addItems({ @@ -81,6 +82,10 @@ QList<QWidget*> ProgramView::row_widget(std::uint32_t address, QWidget *parent) return widgs; } +void ProgramView::addr0_save_change(std::uint32_t val) { + settings->setValue("ProgramViewAddr0", val); +} + void ProgramView::cb_single_changed(int index) { // TODO set memory view } @@ -89,8 +94,8 @@ void ProgramView::cb_pipelined_changed(int index) { // TODO set memory view } -ProgramDock::ProgramDock(QWidget *parent) : QDockWidget(parent) { - view = new ProgramView(this); +ProgramDock::ProgramDock(QWidget *parent, QSettings *settings) : QDockWidget(parent) { + view = new ProgramView(this, settings); setWidget(view); setObjectName("Program"); diff --git a/qtmips_gui/programdock.h b/qtmips_gui/programdock.h index 156c380..888e681 100644 --- a/qtmips_gui/programdock.h +++ b/qtmips_gui/programdock.h @@ -12,7 +12,7 @@ class ProgramView : public MemoryView { Q_OBJECT public: - ProgramView(QWidget *parent); + ProgramView(QWidget *parent, QSettings *settings); void setup(machine::QtMipsMachine*); @@ -21,6 +21,8 @@ public: protected: QList<QWidget*> row_widget(std::uint32_t address, QWidget *parent); + void addr0_save_change(std::uint32_t val); + private slots: void cb_single_changed(int index); void cb_pipelined_changed(int index); @@ -28,12 +30,13 @@ private slots: private: QComboBox *cb_single; QComboBox *cb_pipelined; + QSettings *settings; }; class ProgramDock : public QDockWidget { Q_OBJECT public: - ProgramDock(QWidget *parent); + ProgramDock(QWidget *parent, QSettings *settings); void setup(machine::QtMipsMachine *machine); |