summaryrefslogtreecommitdiff
path: root/src/citra_qt/debugger/graphics_breakpoints.cpp
diff options
context:
space:
mode:
authorGravatar Subv2015-07-22 20:42:59 -0500
committerGravatar Subv2015-07-23 19:37:52 -0500
commit23fd13dd6411fe390cd139144cc077cec13b233b (patch)
tree049d8c19e13ae516d1eabf55448f480473095173 /src/citra_qt/debugger/graphics_breakpoints.cpp
parentMerge pull request #968 from Subv/texture_filtering (diff)
downloadyuzu-23fd13dd6411fe390cd139144cc077cec13b233b.tar.gz
yuzu-23fd13dd6411fe390cd139144cc077cec13b233b.tar.xz
yuzu-23fd13dd6411fe390cd139144cc077cec13b233b.zip
Qt/GPU Breakpoints: Changed the widget so that we don't have to select and click the Enable button when enabling/disabling a breakpoint, now it is done via a checkbox next to the breakpoint's name.
Diffstat (limited to 'src/citra_qt/debugger/graphics_breakpoints.cpp')
-rw-r--r--src/citra_qt/debugger/graphics_breakpoints.cpp103
1 files changed, 38 insertions, 65 deletions
diff --git a/src/citra_qt/debugger/graphics_breakpoints.cpp b/src/citra_qt/debugger/graphics_breakpoints.cpp
index 1da64f616..256ff8ed2 100644
--- a/src/citra_qt/debugger/graphics_breakpoints.cpp
+++ b/src/citra_qt/debugger/graphics_breakpoints.cpp
@@ -4,7 +4,7 @@
4 4
5#include <QMetaType> 5#include <QMetaType>
6#include <QPushButton> 6#include <QPushButton>
7#include <QTreeWidget> 7#include <QTreeView>
8#include <QVBoxLayout> 8#include <QVBoxLayout>
9#include <QLabel> 9#include <QLabel>
10 10
@@ -23,7 +23,7 @@ BreakPointModel::BreakPointModel(std::shared_ptr<Pica::DebugContext> debug_conte
23 23
24int BreakPointModel::columnCount(const QModelIndex& parent) const 24int BreakPointModel::columnCount(const QModelIndex& parent) const
25{ 25{
26 return 2; 26 return 1;
27} 27}
28 28
29int BreakPointModel::rowCount(const QModelIndex& parent) const 29int BreakPointModel::rowCount(const QModelIndex& parent) const
@@ -38,9 +38,7 @@ QVariant BreakPointModel::data(const QModelIndex& index, int role) const
38 switch (role) { 38 switch (role) {
39 case Qt::DisplayRole: 39 case Qt::DisplayRole:
40 { 40 {
41 switch (index.column()) { 41 if (index.column() == 0) {
42 case 0:
43 {
44 static const std::map<Pica::DebugContext::Event, QString> map = { 42 static const std::map<Pica::DebugContext::Event, QString> map = {
45 { Pica::DebugContext::Event::CommandLoaded, tr("Pica command loaded") }, 43 { Pica::DebugContext::Event::CommandLoaded, tr("Pica command loaded") },
46 { Pica::DebugContext::Event::CommandProcessed, tr("Pica command processed") }, 44 { Pica::DebugContext::Event::CommandProcessed, tr("Pica command processed") },
@@ -50,17 +48,16 @@ QVariant BreakPointModel::data(const QModelIndex& index, int role) const
50 }; 48 };
51 49
52 DEBUG_ASSERT(map.size() == static_cast<size_t>(Pica::DebugContext::Event::NumEvents)); 50 DEBUG_ASSERT(map.size() == static_cast<size_t>(Pica::DebugContext::Event::NumEvents));
53
54 return (map.find(event) != map.end()) ? map.at(event) : QString(); 51 return (map.find(event) != map.end()) ? map.at(event) : QString();
55 } 52 }
56 53
57 case 1: 54 break;
58 return data(index, Role_IsEnabled).toBool() ? tr("Enabled") : tr("Disabled"); 55 }
59
60 default:
61 break;
62 }
63 56
57 case Qt::CheckStateRole:
58 {
59 if (index.column() == 0)
60 return data(index, Role_IsEnabled).toBool() ? Qt::Checked : Qt::Unchecked;
64 break; 61 break;
65 } 62 }
66 63
@@ -84,37 +81,34 @@ QVariant BreakPointModel::data(const QModelIndex& index, int role) const
84 return QVariant(); 81 return QVariant();
85} 82}
86 83
87QVariant BreakPointModel::headerData(int section, Qt::Orientation orientation, int role) const 84Qt::ItemFlags BreakPointModel::flags(const QModelIndex &index) const
88{ 85{
89 switch(role) { 86 if (!index.isValid())
90 case Qt::DisplayRole: 87 return 0;
91 {
92 if (section == 0) {
93 return tr("Event");
94 } else if (section == 1) {
95 return tr("Status");
96 }
97
98 break;
99 }
100 }
101 88
102 return QVariant(); 89 Qt::ItemFlags flags = Qt::ItemIsEnabled;
90 if (index.column() == 0)
91 flags |= Qt::ItemIsUserCheckable;
92 return flags;
103} 93}
104 94
95
105bool BreakPointModel::setData(const QModelIndex& index, const QVariant& value, int role) 96bool BreakPointModel::setData(const QModelIndex& index, const QVariant& value, int role)
106{ 97{
107 const auto event = static_cast<Pica::DebugContext::Event>(index.row()); 98 const auto event = static_cast<Pica::DebugContext::Event>(index.row());
108 99
109 switch (role) { 100 switch (role) {
110 case Role_IsEnabled: 101 case Qt::CheckStateRole:
111 { 102 {
103 if (index.column() != 0)
104 return false;
105
112 auto context = context_weak.lock(); 106 auto context = context_weak.lock();
113 if (!context) 107 if (!context)
114 return false; 108 return false;
115 109
116 context->breakpoints[event].enabled = value.toBool(); 110 context->breakpoints[event].enabled = value == Qt::Checked;
117 QModelIndex changed_index = createIndex(index.row(), 1); 111 QModelIndex changed_index = createIndex(index.row(), 0);
118 emit dataChanged(changed_index, changed_index); 112 emit dataChanged(changed_index, changed_index);
119 return true; 113 return true;
120 } 114 }
@@ -133,7 +127,7 @@ void BreakPointModel::OnBreakPointHit(Pica::DebugContext::Event event)
133 active_breakpoint = context->active_breakpoint; 127 active_breakpoint = context->active_breakpoint;
134 at_breakpoint = context->at_breakpoint; 128 at_breakpoint = context->at_breakpoint;
135 emit dataChanged(createIndex(static_cast<int>(event), 0), 129 emit dataChanged(createIndex(static_cast<int>(event), 0),
136 createIndex(static_cast<int>(event), 1)); 130 createIndex(static_cast<int>(event), 0));
137} 131}
138 132
139void BreakPointModel::OnResumed() 133void BreakPointModel::OnResumed()
@@ -144,7 +138,7 @@ void BreakPointModel::OnResumed()
144 138
145 at_breakpoint = context->at_breakpoint; 139 at_breakpoint = context->at_breakpoint;
146 emit dataChanged(createIndex(static_cast<int>(active_breakpoint), 0), 140 emit dataChanged(createIndex(static_cast<int>(active_breakpoint), 0),
147 createIndex(static_cast<int>(active_breakpoint), 1)); 141 createIndex(static_cast<int>(active_breakpoint), 0));
148 active_breakpoint = context->active_breakpoint; 142 active_breakpoint = context->active_breakpoint;
149} 143}
150 144
@@ -162,13 +156,15 @@ GraphicsBreakPointsWidget::GraphicsBreakPointsWidget(std::shared_ptr<Pica::Debug
162 156
163 breakpoint_model = new BreakPointModel(debug_context, this); 157 breakpoint_model = new BreakPointModel(debug_context, this);
164 breakpoint_list = new QTreeView; 158 breakpoint_list = new QTreeView;
159 breakpoint_list->setRootIsDecorated(false);
160 breakpoint_list->setHeaderHidden(true);
165 breakpoint_list->setModel(breakpoint_model); 161 breakpoint_list->setModel(breakpoint_model);
166 162
167 toggle_breakpoint_button = new QPushButton(tr("Enable"));
168 toggle_breakpoint_button->setEnabled(false);
169
170 qRegisterMetaType<Pica::DebugContext::Event>("Pica::DebugContext::Event"); 163 qRegisterMetaType<Pica::DebugContext::Event>("Pica::DebugContext::Event");
171 164
165 connect(breakpoint_list, SIGNAL(doubleClicked(const QModelIndex&)),
166 this, SLOT(OnItemDoubleClicked(const QModelIndex&)));
167
172 connect(resume_button, SIGNAL(clicked()), this, SLOT(OnResumeRequested())); 168 connect(resume_button, SIGNAL(clicked()), this, SLOT(OnResumeRequested()));
173 169
174 connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event,void*)), 170 connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event,void*)),
@@ -184,11 +180,6 @@ GraphicsBreakPointsWidget::GraphicsBreakPointsWidget(std::shared_ptr<Pica::Debug
184 connect(this, SIGNAL(BreakPointsChanged(const QModelIndex&,const QModelIndex&)), 180 connect(this, SIGNAL(BreakPointsChanged(const QModelIndex&,const QModelIndex&)),
185 breakpoint_model, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&))); 181 breakpoint_model, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)));
186 182
187 connect(breakpoint_list->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
188 this, SLOT(OnBreakpointSelectionChanged(QModelIndex)));
189
190 connect(toggle_breakpoint_button, SIGNAL(clicked()), this, SLOT(OnToggleBreakpointEnabled()));
191
192 QWidget* main_widget = new QWidget; 183 QWidget* main_widget = new QWidget;
193 auto main_layout = new QVBoxLayout; 184 auto main_layout = new QVBoxLayout;
194 { 185 {
@@ -198,7 +189,6 @@ GraphicsBreakPointsWidget::GraphicsBreakPointsWidget(std::shared_ptr<Pica::Debug
198 main_layout->addLayout(sub_layout); 189 main_layout->addLayout(sub_layout);
199 } 190 }
200 main_layout->addWidget(breakpoint_list); 191 main_layout->addWidget(breakpoint_list);
201 main_layout->addWidget(toggle_breakpoint_button);
202 main_widget->setLayout(main_layout); 192 main_widget->setLayout(main_layout);
203 193
204 setWidget(main_widget); 194 setWidget(main_widget);
@@ -234,32 +224,15 @@ void GraphicsBreakPointsWidget::OnResumeRequested()
234 context->Resume(); 224 context->Resume();
235} 225}
236 226
237void GraphicsBreakPointsWidget::OnBreakpointSelectionChanged(const QModelIndex& index) 227void GraphicsBreakPointsWidget::OnItemDoubleClicked(const QModelIndex& index)
238{ 228{
239 if (!index.isValid()) { 229 if (!index.isValid())
240 toggle_breakpoint_button->setEnabled(false);
241 return; 230 return;
242 }
243 231
244 toggle_breakpoint_button->setEnabled(true); 232 QModelIndex check_index = breakpoint_list->model()->index(index.row(), 0);
245 UpdateToggleBreakpointButton(index); 233 QVariant enabled = breakpoint_list->model()->data(check_index, Qt::CheckStateRole);
246} 234 QVariant new_state = Qt::Unchecked;
247 235 if (enabled == Qt::Unchecked)
248void GraphicsBreakPointsWidget::OnToggleBreakpointEnabled() 236 new_state = Qt::Checked;
249{ 237 breakpoint_list->model()->setData(check_index, new_state, Qt::CheckStateRole);
250 QModelIndex index = breakpoint_list->selectionModel()->currentIndex();
251 bool new_state = !(breakpoint_model->data(index, BreakPointModel::Role_IsEnabled).toBool());
252
253 breakpoint_model->setData(index, new_state,
254 BreakPointModel::Role_IsEnabled);
255 UpdateToggleBreakpointButton(index);
256}
257
258void GraphicsBreakPointsWidget::UpdateToggleBreakpointButton(const QModelIndex& index)
259{
260 if (true == breakpoint_model->data(index, BreakPointModel::Role_IsEnabled).toBool()) {
261 toggle_breakpoint_button->setText(tr("Disable"));
262 } else {
263 toggle_breakpoint_button->setText(tr("Enable"));
264 }
265} 238}