summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2018-05-13 01:20:11 +0200
committerGitHub <noreply@github.com>2018-05-13 01:20:11 +0200
commit66c1b909c2697e3f3b3f306904e40204a443c7b2 (patch)
tree8d5cf63d52ffc8b16827405a44f9e6d7d8b1e5a5 /Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp
parentad5a69be79b654173a8a762dc8f55c0835eacd26 (diff)
parent5c688b2d2b18d07576410c8082483df9630b7851 (diff)
Merge pull request #6765 from aldelaro5/Qt-debugger-fixes
Qt/debugger: fix a bunch of things
Diffstat (limited to 'Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp')
-rw-r--r--Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp61
1 files changed, 40 insertions, 21 deletions
diff --git a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp
index 0705dc5708..e531fc66c8 100644
--- a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp
+++ b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp
@@ -39,12 +39,12 @@ CodeViewWidget::CodeViewWidget()
setShowGrid(false);
setContextMenuPolicy(Qt::CustomContextMenu);
setSelectionMode(QAbstractItemView::SingleSelection);
+ setSelectionBehavior(QAbstractItemView::SelectRows);
verticalScrollBar()->setHidden(true);
for (int i = 0; i < columnCount(); i++)
{
- horizontalHeader()->setSectionResizeMode(i, i == 0 ? QHeaderView::Fixed :
- QHeaderView::ResizeToContents);
+ horizontalHeader()->setSectionResizeMode(i, QHeaderView::Fixed);
}
verticalHeader()->hide();
@@ -56,6 +56,7 @@ CodeViewWidget::CodeViewWidget()
Update();
connect(this, &CodeViewWidget::customContextMenuRequested, this, &CodeViewWidget::OnContextMenu);
+ connect(this, &CodeViewWidget::itemSelectionChanged, this, &CodeViewWidget::OnSelectionChanged);
connect(&Settings::Instance(), &Settings::DebugFontChanged, this, &QWidget::setFont);
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this] {
m_address = PC;
@@ -119,6 +120,23 @@ void CodeViewWidget::Update()
auto* param_item = new QTableWidgetItem(QString::fromStdString(param));
auto* description_item = new QTableWidgetItem(QString::fromStdString(desc));
+ for (auto* item : {bp_item, addr_item, ins_item, param_item, description_item})
+ {
+ item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+ item->setData(Qt::UserRole, addr);
+
+ if (color != 0xFFFFFF)
+ {
+ item->setForeground(QColor(Qt::black));
+ item->setBackground(QColor(color));
+ }
+ if (addr == pc && item != bp_item)
+ {
+ item->setBackground(QColor(Qt::green));
+ item->setForeground(QColor(Qt::black));
+ }
+ }
+
// look for hex strings to decode branches
std::string hex_str;
size_t pos = param.find("0x");
@@ -137,20 +155,6 @@ void CodeViewWidget::Update()
if (ins == "blr")
ins_item->setForeground(Qt::darkGreen);
- for (auto* item : {bp_item, addr_item, ins_item, param_item, description_item})
- {
- item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
- item->setData(Qt::UserRole, addr);
-
- if (color != 0xFFFFFF)
- item->setBackground(QColor(color).darker(110));
-
- if (addr == pc && item != bp_item)
- {
- item->setBackground(QColor(Qt::green).darker(110));
- }
- }
-
if (PowerPC::debug_interface.IsBreakpoint(addr))
{
bp_item->setData(Qt::DecorationRole,
@@ -165,10 +169,11 @@ void CodeViewWidget::Update()
if (addr == GetAddress())
{
- addr_item->setSelected(true);
+ selectRow(addr_item->row());
}
}
+ resizeColumnsToContents();
setColumnWidth(0, 24 + 5);
g_symbolDB.FillInCallers();
@@ -182,13 +187,14 @@ u32 CodeViewWidget::GetAddress() const
return m_address;
}
-void CodeViewWidget::SetAddress(u32 address)
+void CodeViewWidget::SetAddress(u32 address, SetAddressUpdate update)
{
if (m_address == address)
return;
m_address = address;
- Update();
+ if (update == SetAddressUpdate::WithUpdate)
+ Update();
}
void CodeViewWidget::ReplaceAddress(u32 address, bool blr)
@@ -362,7 +368,7 @@ void CodeViewWidget::OnFollowBranch()
if (!branch_addr)
return;
- SetAddress(branch_addr);
+ SetAddress(branch_addr, SetAddressUpdate::WithUpdate);
}
void CodeViewWidget::OnRenameSymbol()
@@ -387,6 +393,19 @@ void CodeViewWidget::OnRenameSymbol()
}
}
+void CodeViewWidget::OnSelectionChanged()
+{
+ if (m_address == PowerPC::ppcState.pc)
+ {
+ setStyleSheet(QString::fromStdString(
+ "QTableView::item:selected {background-color: #00FF00; color: #000000;}"));
+ }
+ else if (!styleSheet().isEmpty())
+ {
+ setStyleSheet(QString::fromStdString(""));
+ }
+}
+
void CodeViewWidget::OnSetSymbolSize()
{
const u32 addr = GetContextAddress();
@@ -515,7 +534,7 @@ void CodeViewWidget::mousePressEvent(QMouseEvent* event)
if (column(item) == 0)
ToggleBreakpoint();
else
- SetAddress(addr);
+ SetAddress(addr, SetAddressUpdate::WithUpdate);
Update();
break;