blob: 140841d459d0cc60068e4d255ee97ec965cf29b1 [file] [log] [blame]
chudy@google.com902ebe52012-06-29 14:21:22 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
chudy@google.com902ebe52012-06-29 14:21:22 +00008#include "SkDebuggerGUI.h"
chudy@google.combbad34d2012-08-13 14:26:36 +00009#include "SkGraphics.h"
scroggo@google.comb4467e62012-11-06 23:10:09 +000010#include "SkImageDecoder.h"
chudy@google.com902ebe52012-06-29 14:21:22 +000011#include <QListWidgetItem>
12
13SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
chudy@google.comc432f002012-07-10 13:19:25 +000014 QMainWindow(parent)
chudy@google.com2d537a12012-07-31 12:49:52 +000015 , fCentralWidget(this)
16 , fStatusBar(this)
17 , fToolBar(this)
chudy@google.comc432f002012-07-10 13:19:25 +000018 , fActionOpen(this)
19 , fActionBreakpoint(this)
20 , fActionCancel(this)
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000021 , fActionClearBreakpoints(this)
chudy@google.come504de02012-07-16 18:35:23 +000022 , fActionClearDeletes(this)
chudy@google.comc432f002012-07-10 13:19:25 +000023 , fActionClose(this)
chudy@google.come504de02012-07-16 18:35:23 +000024 , fActionCreateBreakpoint(this)
chudy@google.comc432f002012-07-10 13:19:25 +000025 , fActionDelete(this)
26 , fActionDirectory(this)
27 , fActionGoToLine(this)
28 , fActionInspector(this)
29 , fActionPlay(this)
chudy@google.come504de02012-07-16 18:35:23 +000030 , fActionPause(this)
chudy@google.comc432f002012-07-10 13:19:25 +000031 , fActionRewind(this)
chudy@google.com0ab03392012-07-28 20:16:11 +000032 , fActionSave(this)
33 , fActionSaveAs(this)
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000034 , fActionShowDeletes(this)
chudy@google.comc432f002012-07-10 13:19:25 +000035 , fActionStepBack(this)
36 , fActionStepForward(this)
chudy@google.coma1226312012-07-26 20:26:44 +000037 , fActionZoomIn(this)
38 , fActionZoomOut(this)
39 , fMapper(this)
chudy@google.comc432f002012-07-10 13:19:25 +000040 , fListWidget(&fCentralWidget)
41 , fDirectoryWidget(&fCentralWidget)
chudy@google.com607357f2012-08-07 16:12:23 +000042 , fCanvasWidget(this, &fDebugger)
chudy@google.comc432f002012-07-10 13:19:25 +000043 , fMenuBar(this)
44 , fMenuFile(this)
45 , fMenuNavigate(this)
46 , fMenuView(this)
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000047 , fBreakpointsActivated(false)
48 , fDeletesActivated(false)
49 , fPause(false)
chudy@google.comd3058f52012-07-19 13:41:27 +000050 , fLoading(false)
chudy@google.comc432f002012-07-10 13:19:25 +000051{
chudy@google.com902ebe52012-06-29 14:21:22 +000052 setupUi(this);
chudy@google.comea5488b2012-07-26 19:38:22 +000053 connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(registerListClick(QListWidgetItem *)));
chudy@google.comc432f002012-07-10 13:19:25 +000054 connect(&fActionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
chudy@google.comea5488b2012-07-26 19:38:22 +000055 connect(&fActionDirectory, SIGNAL(triggered()), this, SLOT(toggleDirectory()));
56 connect(&fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(loadFile(QListWidgetItem *)));
chudy@google.comc432f002012-07-10 13:19:25 +000057 connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete()));
chudy@google.comea5488b2012-07-26 19:38:22 +000058 connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(toggleBreakpoint()));
chudy@google.comc432f002012-07-10 13:19:25 +000059 connect(&fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind()));
60 connect(&fActionPlay, SIGNAL(triggered()), this, SLOT(actionPlay()));
61 connect(&fActionStepBack, SIGNAL(triggered()), this, SLOT(actionStepBack()));
chudy@google.comea5488b2012-07-26 19:38:22 +000062 connect(&fActionStepForward, SIGNAL(triggered()), this, SLOT(actionStepForward()));
63 connect(&fActionBreakpoint, SIGNAL(triggered()), this, SLOT(actionBreakpoints()));
64 connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionInspector()));
65 connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionSettings()));
66 connect(&fFilter, SIGNAL(activated(QString)), this, SLOT(toggleFilter(QString)));
chudy@google.comc432f002012-07-10 13:19:25 +000067 connect(&fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel()));
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000068 connect(&fActionClearBreakpoints, SIGNAL(triggered()), this, SLOT(actionClearBreakpoints()));
69 connect(&fActionClearDeletes, SIGNAL(triggered()), this, SLOT(actionClearDeletes()));
chudy@google.comc432f002012-07-10 13:19:25 +000070 connect(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose()));
chudy@google.comea5488b2012-07-26 19:38:22 +000071 connect(fSettingsWidget.getVisibilityButton(), SIGNAL(toggled(bool)), this, SLOT(actionCommandFilter()));
72 connect(fSettingsWidget.getGLCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionGLWidget(bool)));
73 connect(fSettingsWidget.getRasterCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionRasterWidget(bool)));
74 connect(&fActionPause, SIGNAL(toggled(bool)), this, SLOT(pauseDrawing(bool)));
chudy@google.come504de02012-07-16 18:35:23 +000075 connect(&fActionCreateBreakpoint, SIGNAL(activated()), this, SLOT(toggleBreakpoint()));
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000076 connect(&fActionShowDeletes, SIGNAL(triggered()), this, SLOT(showDeletes()));
chudy@google.comea5488b2012-07-26 19:38:22 +000077 connect(&fCanvasWidget, SIGNAL(hitChanged(int)), this, SLOT(selectCommand(int)));
78 connect(&fCanvasWidget, SIGNAL(hitChanged(int)), &fSettingsWidget, SLOT(updateHit(int)));
79 connect(&fCanvasWidget, SIGNAL(scaleFactorChanged(float)), this, SLOT(actionScale(float)));
80 connect(&fCanvasWidget, SIGNAL(commandChanged(int)), &fSettingsWidget, SLOT(updateCommand(int)));
chudy@google.com0ab03392012-07-28 20:16:11 +000081 connect(&fActionSaveAs, SIGNAL(triggered()), this, SLOT(actionSaveAs()));
82 connect(&fActionSave, SIGNAL(triggered()), this, SLOT(actionSave()));
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000083
chudy@google.coma1226312012-07-26 20:26:44 +000084 fMapper.setMapping(&fActionZoomIn, 1);
85 fMapper.setMapping(&fActionZoomOut, -1);
86
87 connect(&fActionZoomIn, SIGNAL(triggered()), &fMapper, SLOT(map()));
88 connect(&fActionZoomOut, SIGNAL(triggered()), &fMapper, SLOT(map()));
89 connect(&fMapper, SIGNAL(mapped(int)), &fCanvasWidget, SLOT(keyZoom(int)));
90
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000091 fInspectorWidget.setDisabled(true);
chudy@google.comd3058f52012-07-19 13:41:27 +000092 fMenuEdit.setDisabled(true);
93 fMenuNavigate.setDisabled(true);
94 fMenuView.setDisabled(true);
chudy@google.combbad34d2012-08-13 14:26:36 +000095
96 SkGraphics::Init();
chudy@google.com902ebe52012-06-29 14:21:22 +000097}
98
chudy@google.combbad34d2012-08-13 14:26:36 +000099SkDebuggerGUI::~SkDebuggerGUI() {
100 SkGraphics::Term();
101}
chudy@google.com902ebe52012-06-29 14:21:22 +0000102
103void SkDebuggerGUI::actionBreakpoints() {
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000104 fBreakpointsActivated = !fBreakpointsActivated;
chudy@google.comc432f002012-07-10 13:19:25 +0000105 for (int row = 0; row < fListWidget.count(); row++) {
106 QListWidgetItem *item = fListWidget.item(row);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000107 item->setHidden(item->checkState() == Qt::Unchecked && fBreakpointsActivated);
108 }
109}
chudy@google.com902ebe52012-06-29 14:21:22 +0000110
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000111void SkDebuggerGUI::showDeletes() {
112 fDeletesActivated = !fDeletesActivated;
113 for (int row = 0; row < fListWidget.count(); row++) {
114 QListWidgetItem *item = fListWidget.item(row);
chudy@google.com607357f2012-08-07 16:12:23 +0000115 item->setHidden(fDebugger.isCommandVisible(row)
116 && fDeletesActivated);
chudy@google.com902ebe52012-06-29 14:21:22 +0000117 }
118}
119
120void SkDebuggerGUI::actionCancel() {
chudy@google.comc432f002012-07-10 13:19:25 +0000121 for (int row = 0; row < fListWidget.count(); row++) {
122 fListWidget.item(row)->setHidden(false);
chudy@google.com902ebe52012-06-29 14:21:22 +0000123 }
124}
125
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000126void SkDebuggerGUI::actionClearBreakpoints() {
127 for (int row = 0; row < fListWidget.count(); row++) {
128 QListWidgetItem* item = fListWidget.item(row);
129 item->setCheckState(Qt::Unchecked);
130 item->setData(Qt::DecorationRole,
131 QPixmap(":/images/Icons/blank.png"));
132 }
133}
134
135void SkDebuggerGUI::actionClearDeletes() {
136 for (int row = 0; row < fListWidget.count(); row++) {
137 QListWidgetItem* item = fListWidget.item(row);
138 item->setData(Qt::UserRole + 2, QPixmap(":/images/Icons/blank.png"));
chudy@google.com607357f2012-08-07 16:12:23 +0000139 fDebugger.setCommandVisible(row, true);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000140 }
141 if (fPause) {
142 fCanvasWidget.drawTo(fPausedRow);
143 } else {
144 fCanvasWidget.drawTo(fListWidget.currentRow());
145 }
146}
147
chudy@google.com902ebe52012-06-29 14:21:22 +0000148void SkDebuggerGUI::actionCommandFilter() {
chudy@google.com607357f2012-08-07 16:12:23 +0000149 fDebugger.highlightCurrentCommand(
chudy@google.comc432f002012-07-10 13:19:25 +0000150 fSettingsWidget.getVisibilityButton()->isChecked());
151 fCanvasWidget.drawTo(fListWidget.currentRow());
chudy@google.com902ebe52012-06-29 14:21:22 +0000152}
153
154void SkDebuggerGUI::actionClose() {
155 this->close();
156}
157
158void SkDebuggerGUI::actionDelete() {
chudy@google.comc432f002012-07-10 13:19:25 +0000159 int currentRow = fListWidget.currentRow();
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000160 QListWidgetItem* item = fListWidget.currentItem();
161
chudy@google.com607357f2012-08-07 16:12:23 +0000162 if (fDebugger.isCommandVisible(currentRow)) {
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000163 item->setData(Qt::UserRole + 2, QPixmap(":/images/Icons/delete.png"));
chudy@google.com607357f2012-08-07 16:12:23 +0000164 fDebugger.setCommandVisible(currentRow, false);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000165 } else {
166 item->setData(Qt::UserRole + 2, QPixmap(":/images/Icons/blank.png"));
chudy@google.com607357f2012-08-07 16:12:23 +0000167 fDebugger.setCommandVisible(currentRow, true);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000168 }
169
chudy@google.come504de02012-07-16 18:35:23 +0000170 if (fPause) {
171 fCanvasWidget.drawTo(fPausedRow);
172 } else {
173 fCanvasWidget.drawTo(currentRow);
174 }
chudy@google.com902ebe52012-06-29 14:21:22 +0000175}
176
chudy@google.comea5488b2012-07-26 19:38:22 +0000177void SkDebuggerGUI::actionGLWidget(bool isToggled) {
178 fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kGPU_WidgetType, !isToggled);
179}
180
chudy@google.com902ebe52012-06-29 14:21:22 +0000181void SkDebuggerGUI::actionInspector() {
chudy@google.comc432f002012-07-10 13:19:25 +0000182 if (fInspectorWidget.isHidden()) {
183 fInspectorWidget.setHidden(false);
chudy@google.com902ebe52012-06-29 14:21:22 +0000184 } else {
chudy@google.comc432f002012-07-10 13:19:25 +0000185 fInspectorWidget.setHidden(true);
chudy@google.com902ebe52012-06-29 14:21:22 +0000186 }
187}
188
189void SkDebuggerGUI::actionPlay() {
chudy@google.comc432f002012-07-10 13:19:25 +0000190 for (int row = fListWidget.currentRow() + 1; row < fListWidget.count();
chudy@google.com7dcae672012-07-09 20:26:53 +0000191 row++) {
chudy@google.comc432f002012-07-10 13:19:25 +0000192 QListWidgetItem *item = fListWidget.item(row);
chudy@google.com902ebe52012-06-29 14:21:22 +0000193 if (item->checkState() == Qt::Checked) {
chudy@google.comc432f002012-07-10 13:19:25 +0000194 fListWidget.setCurrentItem(item);
chudy@google.com902ebe52012-06-29 14:21:22 +0000195 return;
196 }
197 }
chudy@google.comc432f002012-07-10 13:19:25 +0000198 fListWidget.setCurrentRow(fListWidget.count() - 1);
chudy@google.com902ebe52012-06-29 14:21:22 +0000199}
200
chudy@google.comea5488b2012-07-26 19:38:22 +0000201void SkDebuggerGUI::actionRasterWidget(bool isToggled) {
202 fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kRaster_8888_WidgetType, !isToggled);
203}
204
chudy@google.com902ebe52012-06-29 14:21:22 +0000205void SkDebuggerGUI::actionRewind() {
chudy@google.come504de02012-07-16 18:35:23 +0000206 fListWidget.setCurrentRow(0);
chudy@google.com902ebe52012-06-29 14:21:22 +0000207}
208
chudy@google.com0ab03392012-07-28 20:16:11 +0000209void SkDebuggerGUI::actionSave() {
210 QString filename;
211 filename.append(fPath);
212 filename.append("/");
213 filename.append(fDirectoryWidget.currentItem()->text());
214 saveToFile(filename);
215}
216
217void SkDebuggerGUI::actionSaveAs() {
218 QString filename = QFileDialog::getSaveFileName(this, "Save File", "",
219 "Skia Picture (*skp)");
chudy@google.com38b08ce2012-07-28 23:26:10 +0000220 if (!filename.endsWith(".skp", Qt::CaseInsensitive)) {
chudy@google.com0ab03392012-07-28 20:16:11 +0000221 filename.append(".skp");
222 }
223 saveToFile(filename);
224}
225
chudy@google.com7dcae672012-07-09 20:26:53 +0000226void SkDebuggerGUI::actionScale(float scaleFactor) {
chudy@google.comc432f002012-07-10 13:19:25 +0000227 fSettingsWidget.setZoomText(scaleFactor);
chudy@google.com7dcae672012-07-09 20:26:53 +0000228}
229
chudy@google.com902ebe52012-06-29 14:21:22 +0000230void SkDebuggerGUI::actionSettings() {
chudy@google.comc432f002012-07-10 13:19:25 +0000231 if (fSettingsWidget.isHidden()) {
232 fSettingsWidget.setHidden(false);
chudy@google.com902ebe52012-06-29 14:21:22 +0000233 } else {
chudy@google.comc432f002012-07-10 13:19:25 +0000234 fSettingsWidget.setHidden(true);
chudy@google.com902ebe52012-06-29 14:21:22 +0000235 }
236}
237
238void SkDebuggerGUI::actionStepBack() {
chudy@google.comc432f002012-07-10 13:19:25 +0000239 int currentRow = fListWidget.currentRow();
chudy@google.com902ebe52012-06-29 14:21:22 +0000240 if (currentRow != 0) {
chudy@google.comc432f002012-07-10 13:19:25 +0000241 fListWidget.setCurrentRow(currentRow - 1);
chudy@google.com902ebe52012-06-29 14:21:22 +0000242 }
243}
244
245void SkDebuggerGUI::actionStepForward() {
chudy@google.comc432f002012-07-10 13:19:25 +0000246 int currentRow = fListWidget.currentRow();
chudy@google.com902ebe52012-06-29 14:21:22 +0000247 QString curRow = QString::number(currentRow);
chudy@google.comc432f002012-07-10 13:19:25 +0000248 QString curCount = QString::number(fListWidget.count());
249 if (currentRow < fListWidget.count() - 1) {
250 fListWidget.setCurrentRow(currentRow + 1);
chudy@google.com902ebe52012-06-29 14:21:22 +0000251 }
252}
253
chudy@google.coma9e937c2012-08-03 17:32:05 +0000254void SkDebuggerGUI::drawComplete() {
chudy@google.com607357f2012-08-07 16:12:23 +0000255 fInspectorWidget.setMatrix(fDebugger.getCurrentMatrix());
256 fInspectorWidget.setClip(fDebugger.getCurrentClip());
chudy@google.coma9e937c2012-08-03 17:32:05 +0000257}
258
chudy@google.com0ab03392012-07-28 20:16:11 +0000259void SkDebuggerGUI::saveToFile(QString filename) {
260 SkFILEWStream file(filename.toAscii());
chudy@google.com607357f2012-08-07 16:12:23 +0000261 fDebugger.makePicture()->serialize(&file);
chudy@google.com0ab03392012-07-28 20:16:11 +0000262}
263
chudy@google.com902ebe52012-06-29 14:21:22 +0000264void SkDebuggerGUI::loadFile(QListWidgetItem *item) {
265 if (fDirectoryWidgetActive) {
266 QString fileName;
267 fileName.append(fPath);
268 fileName.append("/");
269 fileName.append(item->text());
270 loadPicture(fileName);
271 }
272}
273
274void SkDebuggerGUI::openFile() {
chudy@google.com7dcae672012-07-09 20:26:53 +0000275 QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "",
276 tr("Files (*.*)"));
chudy@google.com902ebe52012-06-29 14:21:22 +0000277 fDirectoryWidgetActive = false;
278 if (!fileName.isNull()) {
chudy@google.com902ebe52012-06-29 14:21:22 +0000279 QFileInfo pathInfo(fileName);
280 fPath = pathInfo.path();
281 loadPicture(fileName);
282 setupDirectoryWidget();
283 }
chudy@google.com902ebe52012-06-29 14:21:22 +0000284 fDirectoryWidgetActive = true;
285}
286
chudy@google.comc432f002012-07-10 13:19:25 +0000287void SkDebuggerGUI::pauseDrawing(bool isPaused) {
chudy@google.com607357f2012-08-07 16:12:23 +0000288 fPause = isPaused;
289 fPausedRow = fListWidget.currentRow();
290 fCanvasWidget.drawTo(fPausedRow);
chudy@google.com7dcae672012-07-09 20:26:53 +0000291}
292
chudy@google.com902ebe52012-06-29 14:21:22 +0000293void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
chudy@google.comd3058f52012-07-19 13:41:27 +0000294 if(!fLoading) {
295 int currentRow = fListWidget.currentRow();
chudy@google.comd3058f52012-07-19 13:41:27 +0000296
chudy@google.comea5488b2012-07-26 19:38:22 +0000297 if (currentRow != -1) {
298 if (!fPause) {
299 fCanvasWidget.drawTo(currentRow);
chudy@google.comd3058f52012-07-19 13:41:27 +0000300 }
chudy@google.com97cee972012-08-07 20:41:37 +0000301 SkTDArray<SkString*> *currInfo = fDebugger.getCommandInfo(
chudy@google.comea5488b2012-07-26 19:38:22 +0000302 currentRow);
303
304 /* TODO(chudy): Add command type before parameters. Rename v
305 * to something more informative. */
chudy@google.com97cee972012-08-07 20:41:37 +0000306 if (currInfo) {
chudy@google.comea5488b2012-07-26 19:38:22 +0000307 QString info;
308 info.append("<b>Parameters: </b><br/>");
chudy@google.com97cee972012-08-07 20:41:37 +0000309 for (int i = 0; i < currInfo->count(); i++) {
310
311 info.append(QString((*currInfo)[i]->c_str()));
chudy@google.comea5488b2012-07-26 19:38:22 +0000312 info.append("<br/>");
313 }
chudy@google.com6bd109a2012-08-14 19:34:13 +0000314 fInspectorWidget.setText(info, SkInspectorWidget::kDetail_TabType);
chudy@google.comea5488b2012-07-26 19:38:22 +0000315 fInspectorWidget.setDisabled(false);
chudy@google.comea5488b2012-07-26 19:38:22 +0000316 }
chudy@google.comd3058f52012-07-19 13:41:27 +0000317 }
chudy@google.comea5488b2012-07-26 19:38:22 +0000318
chudy@google.com902ebe52012-06-29 14:21:22 +0000319 }
320}
321
chudy@google.com9ca9bfe2012-07-12 21:58:14 +0000322void SkDebuggerGUI::selectCommand(int command) {
323 if (fPause) {
324 fListWidget.setCurrentRow(command);
325 }
326}
327
chudy@google.com902ebe52012-06-29 14:21:22 +0000328void SkDebuggerGUI::toggleBreakpoint() {
chudy@google.comc432f002012-07-10 13:19:25 +0000329 QListWidgetItem* item = fListWidget.currentItem();
chudy@google.com902ebe52012-06-29 14:21:22 +0000330 if (item->checkState() == Qt::Unchecked) {
331 item->setCheckState(Qt::Checked);
chudy@google.come565de42012-07-12 14:15:54 +0000332 item->setData(Qt::DecorationRole,
333 QPixmap(":/images/Icons/breakpoint_16x16.png"));
chudy@google.com902ebe52012-06-29 14:21:22 +0000334 } else {
chudy@google.com902ebe52012-06-29 14:21:22 +0000335 item->setCheckState(Qt::Unchecked);
chudy@google.come565de42012-07-12 14:15:54 +0000336 item->setData(Qt::DecorationRole,
337 QPixmap(":/images/Icons/blank.png"));
chudy@google.com902ebe52012-06-29 14:21:22 +0000338 }
339}
340
341void SkDebuggerGUI::toggleDirectory() {
chudy@google.com607357f2012-08-07 16:12:23 +0000342 fDirectoryWidget.setHidden(!fDirectoryWidget.isHidden());
chudy@google.com902ebe52012-06-29 14:21:22 +0000343}
344
345void SkDebuggerGUI::toggleFilter(QString string) {
chudy@google.comc432f002012-07-10 13:19:25 +0000346 for (int row = 0; row < fListWidget.count(); row++) {
347 QListWidgetItem *item = fListWidget.item(row);
chudy@google.com607357f2012-08-07 16:12:23 +0000348 item->setHidden(item->text() != string);
chudy@google.com902ebe52012-06-29 14:21:22 +0000349 }
350}
351
352void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
353 QIcon windowIcon;
chudy@google.com7dcae672012-07-09 20:26:53 +0000354 windowIcon.addFile(QString::fromUtf8(":/images/Icons/skia.png"), QSize(),
355 QIcon::Normal, QIcon::Off);
chudy@google.com902ebe52012-06-29 14:21:22 +0000356 SkDebuggerGUI->setObjectName(QString::fromUtf8("SkDebuggerGUI"));
357 SkDebuggerGUI->resize(1200, 1000);
358 SkDebuggerGUI->setWindowIcon(windowIcon);
chudy@google.comc432f002012-07-10 13:19:25 +0000359 SkDebuggerGUI->setWindowTitle("Skia Debugger");
chudy@google.com902ebe52012-06-29 14:21:22 +0000360
chudy@google.come504de02012-07-16 18:35:23 +0000361 fActionOpen.setShortcuts(QKeySequence::Open);
chudy@google.comc432f002012-07-10 13:19:25 +0000362 fActionOpen.setText("Open");
chudy@google.com902ebe52012-06-29 14:21:22 +0000363
364 QIcon breakpoint;
chudy@google.com7dcae672012-07-09 20:26:53 +0000365 breakpoint.addFile(QString::fromUtf8(":/images/Icons/breakpoint.png"),
366 QSize(), QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000367 fActionBreakpoint.setShortcut(QKeySequence(tr("Ctrl+B")));
chudy@google.comc432f002012-07-10 13:19:25 +0000368 fActionBreakpoint.setIcon(breakpoint);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000369 fActionBreakpoint.setText("Breakpoints");
chudy@google.com902ebe52012-06-29 14:21:22 +0000370
371 QIcon cancel;
chudy@google.come504de02012-07-16 18:35:23 +0000372 cancel.addFile(QString::fromUtf8(":/images/Ico/reload.png"), QSize(),
chudy@google.com7dcae672012-07-09 20:26:53 +0000373 QIcon::Normal, QIcon::Off);
chudy@google.comc432f002012-07-10 13:19:25 +0000374 fActionCancel.setIcon(cancel);
375 fActionCancel.setText("Clear Filter");
chudy@google.com902ebe52012-06-29 14:21:22 +0000376
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000377 fActionClearBreakpoints.setShortcut(QKeySequence(tr("Alt+B")));
378 fActionClearBreakpoints.setText("Clear Breakpoints");
379
380 fActionClearDeletes.setShortcut(QKeySequence(tr("Alt+X")));
381 fActionClearDeletes.setText("Clear Deletes");
382
chudy@google.come504de02012-07-16 18:35:23 +0000383 fActionClose.setShortcuts(QKeySequence::Quit);
chudy@google.comc432f002012-07-10 13:19:25 +0000384 fActionClose.setText("Exit");
chudy@google.com902ebe52012-06-29 14:21:22 +0000385
chudy@google.come504de02012-07-16 18:35:23 +0000386 fActionCreateBreakpoint.setShortcut(QKeySequence(tr("B")));
387 fActionCreateBreakpoint.setText("Set Breakpoint");
388
389 fActionDelete.setShortcut(QKeySequence(tr("X")));
chudy@google.comc432f002012-07-10 13:19:25 +0000390 fActionDelete.setText("Delete Command");
chudy@google.com902ebe52012-06-29 14:21:22 +0000391
chudy@google.come504de02012-07-16 18:35:23 +0000392 fActionDirectory.setShortcut(QKeySequence(tr("Ctrl+D")));
393 fActionDirectory.setText("Directory");
chudy@google.com902ebe52012-06-29 14:21:22 +0000394
chudy@google.comc432f002012-07-10 13:19:25 +0000395 QIcon inspector;
chudy@google.come504de02012-07-16 18:35:23 +0000396 inspector.addFile(QString::fromUtf8(":/images/Ico/inspector.png"),
chudy@google.comc432f002012-07-10 13:19:25 +0000397 QSize(), QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000398 fActionInspector.setShortcut(QKeySequence(tr("Ctrl+I")));
chudy@google.comc432f002012-07-10 13:19:25 +0000399 fActionInspector.setIcon(inspector);
chudy@google.come504de02012-07-16 18:35:23 +0000400 fActionInspector.setText("Inspector");
chudy@google.com902ebe52012-06-29 14:21:22 +0000401
chudy@google.comc432f002012-07-10 13:19:25 +0000402 QIcon play;
chudy@google.come504de02012-07-16 18:35:23 +0000403 play.addFile(QString::fromUtf8(":/images/Ico/play.png"), QSize(),
chudy@google.comc432f002012-07-10 13:19:25 +0000404 QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000405 fActionPlay.setShortcut(QKeySequence(tr("Ctrl+P")));
chudy@google.comc432f002012-07-10 13:19:25 +0000406 fActionPlay.setIcon(play);
407 fActionPlay.setText("Play");
chudy@google.com902ebe52012-06-29 14:21:22 +0000408
chudy@google.come504de02012-07-16 18:35:23 +0000409 QIcon pause;
410 pause.addFile(QString::fromUtf8(":/images/Ico/pause.png"), QSize(),
chudy@google.comc432f002012-07-10 13:19:25 +0000411 QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000412 fActionPause.setShortcut(QKeySequence(tr("Space")));
413 fActionPause.setCheckable(true);
414 fActionPause.setIcon(pause);
415 fActionPause.setText("Pause");
416
chudy@google.comc432f002012-07-10 13:19:25 +0000417 QIcon rewind;
chudy@google.come504de02012-07-16 18:35:23 +0000418 rewind.addFile(QString::fromUtf8(":/images/Ico/rewind.png"), QSize(),
chudy@google.comc432f002012-07-10 13:19:25 +0000419 QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000420 fActionRewind.setShortcut(QKeySequence(tr("Ctrl+R")));
chudy@google.comc432f002012-07-10 13:19:25 +0000421 fActionRewind.setIcon(rewind);
422 fActionRewind.setText("Rewind");
chudy@google.com902ebe52012-06-29 14:21:22 +0000423
chudy@google.com0ab03392012-07-28 20:16:11 +0000424 fActionSave.setShortcut(QKeySequence::Save);
425 fActionSave.setText("Save");
426 fActionSave.setDisabled(true);
427 fActionSaveAs.setShortcut(QKeySequence::SaveAs);
428 fActionSaveAs.setText("Save As");
429 fActionSaveAs.setDisabled(true);
430
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000431 fActionShowDeletes.setShortcut(QKeySequence(tr("Ctrl+X")));
432 fActionShowDeletes.setText("Deleted Commands");
433
chudy@google.comc432f002012-07-10 13:19:25 +0000434 QIcon stepBack;
chudy@google.come504de02012-07-16 18:35:23 +0000435 stepBack.addFile(QString::fromUtf8(":/images/Ico/previous.png"), QSize(),
chudy@google.comc432f002012-07-10 13:19:25 +0000436 QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000437 fActionStepBack.setShortcut(QKeySequence(tr("[")));
chudy@google.comc432f002012-07-10 13:19:25 +0000438 fActionStepBack.setIcon(stepBack);
439 fActionStepBack.setText("Step Back");
chudy@google.com902ebe52012-06-29 14:21:22 +0000440
chudy@google.comc432f002012-07-10 13:19:25 +0000441 QIcon stepForward;
chudy@google.come504de02012-07-16 18:35:23 +0000442 stepForward.addFile(QString::fromUtf8(":/images/Ico/next.png"),
chudy@google.comc432f002012-07-10 13:19:25 +0000443 QSize(), QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000444 fActionStepForward.setShortcut(QKeySequence(tr("]")));
chudy@google.comc432f002012-07-10 13:19:25 +0000445 fActionStepForward.setIcon(stepForward);
446 fActionStepForward.setText("Step Forward");
447
chudy@google.coma1226312012-07-26 20:26:44 +0000448 fActionZoomIn.setShortcut(QKeySequence(tr("Ctrl+=")));
449 fActionZoomIn.setText("Zoom In");
450 fActionZoomOut.setShortcut(QKeySequence(tr("Ctrl+-")));
451 fActionZoomOut.setText("Zoom Out");
452
chudy@google.comc432f002012-07-10 13:19:25 +0000453 fListWidget.setItemDelegate(new SkListWidget(&fListWidget));
454 fListWidget.setObjectName(QString::fromUtf8("listWidget"));
455 fListWidget.setMaximumWidth(250);
456
457 fFilter.addItem("--Filter By Available Commands--");
458
459 fDirectoryWidget.setMaximumWidth(250);
460 fDirectoryWidget.setStyleSheet("QListWidget::Item {padding: 5px;}");
461
462 fCanvasWidget.setSizePolicy(QSizePolicy::Expanding,
chudy@google.com7dcae672012-07-09 20:26:53 +0000463 QSizePolicy::Expanding);
chudy@google.com902ebe52012-06-29 14:21:22 +0000464
chudy@google.comc432f002012-07-10 13:19:25 +0000465 fInspectorWidget.setSizePolicy(QSizePolicy::Expanding,
chudy@google.com7dcae672012-07-09 20:26:53 +0000466 QSizePolicy::Expanding);
chudy@google.comc432f002012-07-10 13:19:25 +0000467 fInspectorWidget.setMaximumHeight(300);
chudy@google.com902ebe52012-06-29 14:21:22 +0000468
chudy@google.comc432f002012-07-10 13:19:25 +0000469 fSettingsWidget.setSizePolicy(QSizePolicy::Expanding,
470 QSizePolicy::Expanding);
471 fSettingsWidget.setMaximumWidth(250);
chudy@google.com902ebe52012-06-29 14:21:22 +0000472
chudy@google.comc432f002012-07-10 13:19:25 +0000473 fLeftColumnLayout.setSpacing(6);
474 fLeftColumnLayout.addWidget(&fListWidget);
475 fLeftColumnLayout.addWidget(&fDirectoryWidget);
chudy@google.com902ebe52012-06-29 14:21:22 +0000476
chudy@google.comc432f002012-07-10 13:19:25 +0000477 fCanvasAndSettingsLayout.setSpacing(6);
478 fCanvasAndSettingsLayout.addWidget(&fCanvasWidget);
479 fCanvasAndSettingsLayout.addWidget(&fSettingsWidget);
chudy@google.com902ebe52012-06-29 14:21:22 +0000480
chudy@google.comc432f002012-07-10 13:19:25 +0000481 fMainAndRightColumnLayout.setSpacing(6);
482 fMainAndRightColumnLayout.addLayout(&fCanvasAndSettingsLayout);
483 fMainAndRightColumnLayout.addWidget(&fInspectorWidget);
chudy@google.com902ebe52012-06-29 14:21:22 +0000484
chudy@google.com2d537a12012-07-31 12:49:52 +0000485 fCentralWidget.setLayout(&fContainerLayout);
chudy@google.comc432f002012-07-10 13:19:25 +0000486 fContainerLayout.setSpacing(6);
487 fContainerLayout.setContentsMargins(11, 11, 11, 11);
488 fContainerLayout.addLayout(&fLeftColumnLayout);
489 fContainerLayout.addLayout(&fMainAndRightColumnLayout);
490
491 SkDebuggerGUI->setCentralWidget(&fCentralWidget);
492 SkDebuggerGUI->setStatusBar(&fStatusBar);
493
chudy@google.come504de02012-07-16 18:35:23 +0000494 fToolBar.setIconSize(QSize(32, 32));
chudy@google.comc432f002012-07-10 13:19:25 +0000495 fToolBar.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
496 SkDebuggerGUI->addToolBar(Qt::TopToolBarArea, &fToolBar);
chudy@google.com902ebe52012-06-29 14:21:22 +0000497
chudy@google.com0ab03392012-07-28 20:16:11 +0000498 fSpacer.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
chudy@google.com902ebe52012-06-29 14:21:22 +0000499
chudy@google.comc432f002012-07-10 13:19:25 +0000500 fToolBar.addAction(&fActionRewind);
501 fToolBar.addAction(&fActionStepBack);
chudy@google.come504de02012-07-16 18:35:23 +0000502 fToolBar.addAction(&fActionPause);
chudy@google.comc432f002012-07-10 13:19:25 +0000503 fToolBar.addAction(&fActionStepForward);
504 fToolBar.addAction(&fActionPlay);
505 fToolBar.addSeparator();
chudy@google.come504de02012-07-16 18:35:23 +0000506 fToolBar.addAction(&fActionInspector);
chudy@google.comc432f002012-07-10 13:19:25 +0000507 fToolBar.addSeparator();
chudy@google.com0ab03392012-07-28 20:16:11 +0000508 fToolBar.addWidget(&fSpacer);
chudy@google.comc432f002012-07-10 13:19:25 +0000509 fToolBar.addWidget(&fFilter);
510 fToolBar.addAction(&fActionCancel);
chudy@google.com902ebe52012-06-29 14:21:22 +0000511
512 // TODO(chudy): Remove static call.
513 fDirectoryWidgetActive = false;
chudy@google.comea5488b2012-07-26 19:38:22 +0000514 fPath = "/usr/local/google/home/chudy/trunk-git/trunk/skp";
chudy@google.com902ebe52012-06-29 14:21:22 +0000515 setupDirectoryWidget();
516 fDirectoryWidgetActive = true;
517
chudy@google.com902ebe52012-06-29 14:21:22 +0000518 // Menu Bar
chudy@google.comc432f002012-07-10 13:19:25 +0000519 fMenuFile.setTitle("File");
520 fMenuFile.addAction(&fActionOpen);
chudy@google.com0ab03392012-07-28 20:16:11 +0000521 fMenuFile.addAction(&fActionSave);
522 fMenuFile.addAction(&fActionSaveAs);
chudy@google.comc432f002012-07-10 13:19:25 +0000523 fMenuFile.addAction(&fActionClose);
chudy@google.come504de02012-07-16 18:35:23 +0000524
525 fMenuEdit.setTitle("Edit");
526 fMenuEdit.addAction(&fActionDelete);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000527 fMenuEdit.addAction(&fActionClearDeletes);
528 fMenuEdit.addSeparator();
chudy@google.come504de02012-07-16 18:35:23 +0000529 fMenuEdit.addAction(&fActionCreateBreakpoint);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000530 fMenuEdit.addAction(&fActionClearBreakpoints);
chudy@google.come504de02012-07-16 18:35:23 +0000531
chudy@google.comc432f002012-07-10 13:19:25 +0000532 fMenuNavigate.setTitle("Navigate");
chudy@google.come504de02012-07-16 18:35:23 +0000533 fMenuNavigate.addAction(&fActionRewind);
534 fMenuNavigate.addAction(&fActionStepBack);
535 fMenuNavigate.addAction(&fActionStepForward);
536 fMenuNavigate.addAction(&fActionPlay);
537 fMenuNavigate.addAction(&fActionPause);
chudy@google.comc432f002012-07-10 13:19:25 +0000538 fMenuNavigate.addAction(&fActionGoToLine);
chudy@google.come504de02012-07-16 18:35:23 +0000539
chudy@google.comc432f002012-07-10 13:19:25 +0000540 fMenuView.setTitle("View");
chudy@google.come504de02012-07-16 18:35:23 +0000541 fMenuView.addAction(&fActionBreakpoint);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000542 fMenuView.addAction(&fActionShowDeletes);
chudy@google.coma1226312012-07-26 20:26:44 +0000543 fMenuView.addAction(&fActionZoomIn);
544 fMenuView.addAction(&fActionZoomOut);
chudy@google.come504de02012-07-16 18:35:23 +0000545
546 fMenuWindows.setTitle("Window");
547 fMenuWindows.addAction(&fActionInspector);
548 fMenuWindows.addAction(&fActionDirectory);
chudy@google.comc432f002012-07-10 13:19:25 +0000549
550 fActionGoToLine.setText("Go to Line...");
551 fActionGoToLine.setDisabled(true);
552 fMenuBar.addAction(fMenuFile.menuAction());
chudy@google.come504de02012-07-16 18:35:23 +0000553 fMenuBar.addAction(fMenuEdit.menuAction());
chudy@google.comc432f002012-07-10 13:19:25 +0000554 fMenuBar.addAction(fMenuView.menuAction());
555 fMenuBar.addAction(fMenuNavigate.menuAction());
chudy@google.come504de02012-07-16 18:35:23 +0000556 fMenuBar.addAction(fMenuWindows.menuAction());
chudy@google.com902ebe52012-06-29 14:21:22 +0000557
chudy@google.com7dcae672012-07-09 20:26:53 +0000558 fPause = false;
559
chudy@google.comc432f002012-07-10 13:19:25 +0000560 SkDebuggerGUI->setMenuBar(&fMenuBar);
chudy@google.com902ebe52012-06-29 14:21:22 +0000561 QMetaObject::connectSlotsByName(SkDebuggerGUI);
562}
563
564void SkDebuggerGUI::setupDirectoryWidget() {
chudy@google.comc432f002012-07-10 13:19:25 +0000565 QDir dir(fPath);
chudy@google.com902ebe52012-06-29 14:21:22 +0000566 QRegExp r(".skp");
chudy@google.comc432f002012-07-10 13:19:25 +0000567 fDirectoryWidget.clear();
568 const QStringList files = dir.entryList();
chudy@google.com902ebe52012-06-29 14:21:22 +0000569 foreach (QString f, files) {
chudy@google.com7dcae672012-07-09 20:26:53 +0000570 if (f.contains(r))
chudy@google.comc432f002012-07-10 13:19:25 +0000571 fDirectoryWidget.addItem(f);
chudy@google.com902ebe52012-06-29 14:21:22 +0000572 }
573}
574
chudy@google.com902ebe52012-06-29 14:21:22 +0000575void SkDebuggerGUI::loadPicture(QString fileName) {
chudy@google.comd3058f52012-07-19 13:41:27 +0000576 fLoading = true;
scroggo@google.comb4467e62012-11-06 23:10:09 +0000577 SkStream* stream = SkNEW_ARGS(SkFILEStream, (fileName.toAscii()));
578 SkPicture* picture = SkNEW_ARGS(SkPicture, (stream, NULL, &SkImageDecoder::DecodeStream));
chudy@google.com686e6802012-08-14 16:00:32 +0000579 fCanvasWidget.resetWidgetTransform();
chudy@google.com607357f2012-08-07 16:12:23 +0000580 fDebugger.loadPicture(picture);
chudy@google.com4c7962e2012-08-14 19:38:31 +0000581
chudy@google.com607357f2012-08-07 16:12:23 +0000582 SkSafeUnref(stream);
583 SkSafeUnref(picture);
584
chudy@google.com97cee972012-08-07 20:41:37 +0000585 // Will this automatically clear out due to nature of refcnt?
586 SkTDArray<SkString*>* commands = fDebugger.getDrawCommands();
chudy@google.com607357f2012-08-07 16:12:23 +0000587
chudy@google.com7dcae672012-07-09 20:26:53 +0000588 /* fDebugCanvas is reinitialized every load picture. Need it to retain value
chudy@google.com607357f2012-08-07 16:12:23 +0000589 * of the visibility filter.
590 * TODO(chudy): This should be deprecated since fDebugger is not
591 * recreated.
592 * */
593 fDebugger.highlightCurrentCommand(fSettingsWidget.getVisibilityButton()->isChecked());
594
chudy@google.com97cee972012-08-07 20:41:37 +0000595 setupListWidget(commands);
596 setupComboBox(commands);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000597 fInspectorWidget.setDisabled(false);
chudy@google.come606d6e2012-07-12 14:31:25 +0000598 fSettingsWidget.setDisabled(false);
chudy@google.comd3058f52012-07-19 13:41:27 +0000599 fMenuEdit.setDisabled(false);
600 fMenuNavigate.setDisabled(false);
601 fMenuView.setDisabled(false);
chudy@google.com0ab03392012-07-28 20:16:11 +0000602 fActionSave.setDisabled(false);
603 fActionSaveAs.setDisabled(false);
chudy@google.comd3058f52012-07-19 13:41:27 +0000604 fLoading = false;
605 actionPlay();
chudy@google.com902ebe52012-06-29 14:21:22 +0000606}
607
chudy@google.com97cee972012-08-07 20:41:37 +0000608void SkDebuggerGUI::setupListWidget(SkTDArray<SkString*>* command) {
chudy@google.comc432f002012-07-10 13:19:25 +0000609 fListWidget.clear();
chudy@google.com902ebe52012-06-29 14:21:22 +0000610 int counter = 0;
robertphillips@google.com30d35f22012-11-06 16:45:36 +0000611 int indent = 0;
chudy@google.com97cee972012-08-07 20:41:37 +0000612 for (int i = 0; i < command->count(); i++) {
chudy@google.com902ebe52012-06-29 14:21:22 +0000613 QListWidgetItem *item = new QListWidgetItem();
chudy@google.com97cee972012-08-07 20:41:37 +0000614 item->setData(Qt::DisplayRole, (*command)[i]->c_str());
chudy@google.com902ebe52012-06-29 14:21:22 +0000615 item->setData(Qt::UserRole + 1, counter++);
robertphillips@google.com30d35f22012-11-06 16:45:36 +0000616
617 if (0 == strcmp("Restore", (*command)[i]->c_str())) {
618 indent -= 10;
619 }
620
621 item->setData(Qt::UserRole + 3, indent);
622
623 if (0 == strcmp("Save", (*command)[i]->c_str()) ||
624 0 == strcmp("Save Layer", (*command)[i]->c_str())) {
625 indent += 10;
626 }
627
chudy@google.comc432f002012-07-10 13:19:25 +0000628 fListWidget.addItem(item);
chudy@google.com902ebe52012-06-29 14:21:22 +0000629 }
630}
631
chudy@google.com97cee972012-08-07 20:41:37 +0000632void SkDebuggerGUI::setupComboBox(SkTDArray<SkString*>* command) {
chudy@google.comc432f002012-07-10 13:19:25 +0000633 fFilter.clear();
634 fFilter.addItem("--Filter By Available Commands--");
chudy@google.com902ebe52012-06-29 14:21:22 +0000635
636 std::map<std::string, int> map;
chudy@google.com97cee972012-08-07 20:41:37 +0000637 for (int i = 0; i < command->count(); i++) {
638 map[(*command)[i]->c_str()]++;
chudy@google.com902ebe52012-06-29 14:21:22 +0000639 }
640
641 QString overview;
chudy@google.com607357f2012-08-07 16:12:23 +0000642 int counter = 0;
chudy@google.com7dcae672012-07-09 20:26:53 +0000643 for (std::map<std::string, int>::iterator it = map.begin(); it != map.end();
644 ++it) {
chudy@google.com902ebe52012-06-29 14:21:22 +0000645 overview.append((it->first).c_str());
646 overview.append(": ");
647 overview.append(QString::number(it->second));
648 overview.append("<br/>");
chudy@google.com7dcae672012-07-09 20:26:53 +0000649 counter += it->second;
chudy@google.comc432f002012-07-10 13:19:25 +0000650 fFilter.addItem((it->first).c_str());
chudy@google.com902ebe52012-06-29 14:21:22 +0000651 }
652 QString total;
653 total.append("Total Draw Commands: ");
654 total.append(QString::number(counter));
655 total.append("<br/>");
656 overview.insert(0, total);
657
658 overview.append("<br/>");
chudy@google.com607357f2012-08-07 16:12:23 +0000659 overview.append("SkPicture Width: ");
chudy@google.com902ebe52012-06-29 14:21:22 +0000660 // NOTE(chudy): This is where we can pull out the SkPictures width.
chudy@google.com607357f2012-08-07 16:12:23 +0000661 overview.append(QString::number(fDebugger.pictureWidth()));
chudy@google.com902ebe52012-06-29 14:21:22 +0000662 overview.append("px<br/>");
chudy@google.com607357f2012-08-07 16:12:23 +0000663 overview.append("SkPicture Height: ");
664 overview.append(QString::number(fDebugger.pictureHeight()));
chudy@google.com902ebe52012-06-29 14:21:22 +0000665 overview.append("px");
chudy@google.com6bd109a2012-08-14 19:34:13 +0000666 fInspectorWidget.setText(overview, SkInspectorWidget::kOverview_TabType);
chudy@google.com902ebe52012-06-29 14:21:22 +0000667
668 // NOTE(chudy): Makes first item unselectable.
chudy@google.com7dcae672012-07-09 20:26:53 +0000669 QStandardItemModel* model = qobject_cast<QStandardItemModel*>(
chudy@google.comc432f002012-07-10 13:19:25 +0000670 fFilter.model());
671 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(),
672 fFilter.rootModelIndex());
chudy@google.com902ebe52012-06-29 14:21:22 +0000673 QStandardItem* firstItem = model->itemFromIndex(firstIndex);
674 firstItem->setSelectable(false);
675}