Qt: Memory view address jump
Jeffrey Pfau jeffrey@endrift.com
Thu, 30 Apr 2015 23:15:20 -0700
4 files changed,
37 insertions(+),
6 deletions(-)
M
src/platform/qt/MemoryModel.cpp
→
src/platform/qt/MemoryModel.cpp
@@ -83,6 +83,26 @@ m_align = width;
viewport()->update(); } +void MemoryModel::jumpToAddress(const QString& hex) { + bool ok = false; + uint32_t i = hex.toInt(&ok, 16); + if (ok) { + jumpToAddress(i); + } +} + +void MemoryModel::jumpToAddress(uint32_t address) { + if (address >= 0x10000000) { + return; + } + if (address < m_base || address >= m_base + m_size) { + setRegion(0, 0x10000000, tr("All")); + } + m_top = (address - m_base) / 16; + boundsCheck(); + verticalScrollBar()->setValue(m_top); +} + void MemoryModel::resizeEvent(QResizeEvent*) { verticalScrollBar()->setRange(0, (m_size >> 4) + 1 - viewport()->size().height() / m_cellHeight); boundsCheck();
M
src/platform/qt/MemoryModel.h
→
src/platform/qt/MemoryModel.h
@@ -29,6 +29,10 @@
void setRegion(uint32_t base, uint32_t size, const QString& name = QString()); void setAlignment(int); +public slots: + void jumpToAddress(const QString& hex); + void jumpToAddress(uint32_t); + protected: void resizeEvent(QResizeEvent*) override; void paintEvent(QPaintEvent*) override;
M
src/platform/qt/MemoryView.cpp
→
src/platform/qt/MemoryView.cpp
@@ -27,6 +27,7 @@
connect(m_ui.width8, &QAbstractButton::clicked, [this]() { m_ui.hexfield->setAlignment(1); }); connect(m_ui.width16, &QAbstractButton::clicked, [this]() { m_ui.hexfield->setAlignment(2); }); connect(m_ui.width32, &QAbstractButton::clicked, [this]() { m_ui.hexfield->setAlignment(4); }); + connect(m_ui.setAddress, SIGNAL(valueChanged(const QString&)), m_ui.hexfield, SLOT(jumpToAddress(const QString&))); connect(controller, SIGNAL(gameStopped(GBAThread*)), this, SLOT(close())); }
M
src/platform/qt/MemoryView.ui
→
src/platform/qt/MemoryView.ui
@@ -90,17 +90,23 @@ </item>
<item> <widget class="QLabel" name="label"> <property name="text"> - <string>Inspect Address</string> + <string>Inspect Address:</string> </property> </widget> </item> <item> - <widget class="QLineEdit" name="lineEdit"> - <property name="enabled"> - <bool>false</bool> + <widget class="QSpinBox" name="setAddress"> + <property name="prefix"> + <string>0x</string> </property> - <property name="maxLength"> - <number>10</number> + <property name="maximum"> + <number>268435455</number> + </property> + <property name="singleStep"> + <number>16</number> + </property> + <property name="displayIntegerBase"> + <number>16</number> </property> </widget> </item>