Add save address functionality in memory view
MODIFY
src/mainwindow.ui
src/mainwindow.ui
</size>
</property>
<property name="currentIndex">
- <number>2</number>
+ <number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">

MODIFY
src/memorymodel.h
src/memorymodel.h
@@ -15,8 +15,9 @@ public:
// Custom functionality
void offsetCentralAddress(int byteOffset);
-
void setAddressCount(int count);
+ long long getCentralAddress() const { return m_centralAddress; }
+
public slots:
void jumpToAddress(uint32_t address);

MODIFY
src/memorytab.cpp
src/memorytab.cpp
#include "registerwidget.h"
+#include <QInputDialog>
#include <QWheelEvent>
#include <algorithm>
@@ -31,6 +32,22 @@ void MemoryTab::init() {
initializeRegisterView();
}
+void MemoryTab::saveAddress() {
+ // Saves the current centerAddress of the model to be available as a jump-to
+ // address in the view
+
+ QInputDialog dialog;
+ 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::initializeRegisterView() {
// Initialize register ABInames
QStringList ABInames = QStringList() << "zero"
@@ -130,7 +147,8 @@ void MemoryTab::initializeMemoryView() {
m_model = new MemoryModel(m_memoryPtr);
m_delegate = new MemoryDisplayDelegate();
m_ui->memoryView->setModel(m_model);
- m_ui->memoryView->horizontalHeader()->setStretchLastSection(true);
+ m_ui->memoryView->horizontalHeader()->setSectionResizeMode(
+ 0, QHeaderView::Stretch);
m_ui->memoryView->verticalHeader()->hide();
// Only set delegate on byte columns
@@ -179,6 +197,9 @@ void MemoryTab::initializeMemoryView() {
m_ui->gotoCombobox->setCurrentIndex(0);
m_ui->gotoCombobox->blockSignals(false);
});
+
+ // Connect save address button
+ connect(m_ui->save, &QPushButton::clicked, this, &MemoryTab::saveAddress);
}
MemoryTab::~MemoryTab() { delete m_ui; }

MODIFY
src/memorytab.h
src/memorytab.h
@@ -29,6 +29,7 @@ public:
public slots:
void updateRegisterWidget(int n);
+ void saveAddress();
private:
void initializeMemoryView();

MODIFY
src/memorytab.ui
src/memorytab.ui
<rect>
<x>0</x>
<y>0</y>
- <width>785</width>
+ <width>846</width>
<height>415</height>
</rect>
</property>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
+ <property name="minimumSize">
+ <size>
+ <width>300</width>
+ <height>0</height>
+ </size>
+ </property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<rect>
<x>0</x>
<y>0</y>
- <width>240</width>
+ <width>298</width>
<height>335</height>
</rect>
</property>
<rect>
<x>0</x>
<y>0</y>
- <width>511</width>
+ <width>514</width>
<height>335</height>
</rect>
</property>
<item>
<widget class="QPushButton" name="memoryDown">
<property name="text">
- <string>down</string>
+ <string>Down</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="save">
+ <property name="text">
+ <string>Save Address</string>
</property>
</widget>
</item>

Add save address functionality in memory view