Qt: select target item in debugger list

This should make it easier to spot the item
This commit is contained in:
Megamouse 2021-03-23 20:51:39 +01:00
parent ba45daff35
commit 452fb59c74
5 changed files with 15 additions and 10 deletions

View file

@ -23,7 +23,7 @@ public:
QColor m_text_color_bp;
QColor m_color_bp;
Q_SIGNALS:
void RequestShowAddress(u32 addr, bool force = false);
void RequestShowAddress(u32 addr, bool select_addr = true, bool force = false);
public Q_SLOTS:
void HandleBreakpointRequest(u32 addr);
private Q_SLOTS:

View file

@ -16,7 +16,7 @@ public:
call_stack_list(QWidget* parent);
Q_SIGNALS:
void RequestShowAddress(u32 addr, bool force = false);
void RequestShowAddress(u32 addr, bool select_addr = true, bool force = false);
public Q_SLOTS:
void HandleUpdate(std::vector<std::pair<u32, u32>> call_stack);
private Q_SLOTS:

View file

@ -184,7 +184,7 @@ debugger_frame::debugger_frame(std::shared_ptr<gui_settings> settings, QWidget *
connect(this, &debugger_frame::CallStackUpdateRequested, m_call_stack_list, &call_stack_list::HandleUpdate);
connect(m_call_stack_list, &call_stack_list::RequestShowAddress, m_debugger_list, &debugger_list::ShowAddress);
m_debugger_list->ShowAddress(m_debugger_list->m_pc);
m_debugger_list->ShowAddress(m_debugger_list->m_pc, false);
UpdateUnitList();
}
@ -460,7 +460,7 @@ void debugger_frame::keyPressEvent(QKeyEvent* event)
}
if (auto pos = std::basic_string_view<u32>(res.data(), 2).find_last_not_of(UINT32_MAX); pos != umax)
m_debugger_list->ShowAddress(res[pos] - std::max(i, 0) * 4, true);
m_debugger_list->ShowAddress(res[pos] - std::max(i, 0) * 4, true, true);
return;
}
@ -854,7 +854,7 @@ void debugger_frame::ShowGotoAddressDialog()
if (dlg->exec() == QDialog::Accepted)
{
const u32 address = EvaluateExpression(expression_input->text());
m_debugger_list->ShowAddress(address);
m_debugger_list->ShowAddress(address, true);
}
dlg->deleteLater();
@ -889,7 +889,7 @@ void debugger_frame::ShowPC()
const u32 pc = (cpu0 ? cpu0->get_pc() : 0);
m_debugger_list->ShowAddress(pc);
m_debugger_list->ShowAddress(pc, true);
}
void debugger_frame::DoStep(bool step_over)

View file

@ -43,7 +43,7 @@ u32 debugger_list::GetCenteredAddress(u32 address) const
return address - ((m_item_count / 2) * 4);
}
void debugger_list::ShowAddress(u32 addr, bool force)
void debugger_list::ShowAddress(u32 addr, bool select_addr, bool force)
{
auto IsBreakpoint = [this](u32 pc)
{
@ -114,6 +114,11 @@ void debugger_list::ShowAddress(u32 addr, bool force)
list_item->setBackground(default_background);
}
if (select_addr && pc == addr)
{
list_item->setSelected(true);
}
if (m_cpu->id_type() == 1 && !vm::check_addr(pc, 0))
{
list_item->setText((IsBreakpoint(pc) ? ">> " : " ") + qstr(fmt::format("[%08x] ?? ?? ?? ??:", pc)));
@ -159,7 +164,7 @@ void debugger_list::scroll(s32 steps)
steps--;
}
ShowAddress(m_pc + (steps * 4), true);
ShowAddress(m_pc + (steps * 4), false, true);
}
void debugger_list::keyPressEvent(QKeyEvent* event)
@ -298,5 +303,5 @@ void debugger_list::resizeEvent(QResizeEvent* event)
delete item(m_item_count);
}
ShowAddress(m_pc);
ShowAddress(m_pc, false);
}

View file

@ -30,7 +30,7 @@ public:
debugger_list(QWidget* parent, std::shared_ptr<gui_settings> settings, breakpoint_handler* handler);
void UpdateCPUData(cpu_thread* cpu, CPUDisAsm* disasm);
public Q_SLOTS:
void ShowAddress(u32 addr, bool force = false);
void ShowAddress(u32 addr, bool select_addr = true, bool force = false);
protected:
void keyPressEvent(QKeyEvent* event) override;
void mouseDoubleClickEvent(QMouseEvent* event) override;