Skip to content

Commit

Permalink
Qt: (Debugger) Add ability to remove result from Memory Search results
Browse files Browse the repository at this point in the history
Adds the ability to remove individual search results from the Memory Search results list. Right clicking a result will give the "Remove Result" option in the context menu.
  • Loading branch information
Daniel-McCarthy authored and refractionpcsx2 committed Dec 9, 2023
1 parent b453787 commit 0f4a95e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pcsx2-qt/Debugger/CpuWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,21 @@ void CpuWidget::contextSearchResultGoToDisassembly()
m_ui.disassemblyWidget->gotoAddress(m_ui.listSearchResults->selectedItems().first()->data(256).toUInt());
}

void CpuWidget::contextRemoveSearchResult()
{
const QItemSelectionModel* selModel = m_ui.listSearchResults->selectionModel();
if (!selModel->hasSelection())
return;

const int selectedResultIndex = m_ui.listSearchResults->row(m_ui.listSearchResults->selectedItems().first());
auto* rowToRemove = m_ui.listSearchResults->takeItem(selectedResultIndex);
if (m_searchResults.size() > selectedResultIndex && m_searchResults.at(selectedResultIndex) == rowToRemove->data(256).toUInt())
{
m_searchResults.erase(m_searchResults.begin() + selectedResultIndex);
}
delete rowToRemove;
}

void CpuWidget::updateFunctionList(bool whenEmpty)
{
if (!m_cpu.isAlive())
Expand Down Expand Up @@ -797,6 +812,10 @@ void CpuWidget::onListSearchResultsContextMenu(QPoint pos)
QAction* goToDisassemblyAction = new QAction(tr("Go to in Disassembly"), m_ui.listSearchResults);
connect(goToDisassemblyAction, &QAction::triggered, this, &CpuWidget::contextSearchResultGoToDisassembly);
contextMenu->addAction(goToDisassemblyAction);

QAction* removeResultAction = new QAction(tr("Remove Result"), m_ui.listSearchResults);
connect(removeResultAction, &QAction::triggered, this, &CpuWidget::contextRemoveSearchResult);
contextMenu->addAction(removeResultAction);
}

contextMenu->popup(m_ui.listSearchResults->viewport()->mapToGlobal(pos));
Expand Down
1 change: 1 addition & 0 deletions pcsx2-qt/Debugger/CpuWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public slots:
void onSearchResultsListScroll(u32 value);
void loadSearchResults();
void contextSearchResultGoToDisassembly();
void contextRemoveSearchResult();
void onListSearchResultsContextMenu(QPoint pos);

private:
Expand Down

0 comments on commit 0f4a95e

Please sign in to comment.