From 21542034d334d57bad90d5e0192c361b249e7473 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 30 Apr 2015 23:15:20 -0700 Subject: [PATCH] Qt: Memory view address jump --- src/platform/qt/MemoryModel.cpp | 20 ++++++++++++++++++++ src/platform/qt/MemoryModel.h | 4 ++++ src/platform/qt/MemoryView.cpp | 1 + src/platform/qt/MemoryView.ui | 18 ++++++++++++------ 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/platform/qt/MemoryModel.cpp b/src/platform/qt/MemoryModel.cpp index c34f5f7a0..46dc86a86 100644 --- a/src/platform/qt/MemoryModel.cpp +++ b/src/platform/qt/MemoryModel.cpp @@ -83,6 +83,26 @@ void MemoryModel::setAlignment(int 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(); diff --git a/src/platform/qt/MemoryModel.h b/src/platform/qt/MemoryModel.h index 272b29833..304fbba92 100644 --- a/src/platform/qt/MemoryModel.h +++ b/src/platform/qt/MemoryModel.h @@ -29,6 +29,10 @@ public: 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; diff --git a/src/platform/qt/MemoryView.cpp b/src/platform/qt/MemoryView.cpp index 195f957e3..41671c371 100644 --- a/src/platform/qt/MemoryView.cpp +++ b/src/platform/qt/MemoryView.cpp @@ -27,6 +27,7 @@ MemoryView::MemoryView(GameController* controller, QWidget* parent) 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())); } diff --git a/src/platform/qt/MemoryView.ui b/src/platform/qt/MemoryView.ui index 25ca12d0a..0684c41d4 100644 --- a/src/platform/qt/MemoryView.ui +++ b/src/platform/qt/MemoryView.ui @@ -90,17 +90,23 @@ - Inspect Address + Inspect Address: - - - false + + + 0x - - 10 + + 268435455 + + + 16 + + + 16