summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2015-07-25 12:00:10 -0700
committerGravatar Yuri Kunde Schlesner2015-07-25 12:00:10 -0700
commit43e1f56ff5e43193a124a965cdcae9d7348306fc (patch)
tree7ee66b3c50c97920c736b8b2e7e5444b2c544b74 /src
parentMerge pull request #983 from yuriks/null-memory-fill (diff)
parentQt/GPU Breakpoints: Changed the widget so that we don't have to select and cl... (diff)
downloadyuzu-43e1f56ff5e43193a124a965cdcae9d7348306fc.tar.gz
yuzu-43e1f56ff5e43193a124a965cdcae9d7348306fc.tar.xz
yuzu-43e1f56ff5e43193a124a965cdcae9d7348306fc.zip
Merge pull request #981 from Subv/checkboxes
Qt/GPU Breakpoints: Changed the widget to have a checkbox next to each bp type
Diffstat (limited to 'src')
-rw-r--r--src/citra_qt/debugger/graphics_breakpoints.cpp103
-rw-r--r--src/citra_qt/debugger/graphics_breakpoints.h6
-rw-r--r--src/citra_qt/debugger/graphics_breakpoints_p.h2
3 files changed, 40 insertions, 71 deletions
diff --git a/src/citra_qt/debugger/graphics_breakpoints.cpp b/src/citra_qt/debugger/graphics_breakpoints.cpp
index 4606c01f2..5202c168c 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::PicaCommandLoaded, tr("Pica command loaded") }, 43 { Pica::DebugContext::Event::PicaCommandLoaded, tr("Pica command loaded") },
46 { Pica::DebugContext::Event::PicaCommandProcessed, tr("Pica command processed") }, 44 { Pica::DebugContext::Event::PicaCommandProcessed, tr("Pica command processed") },
@@ -53,17 +51,16 @@ QVariant BreakPointModel::data(const QModelIndex& index, int role) const
53 }; 51 };
54 52
55 DEBUG_ASSERT(map.size() == static_cast<size_t>(Pica::DebugContext::Event::NumEvents)); 53 DEBUG_ASSERT(map.size() == static_cast<size_t>(Pica::DebugContext::Event::NumEvents));
56
57 return (map.find(event) != map.end()) ? map.at(event) : QString(); 54 return (map.find(event) != map.end()) ? map.at(event) : QString();
58 } 55 }
59 56
60 case 1: 57 break;
61 return data(index, Role_IsEnabled).toBool() ? tr("Enabled") : tr("Disabled"); 58 }
62
63 default:
64 break;
65 }
66 59
60 case Qt::CheckStateRole:
61 {
62 if (index.column() == 0)
63 return data(index, Role_IsEnabled).toBool() ? Qt::Checked : Qt::Unchecked;
67 break; 64 break;
68 } 65 }
69 66
@@ -87,37 +84,34 @@ QVariant BreakPointModel::data(const QModelIndex& index, int role) const
87 return QVariant(); 84 return QVariant();
88} 85}
89 86
90QVariant BreakPointModel::headerData(int section, Qt::Orientation orientation, int role) const 87Qt::ItemFlags BreakPointModel::flags(const QModelIndex &index) const
91{ 88{
92 switch(role) { 89 if (!index.isValid())
93 case Qt::DisplayRole: 90 return 0;
94 {
95 if (section == 0) {
96 return tr("Event");
97 } else if (section == 1) {
98 return tr("Status");
99 }
100
101 break;
102 }
103 }
104 91
105 return QVariant(); 92 Qt::ItemFlags flags = Qt::ItemIsEnabled;
93 if (index.column() == 0)
94 flags |= Qt::ItemIsUserCheckable;
95 return flags;
106} 96}
107 97
98
108bool BreakPointModel::setData(const QModelIndex& index, const QVariant& value, int role) 99bool BreakPointModel::setData(const QModelIndex& index, const QVariant& value, int role)
109{ 100{
110 const auto event = static_cast<Pica::DebugContext::Event>(index.row()); 101 const auto event = static_cast<Pica::DebugContext::Event>(index.row());
111 102
112 switch (role) { 103 switch (role) {
113 case Role_IsEnabled: 104 case Qt::CheckStateRole:
114 { 105 {
106 if (index.column() != 0)
107 return false;
108
115 auto context = context_weak.lock(); 109 auto context = context_weak.lock();
116 if (!context) 110 if (!context)
117 return false; 111 return false;
118 112
119 context->breakpoints[event].enabled = value.toBool(); 113 context->breakpoints[event].enabled = value == Qt::Checked;
120 QModelIndex changed_index = createIndex(index.row(), 1); 114 QModelIndex changed_index = createIndex(index.row(), 0);
121 emit dataChanged(changed_index, changed_index); 115 emit dataChanged(changed_index, changed_index);
122 return true; 116 return true;
123 } 117 }
@@ -136,7 +130,7 @@ void BreakPointModel::OnBreakPointHit(Pica::DebugContext::Event event)
136 active_breakpoint = context->active_breakpoint; 130 active_breakpoint = context->active_breakpoint;
137 at_breakpoint = context->at_breakpoint; 131 at_breakpoint = context->at_breakpoint;
138 emit dataChanged(createIndex(static_cast<int>(event), 0), 132 emit dataChanged(createIndex(static_cast<int>(event), 0),
139 createIndex(static_cast<int>(event), 1)); 133 createIndex(static_cast<int>(event), 0));
140} 134}
141 135
142void BreakPointModel::OnResumed() 136void BreakPointModel::OnResumed()
@@ -147,7 +141,7 @@ void BreakPointModel::OnResumed()
147 141
148 at_breakpoint = context->at_breakpoint; 142 at_breakpoint = context->at_breakpoint;
149 emit dataChanged(createIndex(static_cast<int>(active_breakpoint), 0), 143 emit dataChanged(createIndex(static_cast<int>(active_breakpoint), 0),
150 createIndex(static_cast<int>(active_breakpoint), 1)); 144 createIndex(static_cast<int>(active_breakpoint), 0));
151 active_breakpoint = context->active_breakpoint; 145 active_breakpoint = context->active_breakpoint;
152} 146}
153 147
@@ -165,13 +159,15 @@ GraphicsBreakPointsWidget::GraphicsBreakPointsWidget(std::shared_ptr<Pica::Debug
165 159
166 breakpoint_model = new BreakPointModel(debug_context, this); 160 breakpoint_model = new BreakPointModel(debug_context, this);
167 breakpoint_list = new QTreeView; 161 breakpoint_list = new QTreeView;
162 breakpoint_list->setRootIsDecorated(false);
163 breakpoint_list->setHeaderHidden(true);
168 breakpoint_list->setModel(breakpoint_model); 164 breakpoint_list->setModel(breakpoint_model);
169 165
170 toggle_breakpoint_button = new QPushButton(tr("Enable"));
171 toggle_breakpoint_button->setEnabled(false);
172
173 qRegisterMetaType<Pica::DebugContext::Event>("Pica::DebugContext::Event"); 166 qRegisterMetaType<Pica::DebugContext::Event>("Pica::DebugContext::Event");
174 167
168 connect(breakpoint_list, SIGNAL(doubleClicked(const QModelIndex&)),
169 this, SLOT(OnItemDoubleClicked(const QModelIndex&)));
170
175 connect(resume_button, SIGNAL(clicked()), this, SLOT(OnResumeRequested())); 171 connect(resume_button, SIGNAL(clicked()), this, SLOT(OnResumeRequested()));
176 172
177 connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event,void*)), 173 connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event,void*)),
@@ -187,11 +183,6 @@ GraphicsBreakPointsWidget::GraphicsBreakPointsWidget(std::shared_ptr<Pica::Debug
187 connect(this, SIGNAL(BreakPointsChanged(const QModelIndex&,const QModelIndex&)), 183 connect(this, SIGNAL(BreakPointsChanged(const QModelIndex&,const QModelIndex&)),
188 breakpoint_model, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&))); 184 breakpoint_model, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)));
189 185
190 connect(breakpoint_list->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
191 this, SLOT(OnBreakpointSelectionChanged(QModelIndex)));
192
193 connect(toggle_breakpoint_button, SIGNAL(clicked()), this, SLOT(OnToggleBreakpointEnabled()));
194
195 QWidget* main_widget = new QWidget; 186 QWidget* main_widget = new QWidget;
196 auto main_layout = new QVBoxLayout; 187 auto main_layout = new QVBoxLayout;
197 { 188 {
@@ -201,7 +192,6 @@ GraphicsBreakPointsWidget::GraphicsBreakPointsWidget(std::shared_ptr<Pica::Debug
201 main_layout->addLayout(sub_layout); 192 main_layout->addLayout(sub_layout);
202 } 193 }
203 main_layout->addWidget(breakpoint_list); 194 main_layout->addWidget(breakpoint_list);
204 main_layout->addWidget(toggle_breakpoint_button);
205 main_widget->setLayout(main_layout); 195 main_widget->setLayout(main_layout);
206 196
207 setWidget(main_widget); 197 setWidget(main_widget);
@@ -237,32 +227,15 @@ void GraphicsBreakPointsWidget::OnResumeRequested()
237 context->Resume(); 227 context->Resume();
238} 228}
239 229
240void GraphicsBreakPointsWidget::OnBreakpointSelectionChanged(const QModelIndex& index) 230void GraphicsBreakPointsWidget::OnItemDoubleClicked(const QModelIndex& index)
241{ 231{
242 if (!index.isValid()) { 232 if (!index.isValid())
243 toggle_breakpoint_button->setEnabled(false);
244 return; 233 return;
245 }
246 234
247 toggle_breakpoint_button->setEnabled(true); 235 QModelIndex check_index = breakpoint_list->model()->index(index.row(), 0);
248 UpdateToggleBreakpointButton(index); 236 QVariant enabled = breakpoint_list->model()->data(check_index, Qt::CheckStateRole);
249} 237 QVariant new_state = Qt::Unchecked;
250 238 if (enabled == Qt::Unchecked)
251void GraphicsBreakPointsWidget::OnToggleBreakpointEnabled() 239 new_state = Qt::Checked;
252{ 240 breakpoint_list->model()->setData(check_index, new_state, Qt::CheckStateRole);
253 QModelIndex index = breakpoint_list->selectionModel()->currentIndex();
254 bool new_state = !(breakpoint_model->data(index, BreakPointModel::Role_IsEnabled).toBool());
255
256 breakpoint_model->setData(index, new_state,
257 BreakPointModel::Role_IsEnabled);
258 UpdateToggleBreakpointButton(index);
259}
260
261void GraphicsBreakPointsWidget::UpdateToggleBreakpointButton(const QModelIndex& index)
262{
263 if (true == breakpoint_model->data(index, BreakPointModel::Role_IsEnabled).toBool()) {
264 toggle_breakpoint_button->setText(tr("Disable"));
265 } else {
266 toggle_breakpoint_button->setText(tr("Enable"));
267 }
268} 241}
diff --git a/src/citra_qt/debugger/graphics_breakpoints.h b/src/citra_qt/debugger/graphics_breakpoints.h
index 5b9ba324e..d900729da 100644
--- a/src/citra_qt/debugger/graphics_breakpoints.h
+++ b/src/citra_qt/debugger/graphics_breakpoints.h
@@ -31,10 +31,9 @@ public:
31 31
32public slots: 32public slots:
33 void OnBreakPointHit(Pica::DebugContext::Event event, void* data); 33 void OnBreakPointHit(Pica::DebugContext::Event event, void* data);
34 void OnItemDoubleClicked(const QModelIndex&);
34 void OnResumeRequested(); 35 void OnResumeRequested();
35 void OnResumed(); 36 void OnResumed();
36 void OnBreakpointSelectionChanged(const QModelIndex&);
37 void OnToggleBreakpointEnabled();
38 37
39signals: 38signals:
40 void Resumed(); 39 void Resumed();
@@ -42,11 +41,8 @@ signals:
42 void BreakPointsChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); 41 void BreakPointsChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
43 42
44private: 43private:
45 void UpdateToggleBreakpointButton(const QModelIndex& index);
46
47 QLabel* status_text; 44 QLabel* status_text;
48 QPushButton* resume_button; 45 QPushButton* resume_button;
49 QPushButton* toggle_breakpoint_button;
50 46
51 BreakPointModel* breakpoint_model; 47 BreakPointModel* breakpoint_model;
52 QTreeView* breakpoint_list; 48 QTreeView* breakpoint_list;
diff --git a/src/citra_qt/debugger/graphics_breakpoints_p.h b/src/citra_qt/debugger/graphics_breakpoints_p.h
index 34e72e859..00d8d5101 100644
--- a/src/citra_qt/debugger/graphics_breakpoints_p.h
+++ b/src/citra_qt/debugger/graphics_breakpoints_p.h
@@ -23,7 +23,7 @@ public:
23 int columnCount(const QModelIndex& parent = QModelIndex()) const override; 23 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
24 int rowCount(const QModelIndex& parent = QModelIndex()) const override; 24 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
25 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; 25 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
26 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; 26 Qt::ItemFlags flags(const QModelIndex &index) const;
27 27
28 bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; 28 bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
29 29