Qt: (Debugger) Add ability to remove result from Memory Search results

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.
This commit is contained in:
Dan McCarthy 2023-12-08 16:46:41 -06:00 committed by refractionpcsx2
parent b453787670
commit 0f4a95e31b
2 changed files with 20 additions and 0 deletions

View File

@ -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())
@ -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));

View File

@ -98,6 +98,7 @@ public slots:
void onSearchResultsListScroll(u32 value);
void loadSearchResults();
void contextSearchResultGoToDisassembly();
void contextRemoveSearchResult();
void onListSearchResultsContextMenu(QPoint pos);
private: