Debugger CodeWidget : Add search box for notes.

This commit is contained in:
TryTwo
2025-05-19 23:30:20 -07:00
parent 040d9a4336
commit 78065359bb
2 changed files with 49 additions and 3 deletions

View File

@ -16,7 +16,9 @@
#include <QPushButton>
#include <QSplitter>
#include <QStyleHints>
#include <QTabWidget>
#include <QTableWidget>
#include <QVBoxLayout>
#include <QWidget>
#include "Common/Event.h"
@ -120,7 +122,7 @@ void CodeWidget::CreateWidgets()
m_box_splitter = new QSplitter(Qt::Vertical);
m_box_splitter->setStyleSheet(BOX_SPLITTER_STYLESHEET);
auto add_search_line_edit = [this](const QString& name, QListWidget* list_widget) {
auto add_search_line_edit = [this](const QString& name, QWidget* list_widget) {
auto* widget = new QWidget;
auto* line_layout = new QGridLayout;
auto* label = new QLabel(name);
@ -139,8 +141,12 @@ void CodeWidget::CreateWidgets()
m_search_callstack = add_search_line_edit(tr("Callstack"), m_callstack_list);
// Symbols
auto* symbols_tab = new QTabWidget;
m_symbols_list = new QListWidget;
m_search_symbols = add_search_line_edit(tr("Symbols"), m_symbols_list);
m_note_list = new QListWidget;
symbols_tab->addTab(m_symbols_list, tr("Symbols"));
symbols_tab->addTab(m_note_list, tr("Notes"));
m_search_symbols = add_search_line_edit(tr("Symbols"), symbols_tab);
// Function calls
m_function_calls_list = new QListWidget;
@ -198,7 +204,7 @@ void CodeWidget::ConnectWidgets()
connect(m_search_callstack, &QLineEdit::textChanged, this, &CodeWidget::UpdateCallstack);
connect(m_branch_watch, &QPushButton::clicked, this, &CodeWidget::OnBranchWatchDialog);
connect(m_note_list, &QListWidget::itemPressed, this, &CodeWidget::OnSelectNote);
connect(m_symbols_list, &QListWidget::itemPressed, this, &CodeWidget::OnSelectSymbol);
connect(m_callstack_list, &QListWidget::itemPressed, this, &CodeWidget::OnSelectCallstack);
connect(m_function_calls_list, &QListWidget::itemPressed, this,
@ -236,6 +242,7 @@ void CodeWidget::OnSetCodeAddress(u32 address)
void CodeWidget::OnPPCSymbolsChanged()
{
UpdateSymbols();
UpdateNotes();
UpdateCallstack();
if (const Common::Symbol* symbol = m_ppc_symbol_db.GetSymbolFromAddr(m_code_view->GetAddress()))
{
@ -279,6 +286,7 @@ void CodeWidget::OnSearchSymbols()
{
m_symbol_filter = m_search_symbols->text();
UpdateSymbols();
UpdateNotes();
}
void CodeWidget::OnSelectSymbol()
@ -298,6 +306,17 @@ void CodeWidget::OnSelectSymbol()
m_code_view->setFocus();
}
void CodeWidget::OnSelectNote()
{
const auto items = m_note_list->selectedItems();
if (items.isEmpty())
return;
const u32 address = items[0]->data(Qt::UserRole).toUInt();
m_code_view->SetAddress(address, CodeViewWidget::SetAddressUpdate::WithUpdate);
}
void CodeWidget::OnSelectCallstack()
{
const auto items = m_callstack_list->selectedItems();
@ -426,6 +445,30 @@ void CodeWidget::UpdateSymbols()
m_symbols_list->sortItems();
}
void CodeWidget::UpdateNotes()
{
const QString selection = m_note_list->selectedItems().isEmpty() ?
QStringLiteral("") :
m_note_list->selectedItems()[0]->text();
m_note_list->clear();
for (const auto& note : m_ppc_symbol_db.Notes())
{
const QString name = QString::fromStdString(note.second.name);
auto* item = new QListWidgetItem(name);
if (name == selection)
item->setSelected(true);
item->setData(Qt::UserRole, note.second.address);
if (name.toUpper().indexOf(m_symbol_filter.toUpper()) != -1)
m_note_list->addItem(item);
}
m_note_list->sortItems();
}
void CodeWidget::UpdateFunctionCalls(const Common::Symbol* symbol)
{
m_function_calls_list->clear();

View File

@ -61,11 +61,13 @@ private:
void UpdateCallstack();
void UpdateFunctionCalls(const Common::Symbol* symbol);
void UpdateFunctionCallers(const Common::Symbol* symbol);
void UpdateNotes();
void OnPPCSymbolsChanged();
void OnSearchAddress();
void OnSearchSymbols();
void OnSelectSymbol();
void OnSelectNote();
void OnSelectCallstack();
void OnSelectFunctionCallers();
void OnSelectFunctionCalls();
@ -84,6 +86,7 @@ private:
QListWidget* m_callstack_list;
QLineEdit* m_search_symbols;
QListWidget* m_symbols_list;
QListWidget* m_note_list;
QLineEdit* m_search_calls;
QListWidget* m_function_calls_list;
QLineEdit* m_search_callers;