Remove old MemoryModel and modify related code
MODIFY
src/gotocombobox.cpp
src/gotocombobox.cpp
@@ -15,12 +15,10 @@ GoToComboBox::GoToComboBox(QWidget* parent) : QComboBox(parent) {
addItem("Data", DATASTART);
addItem("Stack", STACKSTART);
- // connect to a "signal filter"
connect(this, QOverload<int>::of(&GoToComboBox::activated), this, &GoToComboBox::signalFilter);
}
void GoToComboBox::signalFilter(int index) {
- // Get modifier keys
switch (index) {
case 0:
return; // "select" has been clicked
@@ -44,11 +42,3 @@ void GoToComboBox::signalFilter(int index) {
setCurrentIndex(0);
blockSignals(false);
}
-
-ComboboxDelegate::ComboboxDelegate(QWidget* parent) : QItemDelegate(parent) {}
-
-void ComboboxDelegate::mousePressEvent(QMouseEvent* event) {
- auto modifier = event->modifiers();
- if (modifier == Qt::ShiftModifier) {
- }
-}

MODIFY
src/gotocombobox.h
src/gotocombobox.h
#define GOTOCOMBOBOX_H
#include <QComboBox>
-#include <QItemDelegate>
-
-class ComboboxDelegate : public QItemDelegate {
- Q_OBJECT
-public:
- explicit ComboboxDelegate(QWidget* parent = nullptr);
-
- void mousePressEvent(QMouseEvent* event);
-};
class GoToComboBox : public QComboBox {
Q_OBJECT
@@ -25,8 +16,6 @@ public slots:
private:
void signalFilter(int index);
-
- // ComboboxDelegate m_delegate;
};
#endif // GOTOCOMBOBOX_H

MODIFY
src/mainwindow.cpp
src/mainwindow.cpp
@@ -58,9 +58,6 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), m_ui(new Ui::Main
connect(m_stackedTabs, &QStackedWidget::currentChanged, this, &MainWindow::tabChanged);
tabChanged();
- // Setup tab pointers
- m_memoryTab->initMemoryTab();
-
setupMenus();
// setup and connect widgets

DELETE
src/memorydisplaydelegate.cpp
-#include "memorydisplaydelegate.h"
-#include "binutils.h"
-
-MemoryDisplayDelegate::MemoryDisplayDelegate(QWidget* parent) : QStyledItemDelegate(parent) {}
-
-QString MemoryDisplayDelegate::displayText(const QVariant& value, const QLocale& /*locale*/) const {
- // check for invalid memory - hacky solution. Check for values that can
- // be converted to a qstring larger than any valid value could be
- QString ret = qvariant_cast<QString>(value);
- if (ret.size() > 4) {
- return "---";
- }
-
- QString retVal;
- switch (m_displayType) {
- case displayTypeN::Hex:
- retVal.setNum(value.toUInt(), 16);
- break;
- case displayTypeN::Unsigned:
- retVal.setNum(value.toUInt());
- break;
- case displayTypeN::Decimal:
- retVal.setNum(signextend<int, 8>(value.toInt()));
- break;
- case displayTypeN::ASCII:
- retVal = QChar(value.toInt());
- break;
- case displayTypeN::Binary:
- retVal.setNum(value.toUInt(), 2);
- }
- return retVal;
-}
-
-void MemoryDisplayDelegate::setDisplayType(displayTypeN type) {
- // Given a display type "type", sets validators for the input.
- m_displayType = type;
-}

DELETE
src/memorydisplaydelegate.h
-#ifndef MEMORYDISPLAYDELEGATE_H
-#define MEMORYDISPLAYDELEGATE_H
-
-#include <QStyledItemDelegate>
-
-#include "defines.h"
-
-class MemoryDisplayDelegate : public QStyledItemDelegate {
-public:
- MemoryDisplayDelegate(QWidget* parent = nullptr);
-
- QString displayText(const QVariant& value, const QLocale& locale) const override;
-
-public slots:
- void setDisplayType(displayTypeN type);
-
-private:
- displayTypeN m_displayType = displayTypeN::Hex;
-};
-
-#endif // MEMORYDISPLAYDELEGATE_H

MODIFY
src/memorymodel.cpp
src/memorymodel.cpp
#include "memorymodel.h"
-NewMemoryModel::NewMemoryModel(ProcessorHandler& handler, QObject* parent)
+#include <QBrush>
+#include <QFont>
+
+MemoryModel::MemoryModel(ProcessorHandler& handler, QObject* parent)
: QAbstractTableModel(parent), m_handler(handler) {}
-int NewMemoryModel::columnCount(const QModelIndex&) const {
+int MemoryModel::columnCount(const QModelIndex&) const {
return 1 /* address column */ + m_handler.getProcessor()->implementsISA().bytes() /* byte columns */;
}
-int NewMemoryModel::rowCount(const QModelIndex&) const {
+int MemoryModel::rowCount(const QModelIndex&) const {
return m_rowsVisible;
}
-void NewMemoryModel::processorWasClocked() {
+void MemoryModel::processorWasClocked() {
// Reload model
beginResetModel();
endResetModel();
}
-void NewMemoryModel::offsetCentralAddress(int rowOffset) {
+void MemoryModel::setCentralAddress(uint32_t address) {
+ address = address - (address % m_handler.getProcessor()->implementsISA().bytes());
+ m_centralAddress = address;
+ processorWasClocked();
+}
+
+void MemoryModel::offsetCentralAddress(int rowOffset) {
const int byteOffset = rowOffset * m_handler.getProcessor()->implementsISA().bytes();
const long long newCenterAddress = static_cast<long long>(m_centralAddress) + byteOffset;
m_centralAddress = newCenterAddress < 0 ? m_centralAddress : newCenterAddress;
processorWasClocked();
}
-QVariant NewMemoryModel::headerData(int section, Qt::Orientation orientation, int role) const {
+QVariant MemoryModel::headerData(int section, Qt::Orientation orientation, int role) const {
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
if (section == Column::Address) {
return "Address";
@@ -35,12 +44,12 @@ QVariant NewMemoryModel::headerData(int section, Qt::Orientation orientation, in
return QVariant();
}
-void NewMemoryModel::setRowsVisible(unsigned rows) {
+void MemoryModel::setRowsVisible(unsigned rows) {
m_rowsVisible = rows;
processorWasClocked();
}
-QVariant NewMemoryModel::data(const QModelIndex& index, int role) const {
+QVariant MemoryModel::data(const QModelIndex& index, int role) const {
if (!index.isValid()) {
return QVariant();
}
@@ -56,6 +65,8 @@ QVariant NewMemoryModel::data(const QModelIndex& index, int role) const {
if (index.column() == Column::Address) {
if (role == Qt::DisplayRole) {
return addrData(alignedAddress);
+ } else if (role == Qt::ForegroundRole && alignedAddress < 0) {
+ return fgColorData(alignedAddress, 0);
}
} else {
switch (role) {
@@ -73,19 +84,19 @@ QVariant NewMemoryModel::data(const QModelIndex& index, int role) const {
return QVariant();
}
-void NewMemoryModel::setRadix(Radix r) {
+void MemoryModel::setRadix(Radix r) {
m_radix = r;
processorWasClocked();
}
-QVariant NewMemoryModel::addrData(long long address) const {
+QVariant MemoryModel::addrData(long long address) const {
if (address < 0) {
return "-";
}
return encodeRadixValue(address, Radix::Hex);
}
-QVariant NewMemoryModel::fgColorData(long long address, unsigned byteOffset) const {
+QVariant MemoryModel::fgColorData(long long address, unsigned byteOffset) const {
if (address < 0 || !m_handler.getProcessor()->getMemory().contains(address + byteOffset)) {
return QBrush(Qt::lightGray);
} else {
@@ -93,7 +104,7 @@ QVariant NewMemoryModel::fgColorData(long long address, unsigned byteOffset) con
}
}
-QVariant NewMemoryModel::byteData(long long address, unsigned byteOffset) const {
+QVariant MemoryModel::byteData(long long address, unsigned byteOffset) const {
if (address < 0) {
return "-";
} else if (!m_handler.getProcessor()->getMemory().contains(address + byteOffset)) {
@@ -107,90 +118,6 @@ QVariant NewMemoryModel::byteData(long long address, unsigned byteOffset) const
}
}
-Qt::ItemFlags NewMemoryModel::flags(const QModelIndex& index) const {
+Qt::ItemFlags MemoryModel::flags(const QModelIndex& index) const {
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
-
-MemoryModel::MemoryModel(MainMemory* memoryPtr, QObject* parent) : QStandardItemModel(parent) {
- m_memoryPtr = memoryPtr;
-
- updateModel();
-
- // Set headers
- setHeaderData(0, Qt::Horizontal, "Address");
- setHeaderData(1, Qt::Horizontal, "+0");
- setHeaderData(2, Qt::Horizontal, "+1");
- setHeaderData(3, Qt::Horizontal, "+2");
- setHeaderData(4, Qt::Horizontal, "+3");
-}
-
-void MemoryModel::setInvalidAddresLine(int row) {
- for (int i = 0; i < 5; i++) {
- auto invalidItem = new QStandardItem();
- invalidItem->setData("INVALID", Qt::DisplayRole);
- invalidItem->setTextAlignment(Qt::AlignCenter);
- setItem(row, i, invalidItem);
- };
-}
-
-void MemoryModel::offsetCentralAddress(int byteOffset) {
- // Changes the central address of the model by byteOffset, and updates the
- // model
- if (byteOffset % 4 == 0 && (m_centralAddress + byteOffset >= 0) && (m_centralAddress + byteOffset <= 0xffffffff)) {
- m_centralAddress += byteOffset;
- updateModel();
- }
-}
-
-void MemoryModel::updateModel() {
- for (int i = 0; i < m_addressRadius * 2 + 1; i++) {
- auto lineAddress = m_centralAddress + (m_addressRadius * 4) - i * 4;
- if (lineAddress < 0 || lineAddress > 0xffffffff) {
- // Memory is not available on negative addresses, set invalid data
- setInvalidAddresLine(i);
- } else {
- auto iter = m_memoryPtr->find(lineAddress);
- if (iter != m_memoryPtr->end()) {
- auto addr = new QStandardItem();
- addr->setData(QString("0x%1").arg(QString().setNum(iter->first, 16).rightJustified(8, '0')),
- Qt::DisplayRole);
- addr->setTextAlignment(Qt::AlignCenter);
- auto b1 = new QStandardItem();
- b1->setData(iter->second, Qt::DisplayRole);
- b1->setTextAlignment(Qt::AlignCenter);
- setItem(i, 0, addr);
- setItem(i, 1, b1);
- } else {
- // No address in memory - create "fake" address in model
- auto addr = new QStandardItem();
- addr->setData(QString("0x%1").arg(QString().setNum(lineAddress, 16).rightJustified(8, '0')),
- Qt::DisplayRole);
- addr->setTextAlignment(Qt::AlignCenter);
- auto b1 = new QStandardItem();
- b1->setData(0, Qt::DisplayRole);
- b1->setTextAlignment(Qt::AlignCenter);
- setItem(i, 0, addr);
- setItem(i, 1, b1);
- }
- for (int j = 1; j < 4; j++) {
- // Locate the remaining 3 bytes in the word
- auto byte = new QStandardItem();
- if ((iter = m_memoryPtr->find(lineAddress + j)) != m_memoryPtr->end()) {
- byte->setData(iter->second, Qt::DisplayRole);
- byte->setTextAlignment(Qt::AlignCenter);
- setItem(i, j + 1, byte);
- } else {
- // Memory is not initialized, set model data value to 0
- byte->setData(0, Qt::DisplayRole);
- byte->setTextAlignment(Qt::AlignCenter);
- setItem(i, j + 1, byte);
- }
- }
- }
- }
-}
-
-void MemoryModel::jumpToAddress(uint32_t address) {
- m_centralAddress = address;
- updateModel();
-}

MODIFY
src/memorymodel.h
src/memorymodel.h
-#ifndef MEMORYMODEL_H
-#define MEMORYMODEL_H
-
-#include "mainmemory.h"
+#pragma once
#include <QAbstractTableModel>
-#include <QStandardItemModel>
-
-#include <unordered_map>
#include "processorhandler.h"
#include "radix.h"
-class NewMemoryModel : public QAbstractTableModel {
+class MemoryModel : public QAbstractTableModel {
Q_OBJECT
public:
enum Column { Address = 0 };
- NewMemoryModel(ProcessorHandler& handler, QObject* parent = nullptr);
+ MemoryModel(ProcessorHandler& handler, QObject* parent = nullptr);
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
@@ -32,6 +26,7 @@ public slots:
void processorWasClocked();
void setRowsVisible(unsigned rows);
void offsetCentralAddress(int rowOffset);
+ void setCentralAddress(uint32_t address);
private:
QVariant addrData(long long address) const;
@@ -39,38 +34,8 @@ private:
QVariant fgColorData(long long address, unsigned byteOffset) const;
ProcessorHandler& m_handler;
- Radix m_radix = Radix::Unsigned;
+ Radix m_radix = Radix::Hex;
long long m_centralAddress = 4; // Address at the center of the model
unsigned m_rowsVisible = 0; // Number of rows currently visible in the view associated with the model
};
-
-class MemoryModel : public QStandardItemModel {
- Q_OBJECT
-
-public:
- explicit MemoryModel(MainMemory* memoryPtr, QObject* parent = nullptr);
-
- // Custom functionality
- void offsetCentralAddress(int byteOffset);
- void setAddressCount(int count);
- long long getCentralAddress() const { return m_centralAddress; }
- int getModelRows() const { return rowCount(); }
-
- void updateModel();
-public slots:
- void jumpToAddress(uint32_t address);
-
-private:
- void setInvalidAddresLine(int row);
-
- // instead of direct access to the memory, we should have a pointer to the runner, which can return requested
- // values, or null, if memory doesnt exist
- MainMemory* m_memoryPtr;
-
- long long m_centralAddress = 4; // Address at the center of the model
- int m_addressRadius = 20; // amount of addresses in each direction, from
- // centralAddress
-};
-
-#endif // MEMORYMODEL_H

MODIFY
src/memorytab.cpp
src/memorytab.cpp
#include "memorytab.h"
#include "ui_memorytab.h"
-#include <QInputDialog>
#include <QToolBar>
-#include <QWheelEvent>
-
-#include <algorithm>
#include "pipeline.h"
@@ -13,103 +9,20 @@ MemoryTab::MemoryTab(ProcessorHandler& handler, QToolBar* toolbar, QWidget* pare
: RipesTab(toolbar, parent), m_handler(handler), m_ui(new Ui::MemoryTab) {
m_ui->setupUi(this);
- // Add display types to display comboboxes
- for (const auto& type : displayTypes.keys()) {
- m_ui->memorydisplaytype->insertItem(0, type, displayTypes[type]);
- }
-
m_ui->memoryViewerWidget->setHandler(&m_handler);
m_ui->memoryViewerWidget->updateModel();
m_ui->memoryViewerWidget->updateView();
- m_ui->memorydisplaytype->setCurrentIndex(displayTypeN::Hex);
-}
-
-void MemoryTab::initMemoryTab() {
- m_memoryPtr = Pipeline::getPipeline()->getRuntimeMemoryPtr();
- m_regPtr = Pipeline::getPipeline()->getRegPtr();
- initializeMemoryView();
-
m_ui->rwjumpwidget->init();
- connect(m_ui->rwjumpwidget, &RWJumpWidget::jumpToAdress, this, &MemoryTab::jumpToAdress);
-}
-
-void MemoryTab::saveAddress() {
- // Saves the current centerAddress of the model to be available as a jump-to
- // address in the view
-
- QInputDialog dialog;
- dialog.setWindowIcon(QIcon(":/icons/logo.svg"));
- dialog.setLabelText(
- QString("Please enter a label for address: %1")
- .arg(QString("0x%1").arg(QString().setNum(m_model->getCentralAddress(), 16).rightJustified(8, '0'))));
- if (dialog.exec() == QDialog::Accepted) {
- m_ui->gotoCombobox->addItem(dialog.textValue(), m_model->getCentralAddress());
- }
-}
-
-void MemoryTab::initializeMemoryView() {
- m_model = new MemoryModel(m_memoryPtr);
- m_delegate = new MemoryDisplayDelegate();
- m_ui->memoryView->setModel(m_model);
- m_ui->memoryView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
- m_ui->memoryView->verticalHeader()->hide();
-
- // Only set delegate on byte columns
- m_ui->memoryView->setItemDelegateForColumn(1, m_delegate);
- m_ui->memoryView->setItemDelegateForColumn(2, m_delegate);
- m_ui->memoryView->setItemDelegateForColumn(3, m_delegate);
- m_ui->memoryView->setItemDelegateForColumn(4, m_delegate);
-
- // Memory display type
- connect(m_ui->memorydisplaytype, &QComboBox::currentTextChanged, m_delegate, [=] {
- m_delegate->setDisplayType(qvariant_cast<displayTypeN>(m_ui->memorydisplaytype->currentData()));
- m_ui->memoryView->viewport()->repaint();
- });
- m_delegate->setDisplayType(qvariant_cast<displayTypeN>(m_ui->memorydisplaytype->currentData()));
-
- // connect up/down buttons to adjust the central address of the model
- connect(m_ui->memoryUp, &QPushButton::clicked, [=] {
- m_model->offsetCentralAddress(4);
- m_ui->memoryView->viewport()->repaint();
- });
- connect(m_ui->memoryDown, &QPushButton::clicked, [=] {
- m_model->offsetCentralAddress(-4);
- m_ui->memoryView->viewport()->repaint();
- });
-
- // Connect scroll events directly to the model
- connect(m_ui->memoryView, &MemoryView::scrolled, [=](bool dir) {
- if (dir) {
- m_model->offsetCentralAddress(4);
- } else {
- m_model->offsetCentralAddress(-4);
- };
- });
-
- // Disable editing of memory - this is not implemented in the delegate
- m_ui->memoryView->setEditTriggers(QAbstractItemView::NoEditTriggers);
-
- // Connect goto combobox
-
- connect(m_ui->gotoCombobox, &GoToComboBox::jumpToAddress, m_model, &MemoryModel::jumpToAddress);
-
- // Connect save address button
- connect(m_ui->save, &QPushButton::clicked, this, &MemoryTab::saveAddress);
-
- connect(m_model, &MemoryModel::dataChanged, m_ui->memoryView, &MemoryView::setVisibleRows);
+ connect(m_ui->rwjumpwidget, &RWJumpWidget::jumpToAdress, m_ui->memoryViewerWidget,
+ &MemoryViewerWidget::setCentralAddress);
}
void MemoryTab::update() {
- m_model->updateModel();
m_ui->rwjumpwidget->updateModel();
m_ui->memoryViewerWidget->updateView();
}
-void MemoryTab::jumpToAdress(uint32_t address) {
- m_model->jumpToAddress(address);
-}
-
MemoryTab::~MemoryTab() {
delete m_ui;
}

MODIFY
src/memorytab.h
src/memorytab.h
#include <unordered_map>
-#include "mainmemory.h"
-#include "memorydisplaydelegate.h"
#include "memorymodel.h"
#include "processorhandler.h"
#include "ripestab.h"
@@ -17,35 +15,18 @@ namespace Ui {
class MemoryTab;
}
-class RegisterWidget;
-
class MemoryTab : public RipesTab {
Q_OBJECT
public:
MemoryTab(ProcessorHandler& handler, QToolBar* toolbar, QWidget* parent = nullptr);
~MemoryTab() override;
- void initMemoryTab();
public slots:
- void saveAddress();
-
void update();
- void jumpToAdress(uint32_t address);
private:
- void initializeMemoryView();
- void initializeRegisterView();
-
Ui::MemoryTab* m_ui;
- MemoryModel* m_model;
- MemoryDisplayDelegate* m_delegate;
-
- MainMemory* m_memoryPtr;
- std::vector<uint32_t>* m_regPtr;
-
- std::vector<RegisterWidget*> m_regWidgetPtrs;
-
ProcessorHandler& m_handler;
};

MODIFY
src/memorytab.ui
src/memorytab.ui
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
- <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0">
+ <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
</property>
</widget>
</item>
- <item>
- <widget class="QScrollArea" name="scrollArea_2">
- <property name="widgetResizable">
- <bool>true</bool>
- </property>
- <widget class="QWidget" name="scrollAreaWidgetContents_2">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>606</width>
- <height>321</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout_6">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <property name="horizontalSpacing">
- <number>6</number>
- </property>
- <item row="0" column="0">
- <layout class="QVBoxLayout" name="memoryLayout">
- <item>
- <widget class="MemoryView" name="memoryView">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
- <horstretch>1</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
<item>
<widget class="MemoryViewerWidget" name="memoryViewerWidget" native="true"/>
</item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_4">
- <item>
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Display type:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="memorydisplaytype">
- <property name="enabled">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Go to:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="GoToComboBox" name="gotoCombobox"/>
- </item>
- <item>
- <widget class="QPushButton" name="memoryUp">
- <property name="text">
- <string>Up</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="memoryDown">
- <property name="text">
- <string>Down</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="save">
- <property name="text">
- <string>Save Address</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
</layout>
</widget>
</widget>
</layout>
</widget>
<customwidgets>
- <customwidget>
- <class>MemoryView</class>
- <extends>QTableView</extends>
- <header>memoryview.h</header>
- </customwidget>
<customwidget>
<class>RegisterWidget</class>
<extends>QWidget</extends>
<header>registerwidget.h</header>
<container>1</container>
</customwidget>
- <customwidget>
- <class>GoToComboBox</class>
- <extends>QComboBox</extends>
- <header>gotocombobox.h</header>
- </customwidget>
<customwidget>
<class>RWJumpWidget</class>
<extends>QWidget</extends>

MODIFY
src/memoryviewerwidget.cpp
src/memoryviewerwidget.cpp
#include <QTableView>
+#include "gotocombobox.h"
#include "memorymodel.h"
MemoryViewerWidget::MemoryViewerWidget(QWidget* parent) : QWidget(parent), m_ui(new Ui::MemoryViewerWidget) {
@@ -18,6 +19,10 @@ void MemoryViewerWidget::setHandler(ProcessorHandler* handler) {
updateModel();
}
+void MemoryViewerWidget::setCentralAddress(uint32_t address) {
+ m_memoryModel->setCentralAddress(address);
+}
+
void MemoryViewerWidget::updateView() {
m_memoryModel->processorWasClocked();
}
@@ -25,10 +30,10 @@ void MemoryViewerWidget::updateView() {
void MemoryViewerWidget::updateModel() {
auto* oldModel = m_memoryModel;
- m_memoryModel = new NewMemoryModel(*m_handler, this);
+ m_memoryModel = new MemoryModel(*m_handler, this);
m_ui->memoryView->setModel(m_memoryModel);
m_ui->radixSelector->setRadix(m_memoryModel->getRadix());
- connect(m_ui->radixSelector, &RadixSelectorWidget::radixChanged, m_memoryModel, &NewMemoryModel::setRadix);
+ connect(m_ui->radixSelector, &RadixSelectorWidget::radixChanged, m_memoryModel, &MemoryModel::setRadix);
// Connect scroll events on the view to modify the center address of the model
connect(m_ui->memoryView, &MemoryView::scrolled, [=](bool dir) {
@@ -44,8 +49,9 @@ void MemoryViewerWidget::updateModel() {
const auto rows = m_ui->memoryView->height() / m_ui->memoryView->rowHeight(0);
m_memoryModel->setRowsVisible(rows);
});
+ connect(m_ui->gotoCombobox, &GoToComboBox::jumpToAddress, m_memoryModel, &MemoryModel::setCentralAddress);
- m_ui->memoryView->horizontalHeader()->setSectionResizeMode(NewMemoryModel::Address, QHeaderView::Stretch);
+ m_ui->memoryView->horizontalHeader()->setSectionResizeMode(MemoryModel::Address, QHeaderView::Stretch);
if (oldModel) {
delete oldModel;

MODIFY
src/memoryviewerwidget.h
src/memoryviewerwidget.h
@@ -19,10 +19,11 @@ public:
void updateModel();
void setHandler(ProcessorHandler* handler);
- NewMemoryModel* m_memoryModel = nullptr;
+ MemoryModel* m_memoryModel = nullptr;
public slots:
void updateView();
+ void setCentralAddress(uint32_t address);
private:
Ui::MemoryViewerWidget* m_ui;

MODIFY
src/memoryviewerwidget.ui
src/memoryviewerwidget.ui
<item>
<widget class="RadixSelectorWidget" name="radixSelector" native="true"/>
</item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="gotoButton">
- <property name="text">
- <string>Go to address...</string>
- </property>
- </widget>
- </item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
</widget>
</item>
<item>
- <widget class="QComboBox" name="gotoCombobox"/>
+ <widget class="GoToComboBox" name="gotoCombobox"/>
</item>
</layout>
</item>
<extends>QTableView</extends>
<header>memoryview.h</header>
</customwidget>
+ <customwidget>
+ <class>GoToComboBox</class>
+ <extends>QComboBox</extends>
+ <header>gotocombobox.h</header>
+ </customwidget>
</customwidgets>
<resources/>
<connections/>

MODIFY
src/registermodel.h
src/registermodel.h
@@ -47,7 +47,7 @@ private:
QVariant tooltipData(unsigned idx) const;
ProcessorHandler& m_handler;
- Radix m_radix = Radix::Unsigned;
+ Radix m_radix = Radix::Hex;
int m_mostRecentlyModifiedReg = -1;
std::vector<uint32_t> m_regValues;

Remove old MemoryModel and modify related code