From bcdd7c87b1eda7dc6b294cfa0796ce7e36f12b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Mon, 8 Jan 2018 21:42:10 +0100 Subject: Add skeleton for memory view --- qtmips_gui/memorydock.cpp | 5 +++-- qtmips_gui/memorydock.h | 3 ++- qtmips_gui/memoryview.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++++ qtmips_gui/memoryview.h | 36 +++++++++++++++++++++++++++++++++++ qtmips_gui/programdock.cpp | 13 +++---------- qtmips_gui/programdock.h | 3 ++- qtmips_gui/qtmips_gui.pro | 2 ++ 7 files changed, 95 insertions(+), 14 deletions(-) create mode 100644 qtmips_gui/memoryview.cpp create mode 100644 qtmips_gui/memoryview.h diff --git a/qtmips_gui/memorydock.cpp b/qtmips_gui/memorydock.cpp index 0ccca3f..8998b32 100644 --- a/qtmips_gui/memorydock.cpp +++ b/qtmips_gui/memorydock.cpp @@ -1,14 +1,15 @@ #include "memorydock.h" MemoryDock::MemoryDock(QWidget *parent) : QDockWidget(parent) { - // TODO setup memory view + memory_view = new MemoryView(this); + setWidget(memory_view); setObjectName("Memory"); setWindowTitle("Memory"); } MemoryDock::~MemoryDock() { - + delete memory_view; } void MemoryDock::setup(machine::QtMipsMachine *machine) { diff --git a/qtmips_gui/memorydock.h b/qtmips_gui/memorydock.h index bec8a62..533451e 100644 --- a/qtmips_gui/memorydock.h +++ b/qtmips_gui/memorydock.h @@ -3,6 +3,7 @@ #include #include "qtmipsmachine.h" +#include "memoryview.h" class MemoryDock : public QDockWidget { Q_OBJECT @@ -13,7 +14,7 @@ public: void setup(machine::QtMipsMachine *machine); private: - // TODO memory view + MemoryView *memory_view; }; #endif // MEMORYDOCK_H diff --git a/qtmips_gui/memoryview.cpp b/qtmips_gui/memoryview.cpp new file mode 100644 index 0000000..bd5d6d8 --- /dev/null +++ b/qtmips_gui/memoryview.cpp @@ -0,0 +1,47 @@ +#include "memoryview.h" + +MemoryView::MemoryView(QWidget *parent) : QWidget(parent) { + layout = new QVBoxLayout(this); + + frame = new QFrame(this); + frame->setFrameShadow(QFrame::Sunken); + frame->setFrameShape(QFrame::StyledPanel); + frame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + // TODO + layout->addWidget(frame); + + go_edit = new QLineEdit(this); + go_edit->setText("0x00000000"); + go_edit->setInputMask("\\0\\xHHHHHHHH"); + layout->addWidget(go_edit); + connect(go_edit, SIGNAL(editingFinished()), this, SLOT(go_edit_finish())); + +} + +MemoryView::~MemoryView() { + delete go_edit; + delete frame; + delete layout; +} + +void MemoryView::set_center(std::uint32_t address) { + center_addr = address; + // TODO update view +} + +std::uint32_t MemoryView::center() { + return center_addr; +} + +void MemoryView::resizeEvent(QResizeEvent *event) { + QWidget::resizeEvent(event); + // TODO +} + +void MemoryView::wheelEvent(QWheelEvent *event) { + // TODO +} + +void MemoryView::go_edit_finish() { + // TODO +} diff --git a/qtmips_gui/memoryview.h b/qtmips_gui/memoryview.h new file mode 100644 index 0000000..e1049e8 --- /dev/null +++ b/qtmips_gui/memoryview.h @@ -0,0 +1,36 @@ +#ifndef MEMORYVIEW_H +#define MEMORYVIEW_H + +#include +#include +#include +#include +#include + +class MemoryView : public QWidget { +public: + MemoryView(QWidget *parent = nullptr); + ~MemoryView(); + + void set_center(std::uint32_t address); + std::uint32_t center(); + +protected: + //virtual QWidget *row_widget(std::uint32_t address) = 0; + + void resizeEvent(QResizeEvent *event); + void wheelEvent(QWheelEvent *event); + + QVBoxLayout *layout; + +private slots: + void go_edit_finish(); + +private: + std::uint32_t center_addr; + + QFrame *frame; + QLineEdit *go_edit; +}; + +#endif // MEMORYVIEW_H diff --git a/qtmips_gui/programdock.cpp b/qtmips_gui/programdock.cpp index 8553494..c885083 100644 --- a/qtmips_gui/programdock.cpp +++ b/qtmips_gui/programdock.cpp @@ -6,16 +6,8 @@ ProgramDock::ProgramDock(QWidget *parent) : QDockWidget(parent) { widg_layout = new QBoxLayout(QBoxLayout::TopToBottom, widg); widg_layout->setSizeConstraint(QLayout::SetMinAndMaxSize); - // TODO memory view - - /* - ctlline = new QLineEdit(widg); - ctlline->setText("0x00000000"); - ctlline->setInputMask("\\0\\xHHHHHHHH"); - ctlline->hide(); - widg_layout->addWidget(ctlline); - connect(ctlline, SIGNAL(returnPressed()), this, SLOT(ctlline_returnPress())); - */ + memory_view = new MemoryView(widg); + widg_layout->addWidget(memory_view); ctlbox_single = new QComboBox(widg); ctlbox_single->addItems({ @@ -47,6 +39,7 @@ ProgramDock::ProgramDock(QWidget *parent) : QDockWidget(parent) { } ProgramDock::~ProgramDock() { + delete memory_view; delete ctlbox_single; delete ctlbox_pipelined; delete widg_layout; diff --git a/qtmips_gui/programdock.h b/qtmips_gui/programdock.h index 033cf54..4605a7b 100644 --- a/qtmips_gui/programdock.h +++ b/qtmips_gui/programdock.h @@ -7,6 +7,7 @@ #include #include #include "qtmipsmachine.h" +#include "memoryview.h" class ProgramDock : public QDockWidget { Q_OBJECT @@ -24,7 +25,7 @@ private: QWidget *widg; QBoxLayout *widg_layout; - //QLineEdit *ctlline; + MemoryView *memory_view; QComboBox *ctlbox_single; QComboBox *ctlbox_pipelined; }; diff --git a/qtmips_gui/qtmips_gui.pro b/qtmips_gui/qtmips_gui.pro index 74a5f05..76c5e0f 100644 --- a/qtmips_gui/qtmips_gui.pro +++ b/qtmips_gui/qtmips_gui.pro @@ -18,6 +18,7 @@ SOURCES += \ newdialog.cpp \ coreview.cpp \ registersdock.cpp \ + memoryview.cpp \ cachestatistics.cpp \ cachecontent.cpp \ coreview/programcounter.cpp \ @@ -34,6 +35,7 @@ HEADERS += \ newdialog.h \ coreview.h \ registersdock.h \ + memoryview.h \ cachestatistics.h \ cachecontent.h \ coreview/programcounter.h \ -- cgit v1.2.3