Implement address jump combobox
MODIFY
src/memorymodel.cpp
src/memorymodel.cpp
@@ -83,3 +83,10 @@ void MemoryModel::updateModel() {
}
}
}
+
+void MemoryModel::jumpToAddress(uint32_t address) {
+ if (address >= 0) {
+ m_centralAddress = address;
+ updateModel();
+ }
+}

MODIFY
src/memorymodel.h
src/memorymodel.h
@@ -14,11 +14,11 @@ public:
explicit MemoryModel(memory *memoryPtr, QObject *parent = nullptr);
// Custom functionality
- void setCentralAddress(uint32_t address);
- void jumpToAddress(uint32_t address);
void offsetCentralAddress(int byteOffset);
void setAddressCount(int count);
+public slots:
+ void jumpToAddress(uint32_t address);
private:
void updateModel();

MODIFY
src/memorytab.cpp
src/memorytab.cpp
@@ -15,6 +15,11 @@ MemoryTab::MemoryTab(QWidget *parent)
m_ui->registerdisplaytype->insertItem(0, type);
m_ui->memorydisplaytype->insertItem(0, type);
}
+
+ // Add goto values to goto combobox
+ m_ui->gotoCombobox->addItem("Text", 0);
+ m_ui->gotoCombobox->addItem("Stack", 0x7ffffff0);
+
m_ui->registerdisplaytype->setCurrentIndex(displayTypeN::Hex);
m_ui->memorydisplaytype->setCurrentIndex(displayTypeN::Hex);
}
@@ -148,6 +153,14 @@ void MemoryTab::initializeMemoryView() {
m_model->offsetCentralAddress(-4);
};
});
+
+ // Disable editing
+ m_ui->memoryView->setEditTriggers(QAbstractItemView::NoEditTriggers);
+
+ // Connect goto combobox
+ connect(m_ui->gotoCombobox, &QComboBox::currentTextChanged, [=] {
+ m_model->jumpToAddress(m_ui->gotoCombobox->currentData().toUInt());
+ });
}
MemoryTab::~MemoryTab() { delete m_ui; }

MODIFY
src/memorytab.ui
src/memorytab.ui
</widget>
</item>
<item>
- <widget class="QComboBox" name="comboBox_3">
- <item>
- <property name="text">
- <string>Text</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Data</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Heap</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Stack</string>
- </property>
- </item>
- </widget>
+ <widget class="QComboBox" name="gotoCombobox"/>
</item>
<item>
<widget class="QPushButton" name="memoryUp">

Implement address jump combobox