Qt: Hook up memory search to viewer
Vicki Pfau vi@endrift.com
Mon, 19 Jun 2017 20:53:33 -0700
4 files changed,
26 insertions(+),
4 deletions(-)
M
src/platform/qt/MemorySearch.cpp
→
src/platform/qt/MemorySearch.cpp
@@ -9,6 +9,7 @@
#include <mgba/core/core.h> #include "GameController.h" +#include "MemoryView.h" using namespace QGBA;@@ -24,6 +25,7 @@ connect(m_ui.searchWithin, &QPushButton::clicked, this, &MemorySearch::searchWithin);
connect(m_ui.refresh, &QPushButton::clicked, this, &MemorySearch::refresh); connect(m_ui.numHex, &QPushButton::clicked, this, &MemorySearch::refresh); connect(m_ui.numDec, &QPushButton::clicked, this, &MemorySearch::refresh); + connect(m_ui.viewMem, &QPushButton::clicked, this, &MemorySearch::openMemory); } MemorySearch::~MemorySearch() {@@ -185,3 +187,19 @@ m_ui.results->setItem(i, 1, item);
} m_ui.results->sortItems(0); } + +void MemorySearch::openMemory() { + auto items = m_ui.results->selectedItems(); + if (items.empty()) { + return; + } + QTableWidgetItem* item = items[0]; + uint32_t address = item->text().toUInt(nullptr, 16); + + MemoryView* memView = new MemoryView(m_controller); + memView->jumpToAddress(address); + + connect(m_controller, &GameController::gameStopped, memView, &QWidget::close); + memView->setAttribute(Qt::WA_DeleteOnClose); + memView->show(); +}
M
src/platform/qt/MemorySearch.h
→
src/platform/qt/MemorySearch.h
@@ -28,6 +28,9 @@ void refresh();
void search(); void searchWithin(); +private slots: + void openMemory(); + private: bool createParams(mCoreMemorySearchParams*);
M
src/platform/qt/MemorySearch.ui
→
src/platform/qt/MemorySearch.ui
@@ -28,6 +28,9 @@ <horstretch>1</horstretch>
<verstretch>0</verstretch> </sizepolicy> </property> + <property name="editTriggers"> + <set>QAbstractItemView::NoEditTriggers</set> + </property> <property name="selectionBehavior"> <enum>QAbstractItemView::SelectRows</enum> </property>@@ -194,11 +197,8 @@ </widget>
</item> <item> <widget class="QPushButton" name="viewMem"> - <property name="enabled"> - <bool>false</bool> - </property> <property name="text"> - <string>View in Memory View</string> + <string>Open in Memory Viewer</string> </property> </widget> </item>
M
src/platform/qt/MemoryView.h
→
src/platform/qt/MemoryView.h
@@ -22,6 +22,7 @@ MemoryView(GameController* controller, QWidget* parent = nullptr);
public slots: void update(); + void jumpToAddress(uint32_t address) { m_ui.hexfield->jumpToAddress(address); } private slots: void setIndex(int);