Qt: Adds right click Go To Disassembly menu option to Memory Search

Allows user to right click a memory search result in order to go to that memory address location in the disassembly view. This saves several step and makes it easier to do.

Also adds precedent for the memory search result context menu which will be used in future features.
This commit is contained in:
Dan McCarthy 2023-12-07 23:24:09 -06:00 committed by Connor McLaughlin
parent c555dbc3e8
commit b453787670
2 changed files with 28 additions and 0 deletions

View File

@ -101,10 +101,12 @@ CpuWidget::CpuWidget(QWidget* parent, DebugInterface& cpu)
connect(m_ui.btnRefreshFunctions, &QPushButton::clicked, [this] { updateFunctionList(); });
connect(m_ui.txtFuncSearch, &QLineEdit::textChanged, [this] { updateFunctionList(); });
m_ui.listSearchResults->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_ui.btnSearch, &QPushButton::clicked, this, &CpuWidget::onSearchButtonClicked);
connect(m_ui.btnFilterSearch, &QPushButton::clicked, this, &CpuWidget::onSearchButtonClicked);
connect(m_ui.listSearchResults, &QListWidget::itemDoubleClicked, [this](QListWidgetItem* item) { m_ui.memoryviewWidget->gotoAddress(item->text().toUInt(nullptr, 16)); });
connect(m_ui.listSearchResults->verticalScrollBar(), &QScrollBar::valueChanged, this, &CpuWidget::onSearchResultsListScroll);
connect(m_ui.listSearchResults, &QListView::customContextMenuRequested, this, &CpuWidget::onListSearchResultsContextMenu);
connect(m_ui.cmbSearchType, &QComboBox::currentIndexChanged, [this](int i) {
if (i < 4)
m_ui.chkSearchHex->setEnabled(true);
@ -482,6 +484,15 @@ void CpuWidget::contextBPListPasteCSV()
}
}
void CpuWidget::contextSearchResultGoToDisassembly()
{
const QItemSelectionModel* selModel = m_ui.listSearchResults->selectionModel();
if (!selModel->hasSelection())
return;
m_ui.disassemblyWidget->gotoAddress(m_ui.listSearchResults->selectedItems().first()->data(256).toUInt());
}
void CpuWidget::updateFunctionList(bool whenEmpty)
{
if (!m_cpu.isAlive())
@ -776,6 +787,21 @@ void CpuWidget::updateStackFrames()
m_stackModel.refreshData();
}
void CpuWidget::onListSearchResultsContextMenu(QPoint pos)
{
QMenu* contextMenu = new QMenu(tr("Search Results List Context Menu"), m_ui.listSearchResults);
const QItemSelectionModel* selModel = m_ui.listSearchResults->selectionModel();
if (selModel->hasSelection())
{
QAction* goToDisassemblyAction = new QAction(tr("Go to in Disassembly"), m_ui.listSearchResults);
connect(goToDisassemblyAction, &QAction::triggered, this, &CpuWidget::contextSearchResultGoToDisassembly);
contextMenu->addAction(goToDisassemblyAction);
}
contextMenu->popup(m_ui.listSearchResults->viewport()->mapToGlobal(pos));
}
void CpuWidget::onStackListContextMenu(QPoint pos)
{
if (!m_ui.stackList->selectionModel()->hasSelection())

View File

@ -97,6 +97,8 @@ public slots:
void onSearchButtonClicked();
void onSearchResultsListScroll(u32 value);
void loadSearchResults();
void contextSearchResultGoToDisassembly();
void onListSearchResultsContextMenu(QPoint pos);
private:
std::vector<QTableWidget*> m_registerTableViews;