blob: f5f9bc63312999d1bf753f7334e32b946e4a2048 [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"
scroggo@google.com7def5e12013-05-31 14:00:10 +00009#include "SkForceLinking.h"
chudy@google.combbad34d2012-08-13 14:26:36 +000010#include "SkGraphics.h"
scroggo@google.comb4467e62012-11-06 23:10:09 +000011#include "SkImageDecoder.h"
chudy@google.com902ebe52012-06-29 14:21:22 +000012#include <QListWidgetItem>
robertphillips@google.com2bde91d2012-11-15 14:57:57 +000013#include "PictureRenderer.h"
robertphillips@google.com2bde91d2012-11-15 14:57:57 +000014#include "SkPictureRecord.h"
15#include "SkPicturePlayback.h"
robertphillips@google.come174a8b2012-11-27 16:04:42 +000016
scroggo@google.com7def5e12013-05-31 14:00:10 +000017__SK_FORCE_IMAGE_DECODER_LINKING;
18
robertphillips@google.come174a8b2012-11-27 16:04:42 +000019#if defined(SK_BUILD_FOR_WIN32)
20 #include "BenchSysTimer_windows.h"
21#elif defined(SK_BUILD_FOR_MAC)
22 #include "BenchSysTimer_mach.h"
23#elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
24 #include "BenchSysTimer_posix.h"
25#else
26 #include "BenchSysTimer_c.h"
27#endif
28
chudy@google.com902ebe52012-06-29 14:21:22 +000029
30SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
chudy@google.comc432f002012-07-10 13:19:25 +000031 QMainWindow(parent)
chudy@google.com2d537a12012-07-31 12:49:52 +000032 , fCentralWidget(this)
33 , fStatusBar(this)
34 , fToolBar(this)
chudy@google.comc432f002012-07-10 13:19:25 +000035 , fActionOpen(this)
36 , fActionBreakpoint(this)
robertphillips@google.comd26c7062012-11-12 20:42:12 +000037 , fActionProfile(this)
chudy@google.comc432f002012-07-10 13:19:25 +000038 , fActionCancel(this)
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000039 , fActionClearBreakpoints(this)
chudy@google.come504de02012-07-16 18:35:23 +000040 , fActionClearDeletes(this)
chudy@google.comc432f002012-07-10 13:19:25 +000041 , fActionClose(this)
chudy@google.come504de02012-07-16 18:35:23 +000042 , fActionCreateBreakpoint(this)
chudy@google.comc432f002012-07-10 13:19:25 +000043 , fActionDelete(this)
44 , fActionDirectory(this)
45 , fActionGoToLine(this)
46 , fActionInspector(this)
47 , fActionPlay(this)
chudy@google.come504de02012-07-16 18:35:23 +000048 , fActionPause(this)
chudy@google.comc432f002012-07-10 13:19:25 +000049 , fActionRewind(this)
chudy@google.com0ab03392012-07-28 20:16:11 +000050 , fActionSave(this)
51 , fActionSaveAs(this)
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000052 , fActionShowDeletes(this)
chudy@google.comc432f002012-07-10 13:19:25 +000053 , fActionStepBack(this)
54 , fActionStepForward(this)
chudy@google.coma1226312012-07-26 20:26:44 +000055 , fActionZoomIn(this)
56 , fActionZoomOut(this)
57 , fMapper(this)
chudy@google.comc432f002012-07-10 13:19:25 +000058 , fListWidget(&fCentralWidget)
59 , fDirectoryWidget(&fCentralWidget)
chudy@google.com607357f2012-08-07 16:12:23 +000060 , fCanvasWidget(this, &fDebugger)
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000061 , fImageWidget(&fDebugger)
chudy@google.comc432f002012-07-10 13:19:25 +000062 , fMenuBar(this)
63 , fMenuFile(this)
64 , fMenuNavigate(this)
65 , fMenuView(this)
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000066 , fBreakpointsActivated(false)
67 , fDeletesActivated(false)
68 , fPause(false)
chudy@google.comd3058f52012-07-19 13:41:27 +000069 , fLoading(false)
chudy@google.comc432f002012-07-10 13:19:25 +000070{
chudy@google.com902ebe52012-06-29 14:21:22 +000071 setupUi(this);
robertphillips@google.comdd4b7452013-01-22 19:38:46 +000072 fListWidget.setSelectionMode(QAbstractItemView::ExtendedSelection);
chudy@google.comea5488b2012-07-26 19:38:22 +000073 connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(registerListClick(QListWidgetItem *)));
chudy@google.comc432f002012-07-10 13:19:25 +000074 connect(&fActionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
chudy@google.comea5488b2012-07-26 19:38:22 +000075 connect(&fActionDirectory, SIGNAL(triggered()), this, SLOT(toggleDirectory()));
76 connect(&fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(loadFile(QListWidgetItem *)));
chudy@google.comc432f002012-07-10 13:19:25 +000077 connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete()));
chudy@google.comea5488b2012-07-26 19:38:22 +000078 connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(toggleBreakpoint()));
chudy@google.comc432f002012-07-10 13:19:25 +000079 connect(&fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind()));
80 connect(&fActionPlay, SIGNAL(triggered()), this, SLOT(actionPlay()));
81 connect(&fActionStepBack, SIGNAL(triggered()), this, SLOT(actionStepBack()));
chudy@google.comea5488b2012-07-26 19:38:22 +000082 connect(&fActionStepForward, SIGNAL(triggered()), this, SLOT(actionStepForward()));
83 connect(&fActionBreakpoint, SIGNAL(triggered()), this, SLOT(actionBreakpoints()));
84 connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionInspector()));
85 connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionSettings()));
86 connect(&fFilter, SIGNAL(activated(QString)), this, SLOT(toggleFilter(QString)));
robertphillips@google.comd26c7062012-11-12 20:42:12 +000087 connect(&fActionProfile, SIGNAL(triggered()), this, SLOT(actionProfile()));
chudy@google.comc432f002012-07-10 13:19:25 +000088 connect(&fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel()));
chudy@google.com7e4cfbf2012-07-17 15:40:51 +000089 connect(&fActionClearBreakpoints, SIGNAL(triggered()), this, SLOT(actionClearBreakpoints()));
90 connect(&fActionClearDeletes, SIGNAL(triggered()), this, SLOT(actionClearDeletes()));
chudy@google.comc432f002012-07-10 13:19:25 +000091 connect(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose()));
chudy@google.comea5488b2012-07-26 19:38:22 +000092 connect(fSettingsWidget.getVisibilityButton(), SIGNAL(toggled(bool)), this, SLOT(actionCommandFilter()));
robertphillips@google.come8fe4bc2013-02-13 13:26:13 +000093#if SK_SUPPORT_GPU
chudy@google.comea5488b2012-07-26 19:38:22 +000094 connect(fSettingsWidget.getGLCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionGLWidget(bool)));
robertphillips@google.come8fe4bc2013-02-13 13:26:13 +000095#endif
chudy@google.comea5488b2012-07-26 19:38:22 +000096 connect(fSettingsWidget.getRasterCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionRasterWidget(bool)));
robertphillips@google.comf4741c12013-02-06 20:13:54 +000097 connect(fSettingsWidget.getOverdrawVizCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionOverdrawVizWidget(bool)));
chudy@google.comea5488b2012-07-26 19:38:22 +000098 connect(&fActionPause, SIGNAL(toggled(bool)), this, SLOT(pauseDrawing(bool)));
chudy@google.come504de02012-07-16 18:35:23 +000099 connect(&fActionCreateBreakpoint, SIGNAL(activated()), this, SLOT(toggleBreakpoint()));
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000100 connect(&fActionShowDeletes, SIGNAL(triggered()), this, SLOT(showDeletes()));
chudy@google.comea5488b2012-07-26 19:38:22 +0000101 connect(&fCanvasWidget, SIGNAL(hitChanged(int)), this, SLOT(selectCommand(int)));
102 connect(&fCanvasWidget, SIGNAL(hitChanged(int)), &fSettingsWidget, SLOT(updateHit(int)));
103 connect(&fCanvasWidget, SIGNAL(scaleFactorChanged(float)), this, SLOT(actionScale(float)));
104 connect(&fCanvasWidget, SIGNAL(commandChanged(int)), &fSettingsWidget, SLOT(updateCommand(int)));
chudy@google.com0ab03392012-07-28 20:16:11 +0000105 connect(&fActionSaveAs, SIGNAL(triggered()), this, SLOT(actionSaveAs()));
106 connect(&fActionSave, SIGNAL(triggered()), this, SLOT(actionSave()));
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000107
bungeman@google.come8cc6e82013-01-17 16:30:56 +0000108 fMapper.setMapping(&fActionZoomIn, SkCanvasWidget::kIn_ZoomCommand);
109 fMapper.setMapping(&fActionZoomOut, SkCanvasWidget::kOut_ZoomCommand);
chudy@google.coma1226312012-07-26 20:26:44 +0000110
111 connect(&fActionZoomIn, SIGNAL(triggered()), &fMapper, SLOT(map()));
112 connect(&fActionZoomOut, SIGNAL(triggered()), &fMapper, SLOT(map()));
bungeman@google.come8cc6e82013-01-17 16:30:56 +0000113 connect(&fMapper, SIGNAL(mapped(int)), &fCanvasWidget, SLOT(zoom(int)));
chudy@google.coma1226312012-07-26 20:26:44 +0000114
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000115 fInspectorWidget.setDisabled(true);
chudy@google.comd3058f52012-07-19 13:41:27 +0000116 fMenuEdit.setDisabled(true);
117 fMenuNavigate.setDisabled(true);
118 fMenuView.setDisabled(true);
chudy@google.combbad34d2012-08-13 14:26:36 +0000119
120 SkGraphics::Init();
chudy@google.com902ebe52012-06-29 14:21:22 +0000121}
122
chudy@google.combbad34d2012-08-13 14:26:36 +0000123SkDebuggerGUI::~SkDebuggerGUI() {
124 SkGraphics::Term();
125}
chudy@google.com902ebe52012-06-29 14:21:22 +0000126
127void SkDebuggerGUI::actionBreakpoints() {
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000128 fBreakpointsActivated = !fBreakpointsActivated;
chudy@google.comc432f002012-07-10 13:19:25 +0000129 for (int row = 0; row < fListWidget.count(); row++) {
130 QListWidgetItem *item = fListWidget.item(row);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000131 item->setHidden(item->checkState() == Qt::Unchecked && fBreakpointsActivated);
132 }
133}
chudy@google.com902ebe52012-06-29 14:21:22 +0000134
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000135void SkDebuggerGUI::showDeletes() {
136 fDeletesActivated = !fDeletesActivated;
137 for (int row = 0; row < fListWidget.count(); row++) {
138 QListWidgetItem *item = fListWidget.item(row);
chudy@google.com607357f2012-08-07 16:12:23 +0000139 item->setHidden(fDebugger.isCommandVisible(row)
140 && fDeletesActivated);
chudy@google.com902ebe52012-06-29 14:21:22 +0000141 }
142}
143
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000144// The timed picture playback uses the SkPicturePlayback's profiling stubs
145// to time individual commands. The offsets are needed to map SkPicture
146// offsets to individual commands.
147class SkTimedPicturePlayback : public SkPicturePlayback {
148public:
scroggo@google.com12d588a2013-02-25 16:05:00 +0000149 SkTimedPicturePlayback(SkStream* stream, const SkPictInfo& info,
skia.committer@gmail.com3e2345a2013-05-24 07:01:26 +0000150 SkPicture::InstallPixelRefProc proc,
robertphillips@google.com5f971142012-12-07 20:48:56 +0000151 const SkTDArray<bool>& deletedCommands)
scroggo@google.com12d588a2013-02-25 16:05:00 +0000152 : INHERITED(stream, info, proc)
bungeman@google.come8cc6e82013-01-17 16:30:56 +0000153 , fSkipCommands(deletedCommands)
154 , fTot(0.0)
155 , fCurCommand(0) {
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000156 fTimes.setCount(deletedCommands.count());
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000157 fTypeTimes.setCount(LAST_DRAWTYPE_ENUM+1);
158 this->resetTimes();
159 }
160
161 void resetTimes() {
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000162 for (int i = 0; i < fTimes.count(); ++i) {
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000163 fTimes[i] = 0.0;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000164 }
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000165 for (int i = 0; i < fTypeTimes.count(); ++i) {
166 fTypeTimes[i] = 0.0f;
167 }
168 fTot = 0.0;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000169 }
170
171 int count() const { return fTimes.count(); }
172
173 double time(int index) const { return fTimes[index] / fTot; }
174
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000175 const SkTDArray<double>* typeTimes() const { return &fTypeTimes; }
176
177 double totTime() const { return fTot; }
178
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000179protected:
robertphillips@google.come174a8b2012-11-27 16:04:42 +0000180 BenchSysTimer fTimer;
robertphillips@google.com5f971142012-12-07 20:48:56 +0000181 SkTDArray<bool> fSkipCommands; // has the command been deleted in the GUI?
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000182 SkTDArray<double> fTimes; // sum of time consumed for each command
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000183 SkTDArray<double> fTypeTimes; // sum of time consumed for each type of command (e.g., drawPath)
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000184 double fTot; // total of all times in 'fTimes'
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000185 int fCurType;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000186 int fCurCommand; // the current command being executed/timed
187
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000188#ifdef SK_DEVELOPER
189 virtual bool preDraw(int opIndex, int type) SK_OVERRIDE {
190 fCurCommand = opIndex;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000191
robertphillips@google.com5f971142012-12-07 20:48:56 +0000192 if (fSkipCommands[fCurCommand]) {
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000193 return true;
robertphillips@google.com5f971142012-12-07 20:48:56 +0000194 }
195
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000196 fCurType = type;
197 // The SkDebugCanvas doesn't recognize these types. This class needs to
198 // convert or else we'll wind up with a mismatch between the type counts
199 // the debugger displays and the profile times.
200 if (DRAW_POS_TEXT_TOP_BOTTOM == type) {
201 fCurType = DRAW_POS_TEXT;
202 } else if (DRAW_POS_TEXT_H_TOP_BOTTOM == type) {
203 fCurType = DRAW_POS_TEXT_H;
204 }
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000205
robertphillips@google.come174a8b2012-11-27 16:04:42 +0000206#if defined(SK_BUILD_FOR_WIN32)
207 // CPU timer doesn't work well on Windows
208 fTimer.startWall();
209#else
210 fTimer.startCpu();
211#endif
robertphillips@google.com5f971142012-12-07 20:48:56 +0000212
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000213 return false;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000214 }
215
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000216 virtual void postDraw(int opIndex) SK_OVERRIDE {
robertphillips@google.come174a8b2012-11-27 16:04:42 +0000217#if defined(SK_BUILD_FOR_WIN32)
218 // CPU timer doesn't work well on Windows
219 double time = fTimer.endWall();
220#else
221 double time = fTimer.endCpu();
222#endif
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000223
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000224 SkASSERT(opIndex == fCurCommand);
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000225 SkASSERT(fCurType <= LAST_DRAWTYPE_ENUM);
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000226
robertphillips@google.come174a8b2012-11-27 16:04:42 +0000227 fTimes[fCurCommand] += time;
228 fTypeTimes[fCurType] += time;
229 fTot += time;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000230 }
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000231#endif
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000232
233private:
234 typedef SkPicturePlayback INHERITED;
235};
236
237// Wrap SkPicture to allow installation of an SkTimedPicturePlayback object
238class SkTimedPicture : public SkPicture {
239public:
scroggo@google.com9f123162013-02-22 22:37:31 +0000240 explicit SkTimedPicture(SkStream* stream, bool* success, SkPicture::InstallPixelRefProc proc,
robertphillips@google.com5f971142012-12-07 20:48:56 +0000241 const SkTDArray<bool>& deletedCommands) {
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000242 if (success) {
243 *success = false;
244 }
245 fRecord = NULL;
246 fPlayback = NULL;
247 fWidth = fHeight = 0;
248
249 SkPictInfo info;
250
251 if (!stream->read(&info, sizeof(info))) {
252 return;
253 }
254 if (SkPicture::PICTURE_VERSION != info.fVersion) {
255 return;
256 }
257
258 if (stream->readBool()) {
skia.committer@gmail.com884e60b2012-11-16 02:01:17 +0000259 fPlayback = SkNEW_ARGS(SkTimedPicturePlayback,
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000260 (stream, info, proc, deletedCommands));
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000261 }
262
263 // do this at the end, so that they will be zero if we hit an error.
264 fWidth = info.fWidth;
265 fHeight = info.fHeight;
266 if (success) {
267 *success = true;
268 }
269 }
270
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000271 void resetTimes() { ((SkTimedPicturePlayback*) fPlayback)->resetTimes(); }
272
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000273 int count() const { return ((SkTimedPicturePlayback*) fPlayback)->count(); }
274
275 // return the fraction of the total time this command consumed
276 double time(int index) const { return ((SkTimedPicturePlayback*) fPlayback)->time(index); }
277
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000278 const SkTDArray<double>* typeTimes() const { return ((SkTimedPicturePlayback*) fPlayback)->typeTimes(); }
279
280 double totTime() const { return ((SkTimedPicturePlayback*) fPlayback)->totTime(); }
281
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000282private:
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000283 // disallow default ctor b.c. we don't have a good way to setup the fPlayback ptr
284 SkTimedPicture();
285 // disallow the copy ctor - enabling would require copying code from SkPicture
286 SkTimedPicture(const SkTimedPicture& src);
287
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000288 typedef SkPicture INHERITED;
289};
290
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000291// This is a simplification of PictureBenchmark's run with the addition of
292// clearing of the times after the first pass (in resetTimes)
skia.committer@gmail.com34587162012-11-20 02:01:23 +0000293void SkDebuggerGUI::run(SkTimedPicture* pict,
294 sk_tools::PictureRenderer* renderer,
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000295 int repeats) {
296 SkASSERT(pict);
297 if (NULL == pict) {
298 return;
299 }
300
301 SkASSERT(renderer != NULL);
302 if (NULL == renderer) {
303 return;
304 }
305
306 renderer->init(pict);
307
308 renderer->setup();
309 renderer->render(NULL);
jvanverth@google.comade32662013-01-28 21:09:05 +0000310 renderer->resetState(true);
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000311
312 // We throw this away the first batch of times to remove first time effects (such as paging in this program)
313 pict->resetTimes();
314
315 for (int i = 0; i < repeats; ++i) {
316 renderer->setup();
317 renderer->render(NULL);
jvanverth@google.comade32662013-01-28 21:09:05 +0000318 renderer->resetState(true);
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000319 }
320
321 renderer->end();
322}
323
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000324void SkDebuggerGUI::actionProfile() {
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000325 // In order to profile we pass the command offsets (that were read-in
326 // in loadPicture by the SkOffsetPicture) to an SkTimedPlaybackPicture.
skia.committer@gmail.com884e60b2012-11-16 02:01:17 +0000327 // The SkTimedPlaybackPicture in turn passes the offsets to an
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000328 // SkTimedPicturePlayback object which uses them to track the performance
329 // of individual commands.
330 if (fFileName.isEmpty()) {
331 return;
332 }
333
334 SkFILEStream inputStream;
335
336 inputStream.setPath(fFileName.c_str());
337 if (!inputStream.isValid()) {
338 return;
339 }
340
341 bool success = false;
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000342 SkTimedPicture picture(&inputStream, &success, &SkImageDecoder::DecodeMemory,
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000343 fSkipCommands);
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000344 if (!success) {
345 return;
346 }
347
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000348 // For now this #if allows switching between tiled and simple rendering
349 // modes. Eventually this will be accomplished via the GUI
robertphillips@google.come174a8b2012-11-27 16:04:42 +0000350#if 0
351 // With the current batch of SysTimers, profiling in tiled mode
352 // gets swamped by the timing overhead:
353 //
354 // tile mode simple mode
355 // debugger 64.2ms 12.8ms
356 // bench_pictures 16.9ms 12.4ms
357 //
358 // This is b.c. in tiled mode each command is called many more times
359 // but typically does less work on each invocation (due to clipping)
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000360 sk_tools::TiledPictureRenderer* renderer = NULL;
361
362 renderer = SkNEW(sk_tools::TiledPictureRenderer);
363 renderer->setTileWidth(256);
364 renderer->setTileHeight(256);
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000365#else
366 sk_tools::SimplePictureRenderer* renderer = NULL;
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000367
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000368 renderer = SkNEW(sk_tools::SimplePictureRenderer);
robertphillips@google.com1447aa32013-01-30 21:09:09 +0000369
370#if SK_SUPPORT_GPU
371 if (Qt::Checked == fSettingsWidget.getGLCheckBox()->checkState()) {
372 renderer->setDeviceType(sk_tools::PictureRenderer::kGPU_DeviceType);
373 }
374#endif
375
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000376#endif
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000377
robertphillips@google.come174a8b2012-11-27 16:04:42 +0000378 static const int kNumRepeats = 10;
379
380 run(&picture, renderer, kNumRepeats);
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000381
382 SkASSERT(picture.count() == fListWidget.count());
383
384 // extract the individual command times from the SkTimedPlaybackPicture
385 for (int i = 0; i < picture.count(); ++i) {
386 double temp = picture.time(i);
387
388 QListWidgetItem* item = fListWidget.item(i);
389
390 item->setData(Qt::UserRole + 4, 100.0*temp);
391 }
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000392
robertphillips@google.come428f9b2013-03-12 15:33:40 +0000393 setupOverviewText(picture.typeTimes(), picture.totTime(), kNumRepeats);
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000394}
395
chudy@google.com902ebe52012-06-29 14:21:22 +0000396void SkDebuggerGUI::actionCancel() {
chudy@google.comc432f002012-07-10 13:19:25 +0000397 for (int row = 0; row < fListWidget.count(); row++) {
398 fListWidget.item(row)->setHidden(false);
chudy@google.com902ebe52012-06-29 14:21:22 +0000399 }
400}
401
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000402void SkDebuggerGUI::actionClearBreakpoints() {
403 for (int row = 0; row < fListWidget.count(); row++) {
404 QListWidgetItem* item = fListWidget.item(row);
405 item->setCheckState(Qt::Unchecked);
406 item->setData(Qt::DecorationRole,
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000407 QPixmap(":/blank.png"));
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000408 }
409}
410
411void SkDebuggerGUI::actionClearDeletes() {
412 for (int row = 0; row < fListWidget.count(); row++) {
413 QListWidgetItem* item = fListWidget.item(row);
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000414 item->setData(Qt::UserRole + 2, QPixmap(":/blank.png"));
chudy@google.com607357f2012-08-07 16:12:23 +0000415 fDebugger.setCommandVisible(row, true);
robertphillips@google.com5f971142012-12-07 20:48:56 +0000416 fSkipCommands[row] = false;
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000417 }
418 if (fPause) {
419 fCanvasWidget.drawTo(fPausedRow);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000420 fImageWidget.draw();
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000421 } else {
422 fCanvasWidget.drawTo(fListWidget.currentRow());
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000423 fImageWidget.draw();
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000424 }
425}
426
chudy@google.com902ebe52012-06-29 14:21:22 +0000427void SkDebuggerGUI::actionCommandFilter() {
chudy@google.com607357f2012-08-07 16:12:23 +0000428 fDebugger.highlightCurrentCommand(
chudy@google.comc432f002012-07-10 13:19:25 +0000429 fSettingsWidget.getVisibilityButton()->isChecked());
430 fCanvasWidget.drawTo(fListWidget.currentRow());
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000431 fImageWidget.draw();
chudy@google.com902ebe52012-06-29 14:21:22 +0000432}
433
434void SkDebuggerGUI::actionClose() {
435 this->close();
436}
437
438void SkDebuggerGUI::actionDelete() {
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000439
robertphillips@google.comdd4b7452013-01-22 19:38:46 +0000440 for (int row = 0; row < fListWidget.count(); ++row) {
441 QListWidgetItem* item = fListWidget.item(row);
442
443 if (!item->isSelected()) {
444 continue;
445 }
446
447 if (fDebugger.isCommandVisible(row)) {
448 item->setData(Qt::UserRole + 2, QPixmap(":/delete.png"));
449 fDebugger.setCommandVisible(row, false);
450 fSkipCommands[row] = true;
451 } else {
452 item->setData(Qt::UserRole + 2, QPixmap(":/blank.png"));
453 fDebugger.setCommandVisible(row, true);
454 fSkipCommands[row] = false;
455 }
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000456 }
457
robertphillips@google.comdd4b7452013-01-22 19:38:46 +0000458 int currentRow = fListWidget.currentRow();
459
chudy@google.come504de02012-07-16 18:35:23 +0000460 if (fPause) {
461 fCanvasWidget.drawTo(fPausedRow);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000462 fImageWidget.draw();
chudy@google.come504de02012-07-16 18:35:23 +0000463 } else {
464 fCanvasWidget.drawTo(currentRow);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000465 fImageWidget.draw();
chudy@google.come504de02012-07-16 18:35:23 +0000466 }
chudy@google.com902ebe52012-06-29 14:21:22 +0000467}
468
robertphillips@google.come8fe4bc2013-02-13 13:26:13 +0000469#if SK_SUPPORT_GPU
chudy@google.comea5488b2012-07-26 19:38:22 +0000470void SkDebuggerGUI::actionGLWidget(bool isToggled) {
471 fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kGPU_WidgetType, !isToggled);
472}
robertphillips@google.come8fe4bc2013-02-13 13:26:13 +0000473#endif
chudy@google.comea5488b2012-07-26 19:38:22 +0000474
chudy@google.com902ebe52012-06-29 14:21:22 +0000475void SkDebuggerGUI::actionInspector() {
chudy@google.comc432f002012-07-10 13:19:25 +0000476 if (fInspectorWidget.isHidden()) {
477 fInspectorWidget.setHidden(false);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000478 fImageWidget.setHidden(false);
chudy@google.com902ebe52012-06-29 14:21:22 +0000479 } else {
chudy@google.comc432f002012-07-10 13:19:25 +0000480 fInspectorWidget.setHidden(true);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000481 fImageWidget.setHidden(true);
chudy@google.com902ebe52012-06-29 14:21:22 +0000482 }
483}
484
485void SkDebuggerGUI::actionPlay() {
chudy@google.comc432f002012-07-10 13:19:25 +0000486 for (int row = fListWidget.currentRow() + 1; row < fListWidget.count();
chudy@google.com7dcae672012-07-09 20:26:53 +0000487 row++) {
chudy@google.comc432f002012-07-10 13:19:25 +0000488 QListWidgetItem *item = fListWidget.item(row);
chudy@google.com902ebe52012-06-29 14:21:22 +0000489 if (item->checkState() == Qt::Checked) {
chudy@google.comc432f002012-07-10 13:19:25 +0000490 fListWidget.setCurrentItem(item);
chudy@google.com902ebe52012-06-29 14:21:22 +0000491 return;
492 }
493 }
chudy@google.comc432f002012-07-10 13:19:25 +0000494 fListWidget.setCurrentRow(fListWidget.count() - 1);
chudy@google.com902ebe52012-06-29 14:21:22 +0000495}
496
chudy@google.comea5488b2012-07-26 19:38:22 +0000497void SkDebuggerGUI::actionRasterWidget(bool isToggled) {
498 fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kRaster_8888_WidgetType, !isToggled);
499}
500
robertphillips@google.comf4741c12013-02-06 20:13:54 +0000501void SkDebuggerGUI::actionOverdrawVizWidget(bool isToggled) {
502 fDebugger.setOverdrawViz(isToggled);
503 fCanvasWidget.update();
504}
505
chudy@google.com902ebe52012-06-29 14:21:22 +0000506void SkDebuggerGUI::actionRewind() {
chudy@google.come504de02012-07-16 18:35:23 +0000507 fListWidget.setCurrentRow(0);
chudy@google.com902ebe52012-06-29 14:21:22 +0000508}
509
chudy@google.com0ab03392012-07-28 20:16:11 +0000510void SkDebuggerGUI::actionSave() {
robertphillips@google.come219baf2013-01-28 19:25:43 +0000511 fFileName = fPath.toAscii().data();
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000512 fFileName.append("/");
robertphillips@google.come219baf2013-01-28 19:25:43 +0000513 fFileName.append(fDirectoryWidget.currentItem()->text().toAscii().data());
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000514 saveToFile(fFileName);
chudy@google.com0ab03392012-07-28 20:16:11 +0000515}
516
517void SkDebuggerGUI::actionSaveAs() {
518 QString filename = QFileDialog::getSaveFileName(this, "Save File", "",
519 "Skia Picture (*skp)");
chudy@google.com38b08ce2012-07-28 23:26:10 +0000520 if (!filename.endsWith(".skp", Qt::CaseInsensitive)) {
chudy@google.com0ab03392012-07-28 20:16:11 +0000521 filename.append(".skp");
522 }
djsollen@google.comc3c82162012-11-13 18:35:10 +0000523 saveToFile(SkString(filename.toAscii().data()));
chudy@google.com0ab03392012-07-28 20:16:11 +0000524}
525
chudy@google.com7dcae672012-07-09 20:26:53 +0000526void SkDebuggerGUI::actionScale(float scaleFactor) {
chudy@google.comc432f002012-07-10 13:19:25 +0000527 fSettingsWidget.setZoomText(scaleFactor);
chudy@google.com7dcae672012-07-09 20:26:53 +0000528}
529
chudy@google.com902ebe52012-06-29 14:21:22 +0000530void SkDebuggerGUI::actionSettings() {
chudy@google.comc432f002012-07-10 13:19:25 +0000531 if (fSettingsWidget.isHidden()) {
532 fSettingsWidget.setHidden(false);
chudy@google.com902ebe52012-06-29 14:21:22 +0000533 } else {
chudy@google.comc432f002012-07-10 13:19:25 +0000534 fSettingsWidget.setHidden(true);
chudy@google.com902ebe52012-06-29 14:21:22 +0000535 }
536}
537
538void SkDebuggerGUI::actionStepBack() {
chudy@google.comc432f002012-07-10 13:19:25 +0000539 int currentRow = fListWidget.currentRow();
chudy@google.com902ebe52012-06-29 14:21:22 +0000540 if (currentRow != 0) {
chudy@google.comc432f002012-07-10 13:19:25 +0000541 fListWidget.setCurrentRow(currentRow - 1);
chudy@google.com902ebe52012-06-29 14:21:22 +0000542 }
543}
544
545void SkDebuggerGUI::actionStepForward() {
chudy@google.comc432f002012-07-10 13:19:25 +0000546 int currentRow = fListWidget.currentRow();
chudy@google.com902ebe52012-06-29 14:21:22 +0000547 QString curRow = QString::number(currentRow);
chudy@google.comc432f002012-07-10 13:19:25 +0000548 QString curCount = QString::number(fListWidget.count());
549 if (currentRow < fListWidget.count() - 1) {
550 fListWidget.setCurrentRow(currentRow + 1);
chudy@google.com902ebe52012-06-29 14:21:22 +0000551 }
552}
553
chudy@google.coma9e937c2012-08-03 17:32:05 +0000554void SkDebuggerGUI::drawComplete() {
chudy@google.com607357f2012-08-07 16:12:23 +0000555 fInspectorWidget.setMatrix(fDebugger.getCurrentMatrix());
556 fInspectorWidget.setClip(fDebugger.getCurrentClip());
chudy@google.coma9e937c2012-08-03 17:32:05 +0000557}
558
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000559void SkDebuggerGUI::saveToFile(const SkString& filename) {
560 SkFILEWStream file(filename.c_str());
robertphillips@google.com25bc2f82013-01-22 18:03:56 +0000561 SkAutoTUnref<SkPicture> copy(fDebugger.copyPicture());
562
563 copy->serialize(&file);
chudy@google.com0ab03392012-07-28 20:16:11 +0000564}
565
chudy@google.com902ebe52012-06-29 14:21:22 +0000566void SkDebuggerGUI::loadFile(QListWidgetItem *item) {
567 if (fDirectoryWidgetActive) {
robertphillips@google.come219baf2013-01-28 19:25:43 +0000568 fFileName = fPath.toAscii().data();
jvanverth@google.com0ac6f162013-02-05 19:44:07 +0000569 // don't add a '/' to files in the local directory
570 if (fFileName.size() > 0) {
571 fFileName.append("/");
572 }
robertphillips@google.come219baf2013-01-28 19:25:43 +0000573 fFileName.append(item->text().toAscii().data());
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000574 loadPicture(fFileName);
chudy@google.com902ebe52012-06-29 14:21:22 +0000575 }
576}
577
578void SkDebuggerGUI::openFile() {
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000579 QString temp = QFileDialog::getOpenFileName(this, tr("Open File"), "",
chudy@google.com7dcae672012-07-09 20:26:53 +0000580 tr("Files (*.*)"));
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +0000581 openFile(temp);
582}
583
584void SkDebuggerGUI::openFile(const QString &filename) {
chudy@google.com902ebe52012-06-29 14:21:22 +0000585 fDirectoryWidgetActive = false;
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +0000586 if (!filename.isEmpty()) {
587 QFileInfo pathInfo(filename);
588 loadPicture(SkString(filename.toAscii().data()));
589 setupDirectoryWidget(pathInfo.path());
chudy@google.com902ebe52012-06-29 14:21:22 +0000590 }
chudy@google.com902ebe52012-06-29 14:21:22 +0000591 fDirectoryWidgetActive = true;
592}
593
chudy@google.comc432f002012-07-10 13:19:25 +0000594void SkDebuggerGUI::pauseDrawing(bool isPaused) {
chudy@google.com607357f2012-08-07 16:12:23 +0000595 fPause = isPaused;
596 fPausedRow = fListWidget.currentRow();
597 fCanvasWidget.drawTo(fPausedRow);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000598 fImageWidget.draw();
chudy@google.com7dcae672012-07-09 20:26:53 +0000599}
600
chudy@google.com902ebe52012-06-29 14:21:22 +0000601void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
chudy@google.comd3058f52012-07-19 13:41:27 +0000602 if(!fLoading) {
603 int currentRow = fListWidget.currentRow();
chudy@google.comd3058f52012-07-19 13:41:27 +0000604
chudy@google.comea5488b2012-07-26 19:38:22 +0000605 if (currentRow != -1) {
606 if (!fPause) {
607 fCanvasWidget.drawTo(currentRow);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000608 fImageWidget.draw();
chudy@google.comd3058f52012-07-19 13:41:27 +0000609 }
chudy@google.com97cee972012-08-07 20:41:37 +0000610 SkTDArray<SkString*> *currInfo = fDebugger.getCommandInfo(
chudy@google.comea5488b2012-07-26 19:38:22 +0000611 currentRow);
612
613 /* TODO(chudy): Add command type before parameters. Rename v
614 * to something more informative. */
chudy@google.com97cee972012-08-07 20:41:37 +0000615 if (currInfo) {
chudy@google.comea5488b2012-07-26 19:38:22 +0000616 QString info;
617 info.append("<b>Parameters: </b><br/>");
chudy@google.com97cee972012-08-07 20:41:37 +0000618 for (int i = 0; i < currInfo->count(); i++) {
619
620 info.append(QString((*currInfo)[i]->c_str()));
chudy@google.comea5488b2012-07-26 19:38:22 +0000621 info.append("<br/>");
622 }
chudy@google.com6bd109a2012-08-14 19:34:13 +0000623 fInspectorWidget.setText(info, SkInspectorWidget::kDetail_TabType);
chudy@google.comea5488b2012-07-26 19:38:22 +0000624 fInspectorWidget.setDisabled(false);
chudy@google.comea5488b2012-07-26 19:38:22 +0000625 }
chudy@google.comd3058f52012-07-19 13:41:27 +0000626 }
chudy@google.comea5488b2012-07-26 19:38:22 +0000627
chudy@google.com902ebe52012-06-29 14:21:22 +0000628 }
629}
630
chudy@google.com9ca9bfe2012-07-12 21:58:14 +0000631void SkDebuggerGUI::selectCommand(int command) {
632 if (fPause) {
633 fListWidget.setCurrentRow(command);
634 }
635}
636
chudy@google.com902ebe52012-06-29 14:21:22 +0000637void SkDebuggerGUI::toggleBreakpoint() {
chudy@google.comc432f002012-07-10 13:19:25 +0000638 QListWidgetItem* item = fListWidget.currentItem();
chudy@google.com902ebe52012-06-29 14:21:22 +0000639 if (item->checkState() == Qt::Unchecked) {
640 item->setCheckState(Qt::Checked);
chudy@google.come565de42012-07-12 14:15:54 +0000641 item->setData(Qt::DecorationRole,
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000642 QPixmap(":/breakpoint_16x16.png"));
chudy@google.com902ebe52012-06-29 14:21:22 +0000643 } else {
chudy@google.com902ebe52012-06-29 14:21:22 +0000644 item->setCheckState(Qt::Unchecked);
chudy@google.come565de42012-07-12 14:15:54 +0000645 item->setData(Qt::DecorationRole,
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000646 QPixmap(":/blank.png"));
chudy@google.com902ebe52012-06-29 14:21:22 +0000647 }
648}
649
650void SkDebuggerGUI::toggleDirectory() {
chudy@google.com607357f2012-08-07 16:12:23 +0000651 fDirectoryWidget.setHidden(!fDirectoryWidget.isHidden());
chudy@google.com902ebe52012-06-29 14:21:22 +0000652}
653
654void SkDebuggerGUI::toggleFilter(QString string) {
chudy@google.comc432f002012-07-10 13:19:25 +0000655 for (int row = 0; row < fListWidget.count(); row++) {
656 QListWidgetItem *item = fListWidget.item(row);
chudy@google.com607357f2012-08-07 16:12:23 +0000657 item->setHidden(item->text() != string);
chudy@google.com902ebe52012-06-29 14:21:22 +0000658 }
659}
660
661void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
662 QIcon windowIcon;
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000663 windowIcon.addFile(QString::fromUtf8(":/skia.png"), QSize(),
chudy@google.com7dcae672012-07-09 20:26:53 +0000664 QIcon::Normal, QIcon::Off);
chudy@google.com902ebe52012-06-29 14:21:22 +0000665 SkDebuggerGUI->setObjectName(QString::fromUtf8("SkDebuggerGUI"));
666 SkDebuggerGUI->resize(1200, 1000);
667 SkDebuggerGUI->setWindowIcon(windowIcon);
chudy@google.comc432f002012-07-10 13:19:25 +0000668 SkDebuggerGUI->setWindowTitle("Skia Debugger");
chudy@google.com902ebe52012-06-29 14:21:22 +0000669
chudy@google.come504de02012-07-16 18:35:23 +0000670 fActionOpen.setShortcuts(QKeySequence::Open);
chudy@google.comc432f002012-07-10 13:19:25 +0000671 fActionOpen.setText("Open");
chudy@google.com902ebe52012-06-29 14:21:22 +0000672
673 QIcon breakpoint;
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000674 breakpoint.addFile(QString::fromUtf8(":/breakpoint.png"),
chudy@google.com7dcae672012-07-09 20:26:53 +0000675 QSize(), QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000676 fActionBreakpoint.setShortcut(QKeySequence(tr("Ctrl+B")));
chudy@google.comc432f002012-07-10 13:19:25 +0000677 fActionBreakpoint.setIcon(breakpoint);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000678 fActionBreakpoint.setText("Breakpoints");
chudy@google.com902ebe52012-06-29 14:21:22 +0000679
680 QIcon cancel;
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000681 cancel.addFile(QString::fromUtf8(":/reload.png"), QSize(),
chudy@google.com7dcae672012-07-09 20:26:53 +0000682 QIcon::Normal, QIcon::Off);
chudy@google.comc432f002012-07-10 13:19:25 +0000683 fActionCancel.setIcon(cancel);
684 fActionCancel.setText("Clear Filter");
chudy@google.com902ebe52012-06-29 14:21:22 +0000685
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000686 fActionClearBreakpoints.setShortcut(QKeySequence(tr("Alt+B")));
687 fActionClearBreakpoints.setText("Clear Breakpoints");
688
689 fActionClearDeletes.setShortcut(QKeySequence(tr("Alt+X")));
690 fActionClearDeletes.setText("Clear Deletes");
691
chudy@google.come504de02012-07-16 18:35:23 +0000692 fActionClose.setShortcuts(QKeySequence::Quit);
chudy@google.comc432f002012-07-10 13:19:25 +0000693 fActionClose.setText("Exit");
chudy@google.com902ebe52012-06-29 14:21:22 +0000694
chudy@google.come504de02012-07-16 18:35:23 +0000695 fActionCreateBreakpoint.setShortcut(QKeySequence(tr("B")));
696 fActionCreateBreakpoint.setText("Set Breakpoint");
697
698 fActionDelete.setShortcut(QKeySequence(tr("X")));
chudy@google.comc432f002012-07-10 13:19:25 +0000699 fActionDelete.setText("Delete Command");
chudy@google.com902ebe52012-06-29 14:21:22 +0000700
chudy@google.come504de02012-07-16 18:35:23 +0000701 fActionDirectory.setShortcut(QKeySequence(tr("Ctrl+D")));
702 fActionDirectory.setText("Directory");
chudy@google.com902ebe52012-06-29 14:21:22 +0000703
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000704 QIcon profile;
robertphillips@google.comd1636362012-11-19 18:25:09 +0000705 profile.addFile(QString::fromUtf8(":/profile.png"), QSize(),
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000706 QIcon::Normal, QIcon::Off);
707 fActionProfile.setIcon(profile);
708 fActionProfile.setText("Profile");
robertphillips@google.come099bc42012-11-19 16:26:40 +0000709 fActionProfile.setDisabled(true);
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000710
chudy@google.comc432f002012-07-10 13:19:25 +0000711 QIcon inspector;
robertphillips@google.comd1636362012-11-19 18:25:09 +0000712 inspector.addFile(QString::fromUtf8(":/inspector.png"),
chudy@google.comc432f002012-07-10 13:19:25 +0000713 QSize(), QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000714 fActionInspector.setShortcut(QKeySequence(tr("Ctrl+I")));
chudy@google.comc432f002012-07-10 13:19:25 +0000715 fActionInspector.setIcon(inspector);
chudy@google.come504de02012-07-16 18:35:23 +0000716 fActionInspector.setText("Inspector");
chudy@google.com902ebe52012-06-29 14:21:22 +0000717
chudy@google.comc432f002012-07-10 13:19:25 +0000718 QIcon play;
robertphillips@google.comd1636362012-11-19 18:25:09 +0000719 play.addFile(QString::fromUtf8(":/play.png"), QSize(),
chudy@google.comc432f002012-07-10 13:19:25 +0000720 QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000721 fActionPlay.setShortcut(QKeySequence(tr("Ctrl+P")));
chudy@google.comc432f002012-07-10 13:19:25 +0000722 fActionPlay.setIcon(play);
723 fActionPlay.setText("Play");
chudy@google.com902ebe52012-06-29 14:21:22 +0000724
chudy@google.come504de02012-07-16 18:35:23 +0000725 QIcon pause;
robertphillips@google.comd1636362012-11-19 18:25:09 +0000726 pause.addFile(QString::fromUtf8(":/pause.png"), QSize(),
chudy@google.comc432f002012-07-10 13:19:25 +0000727 QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000728 fActionPause.setShortcut(QKeySequence(tr("Space")));
729 fActionPause.setCheckable(true);
730 fActionPause.setIcon(pause);
731 fActionPause.setText("Pause");
732
chudy@google.comc432f002012-07-10 13:19:25 +0000733 QIcon rewind;
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000734 rewind.addFile(QString::fromUtf8(":/rewind.png"), QSize(),
chudy@google.comc432f002012-07-10 13:19:25 +0000735 QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000736 fActionRewind.setShortcut(QKeySequence(tr("Ctrl+R")));
chudy@google.comc432f002012-07-10 13:19:25 +0000737 fActionRewind.setIcon(rewind);
738 fActionRewind.setText("Rewind");
chudy@google.com902ebe52012-06-29 14:21:22 +0000739
chudy@google.com0ab03392012-07-28 20:16:11 +0000740 fActionSave.setShortcut(QKeySequence::Save);
741 fActionSave.setText("Save");
742 fActionSave.setDisabled(true);
743 fActionSaveAs.setShortcut(QKeySequence::SaveAs);
744 fActionSaveAs.setText("Save As");
745 fActionSaveAs.setDisabled(true);
746
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000747 fActionShowDeletes.setShortcut(QKeySequence(tr("Ctrl+X")));
748 fActionShowDeletes.setText("Deleted Commands");
749
chudy@google.comc432f002012-07-10 13:19:25 +0000750 QIcon stepBack;
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000751 stepBack.addFile(QString::fromUtf8(":/previous.png"), QSize(),
chudy@google.comc432f002012-07-10 13:19:25 +0000752 QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000753 fActionStepBack.setShortcut(QKeySequence(tr("[")));
chudy@google.comc432f002012-07-10 13:19:25 +0000754 fActionStepBack.setIcon(stepBack);
755 fActionStepBack.setText("Step Back");
chudy@google.com902ebe52012-06-29 14:21:22 +0000756
chudy@google.comc432f002012-07-10 13:19:25 +0000757 QIcon stepForward;
robertphillips@google.com8e41a162012-11-19 17:39:18 +0000758 stepForward.addFile(QString::fromUtf8(":/next.png"),
chudy@google.comc432f002012-07-10 13:19:25 +0000759 QSize(), QIcon::Normal, QIcon::Off);
chudy@google.come504de02012-07-16 18:35:23 +0000760 fActionStepForward.setShortcut(QKeySequence(tr("]")));
chudy@google.comc432f002012-07-10 13:19:25 +0000761 fActionStepForward.setIcon(stepForward);
762 fActionStepForward.setText("Step Forward");
763
chudy@google.coma1226312012-07-26 20:26:44 +0000764 fActionZoomIn.setShortcut(QKeySequence(tr("Ctrl+=")));
765 fActionZoomIn.setText("Zoom In");
766 fActionZoomOut.setShortcut(QKeySequence(tr("Ctrl+-")));
767 fActionZoomOut.setText("Zoom Out");
768
chudy@google.comc432f002012-07-10 13:19:25 +0000769 fListWidget.setItemDelegate(new SkListWidget(&fListWidget));
770 fListWidget.setObjectName(QString::fromUtf8("listWidget"));
771 fListWidget.setMaximumWidth(250);
772
773 fFilter.addItem("--Filter By Available Commands--");
774
775 fDirectoryWidget.setMaximumWidth(250);
776 fDirectoryWidget.setStyleSheet("QListWidget::Item {padding: 5px;}");
777
778 fCanvasWidget.setSizePolicy(QSizePolicy::Expanding,
chudy@google.com7dcae672012-07-09 20:26:53 +0000779 QSizePolicy::Expanding);
chudy@google.com902ebe52012-06-29 14:21:22 +0000780
skia.committer@gmail.com1c9c0d32012-11-22 02:02:41 +0000781 fImageWidget.setFixedSize(SkImageWidget::kImageWidgetWidth,
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000782 SkImageWidget::kImageWidgetHeight);
783
chudy@google.comc432f002012-07-10 13:19:25 +0000784 fInspectorWidget.setSizePolicy(QSizePolicy::Expanding,
chudy@google.com7dcae672012-07-09 20:26:53 +0000785 QSizePolicy::Expanding);
chudy@google.comc432f002012-07-10 13:19:25 +0000786 fInspectorWidget.setMaximumHeight(300);
chudy@google.com902ebe52012-06-29 14:21:22 +0000787
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000788 fSettingsAndImageLayout.setSpacing(6);
789 fSettingsAndImageLayout.addWidget(&fSettingsWidget);
790 fSettingsAndImageLayout.addWidget(&fImageWidget);
791
chudy@google.comc432f002012-07-10 13:19:25 +0000792 fSettingsWidget.setSizePolicy(QSizePolicy::Expanding,
793 QSizePolicy::Expanding);
794 fSettingsWidget.setMaximumWidth(250);
chudy@google.com902ebe52012-06-29 14:21:22 +0000795
chudy@google.comc432f002012-07-10 13:19:25 +0000796 fLeftColumnLayout.setSpacing(6);
797 fLeftColumnLayout.addWidget(&fListWidget);
798 fLeftColumnLayout.addWidget(&fDirectoryWidget);
chudy@google.com902ebe52012-06-29 14:21:22 +0000799
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000800 fCanvasSettingsAndImageLayout.setSpacing(6);
801 fCanvasSettingsAndImageLayout.addWidget(&fCanvasWidget);
802 fCanvasSettingsAndImageLayout.addLayout(&fSettingsAndImageLayout);
803
chudy@google.com902ebe52012-06-29 14:21:22 +0000804
chudy@google.comc432f002012-07-10 13:19:25 +0000805 fMainAndRightColumnLayout.setSpacing(6);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000806 fMainAndRightColumnLayout.addLayout(&fCanvasSettingsAndImageLayout);
chudy@google.comc432f002012-07-10 13:19:25 +0000807 fMainAndRightColumnLayout.addWidget(&fInspectorWidget);
chudy@google.com902ebe52012-06-29 14:21:22 +0000808
chudy@google.com2d537a12012-07-31 12:49:52 +0000809 fCentralWidget.setLayout(&fContainerLayout);
chudy@google.comc432f002012-07-10 13:19:25 +0000810 fContainerLayout.setSpacing(6);
811 fContainerLayout.setContentsMargins(11, 11, 11, 11);
812 fContainerLayout.addLayout(&fLeftColumnLayout);
813 fContainerLayout.addLayout(&fMainAndRightColumnLayout);
814
815 SkDebuggerGUI->setCentralWidget(&fCentralWidget);
816 SkDebuggerGUI->setStatusBar(&fStatusBar);
817
chudy@google.come504de02012-07-16 18:35:23 +0000818 fToolBar.setIconSize(QSize(32, 32));
chudy@google.comc432f002012-07-10 13:19:25 +0000819 fToolBar.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
820 SkDebuggerGUI->addToolBar(Qt::TopToolBarArea, &fToolBar);
chudy@google.com902ebe52012-06-29 14:21:22 +0000821
chudy@google.com0ab03392012-07-28 20:16:11 +0000822 fSpacer.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
chudy@google.com902ebe52012-06-29 14:21:22 +0000823
chudy@google.comc432f002012-07-10 13:19:25 +0000824 fToolBar.addAction(&fActionRewind);
825 fToolBar.addAction(&fActionStepBack);
chudy@google.come504de02012-07-16 18:35:23 +0000826 fToolBar.addAction(&fActionPause);
chudy@google.comc432f002012-07-10 13:19:25 +0000827 fToolBar.addAction(&fActionStepForward);
828 fToolBar.addAction(&fActionPlay);
829 fToolBar.addSeparator();
chudy@google.come504de02012-07-16 18:35:23 +0000830 fToolBar.addAction(&fActionInspector);
chudy@google.comc432f002012-07-10 13:19:25 +0000831 fToolBar.addSeparator();
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000832 fToolBar.addAction(&fActionProfile);
833
834 fToolBar.addSeparator();
chudy@google.com0ab03392012-07-28 20:16:11 +0000835 fToolBar.addWidget(&fSpacer);
chudy@google.comc432f002012-07-10 13:19:25 +0000836 fToolBar.addWidget(&fFilter);
837 fToolBar.addAction(&fActionCancel);
chudy@google.com902ebe52012-06-29 14:21:22 +0000838
839 // TODO(chudy): Remove static call.
840 fDirectoryWidgetActive = false;
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000841 fFileName = "";
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +0000842 setupDirectoryWidget("");
chudy@google.com902ebe52012-06-29 14:21:22 +0000843 fDirectoryWidgetActive = true;
844
chudy@google.com902ebe52012-06-29 14:21:22 +0000845 // Menu Bar
chudy@google.comc432f002012-07-10 13:19:25 +0000846 fMenuFile.setTitle("File");
847 fMenuFile.addAction(&fActionOpen);
chudy@google.com0ab03392012-07-28 20:16:11 +0000848 fMenuFile.addAction(&fActionSave);
849 fMenuFile.addAction(&fActionSaveAs);
chudy@google.comc432f002012-07-10 13:19:25 +0000850 fMenuFile.addAction(&fActionClose);
chudy@google.come504de02012-07-16 18:35:23 +0000851
852 fMenuEdit.setTitle("Edit");
853 fMenuEdit.addAction(&fActionDelete);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000854 fMenuEdit.addAction(&fActionClearDeletes);
855 fMenuEdit.addSeparator();
chudy@google.come504de02012-07-16 18:35:23 +0000856 fMenuEdit.addAction(&fActionCreateBreakpoint);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000857 fMenuEdit.addAction(&fActionClearBreakpoints);
chudy@google.come504de02012-07-16 18:35:23 +0000858
chudy@google.comc432f002012-07-10 13:19:25 +0000859 fMenuNavigate.setTitle("Navigate");
chudy@google.come504de02012-07-16 18:35:23 +0000860 fMenuNavigate.addAction(&fActionRewind);
861 fMenuNavigate.addAction(&fActionStepBack);
862 fMenuNavigate.addAction(&fActionStepForward);
863 fMenuNavigate.addAction(&fActionPlay);
864 fMenuNavigate.addAction(&fActionPause);
chudy@google.comc432f002012-07-10 13:19:25 +0000865 fMenuNavigate.addAction(&fActionGoToLine);
chudy@google.come504de02012-07-16 18:35:23 +0000866
chudy@google.comc432f002012-07-10 13:19:25 +0000867 fMenuView.setTitle("View");
chudy@google.come504de02012-07-16 18:35:23 +0000868 fMenuView.addAction(&fActionBreakpoint);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000869 fMenuView.addAction(&fActionShowDeletes);
chudy@google.coma1226312012-07-26 20:26:44 +0000870 fMenuView.addAction(&fActionZoomIn);
871 fMenuView.addAction(&fActionZoomOut);
chudy@google.come504de02012-07-16 18:35:23 +0000872
873 fMenuWindows.setTitle("Window");
874 fMenuWindows.addAction(&fActionInspector);
875 fMenuWindows.addAction(&fActionDirectory);
chudy@google.comc432f002012-07-10 13:19:25 +0000876
877 fActionGoToLine.setText("Go to Line...");
878 fActionGoToLine.setDisabled(true);
879 fMenuBar.addAction(fMenuFile.menuAction());
chudy@google.come504de02012-07-16 18:35:23 +0000880 fMenuBar.addAction(fMenuEdit.menuAction());
chudy@google.comc432f002012-07-10 13:19:25 +0000881 fMenuBar.addAction(fMenuView.menuAction());
882 fMenuBar.addAction(fMenuNavigate.menuAction());
chudy@google.come504de02012-07-16 18:35:23 +0000883 fMenuBar.addAction(fMenuWindows.menuAction());
chudy@google.com902ebe52012-06-29 14:21:22 +0000884
chudy@google.com7dcae672012-07-09 20:26:53 +0000885 fPause = false;
886
chudy@google.comc432f002012-07-10 13:19:25 +0000887 SkDebuggerGUI->setMenuBar(&fMenuBar);
chudy@google.com902ebe52012-06-29 14:21:22 +0000888 QMetaObject::connectSlotsByName(SkDebuggerGUI);
889}
890
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +0000891void SkDebuggerGUI::setupDirectoryWidget(const QString& path) {
892 fPath = path;
893 QDir dir(path);
chudy@google.com902ebe52012-06-29 14:21:22 +0000894 QRegExp r(".skp");
chudy@google.comc432f002012-07-10 13:19:25 +0000895 fDirectoryWidget.clear();
896 const QStringList files = dir.entryList();
chudy@google.com902ebe52012-06-29 14:21:22 +0000897 foreach (QString f, files) {
chudy@google.com7dcae672012-07-09 20:26:53 +0000898 if (f.contains(r))
chudy@google.comc432f002012-07-10 13:19:25 +0000899 fDirectoryWidget.addItem(f);
chudy@google.com902ebe52012-06-29 14:21:22 +0000900 }
901}
902
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000903void SkDebuggerGUI::loadPicture(const SkString& fileName) {
904 fFileName = fileName;
chudy@google.comd3058f52012-07-19 13:41:27 +0000905 fLoading = true;
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000906 SkStream* stream = SkNEW_ARGS(SkFILEStream, (fileName.c_str()));
robertphillips@google.com2d40ec42013-02-07 20:39:40 +0000907
908 bool success = false;
909
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000910 SkPicture* picture = SkNEW_ARGS(SkPicture,
911 (stream, &success, &SkImageDecoder::DecodeMemory));
robertphillips@google.com2d40ec42013-02-07 20:39:40 +0000912
913 if (!success) {
914 QMessageBox::critical(this, "Error loading file", "Couldn't read file, sorry.");
915 SkSafeUnref(stream);
916 return;
917 }
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000918
chudy@google.com686e6802012-08-14 16:00:32 +0000919 fCanvasWidget.resetWidgetTransform();
chudy@google.com607357f2012-08-07 16:12:23 +0000920 fDebugger.loadPicture(picture);
chudy@google.com4c7962e2012-08-14 19:38:31 +0000921
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000922 fSkipCommands.setCount(fDebugger.getSize());
923 for (int i = 0; i < fSkipCommands.count(); ++i) {
robertphillips@google.com5f971142012-12-07 20:48:56 +0000924 fSkipCommands[i] = false;
925 }
926
chudy@google.com607357f2012-08-07 16:12:23 +0000927 SkSafeUnref(stream);
928 SkSafeUnref(picture);
929
chudy@google.com97cee972012-08-07 20:41:37 +0000930 // Will this automatically clear out due to nature of refcnt?
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000931 SkTArray<SkString>* commands = fDebugger.getDrawCommandsAsStrings();
chudy@google.com607357f2012-08-07 16:12:23 +0000932
robertphillips@google.com6d9c92b2013-05-23 13:21:18 +0000933 fActionProfile.setDisabled(false);
robertphillips@google.com2bde91d2012-11-15 14:57:57 +0000934
chudy@google.com7dcae672012-07-09 20:26:53 +0000935 /* fDebugCanvas is reinitialized every load picture. Need it to retain value
chudy@google.com607357f2012-08-07 16:12:23 +0000936 * of the visibility filter.
937 * TODO(chudy): This should be deprecated since fDebugger is not
938 * recreated.
939 * */
940 fDebugger.highlightCurrentCommand(fSettingsWidget.getVisibilityButton()->isChecked());
941
chudy@google.com97cee972012-08-07 20:41:37 +0000942 setupListWidget(commands);
943 setupComboBox(commands);
robertphillips@google.come428f9b2013-03-12 15:33:40 +0000944 setupOverviewText(NULL, 0.0, 1);
chudy@google.com7e4cfbf2012-07-17 15:40:51 +0000945 fInspectorWidget.setDisabled(false);
chudy@google.come606d6e2012-07-12 14:31:25 +0000946 fSettingsWidget.setDisabled(false);
chudy@google.comd3058f52012-07-19 13:41:27 +0000947 fMenuEdit.setDisabled(false);
948 fMenuNavigate.setDisabled(false);
949 fMenuView.setDisabled(false);
chudy@google.com0ab03392012-07-28 20:16:11 +0000950 fActionSave.setDisabled(false);
951 fActionSaveAs.setDisabled(false);
chudy@google.comd3058f52012-07-19 13:41:27 +0000952 fLoading = false;
953 actionPlay();
chudy@google.com902ebe52012-06-29 14:21:22 +0000954}
955
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000956void SkDebuggerGUI::setupListWidget(SkTArray<SkString>* command) {
chudy@google.comc432f002012-07-10 13:19:25 +0000957 fListWidget.clear();
chudy@google.com902ebe52012-06-29 14:21:22 +0000958 int counter = 0;
robertphillips@google.com30d35f22012-11-06 16:45:36 +0000959 int indent = 0;
chudy@google.com97cee972012-08-07 20:41:37 +0000960 for (int i = 0; i < command->count(); i++) {
chudy@google.com902ebe52012-06-29 14:21:22 +0000961 QListWidgetItem *item = new QListWidgetItem();
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000962 item->setData(Qt::DisplayRole, (*command)[i].c_str());
chudy@google.com902ebe52012-06-29 14:21:22 +0000963 item->setData(Qt::UserRole + 1, counter++);
robertphillips@google.com30d35f22012-11-06 16:45:36 +0000964
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000965 if (0 == strcmp("Restore", (*command)[i].c_str()) ||
966 0 == strcmp("EndCommentGroup", (*command)[i].c_str())) {
robertphillips@google.com30d35f22012-11-06 16:45:36 +0000967 indent -= 10;
968 }
969
970 item->setData(Qt::UserRole + 3, indent);
971
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000972 if (0 == strcmp("Save", (*command)[i].c_str()) ||
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000973 0 == strcmp("Save Layer", (*command)[i].c_str()) ||
974 0 == strcmp("BeginCommentGroup", (*command)[i].c_str())) {
robertphillips@google.com30d35f22012-11-06 16:45:36 +0000975 indent += 10;
976 }
977
robertphillips@google.comd26c7062012-11-12 20:42:12 +0000978 item->setData(Qt::UserRole + 4, -1.0);
979
chudy@google.comc432f002012-07-10 13:19:25 +0000980 fListWidget.addItem(item);
chudy@google.com902ebe52012-06-29 14:21:22 +0000981 }
982}
983
skia.committer@gmail.com91274b92013-03-13 07:01:04 +0000984void SkDebuggerGUI::setupOverviewText(const SkTDArray<double>* typeTimes,
robertphillips@google.come428f9b2013-03-12 15:33:40 +0000985 double totTime,
986 int numRuns) {
borenet@google.com2d9dbd42013-03-12 13:07:40 +0000987 SkString overview;
robertphillips@google.come428f9b2013-03-12 15:33:40 +0000988 fDebugger.getOverviewText(typeTimes, totTime, &overview, numRuns);
borenet@google.com2d9dbd42013-03-12 13:07:40 +0000989 fInspectorWidget.setText(overview.c_str(), SkInspectorWidget::kOverview_TabType);
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000990}
991
992void SkDebuggerGUI::setupComboBox(SkTArray<SkString>* command) {
993 fFilter.clear();
994 fFilter.addItem("--Filter By Available Commands--");
995
996 std::map<std::string, int> map;
997 for (int i = 0; i < command->count(); i++) {
998 map[(*command)[i].c_str()]++;
999 }
1000
skia.committer@gmail.com34587162012-11-20 02:01:23 +00001001 for (std::map<std::string, int>::iterator it = map.begin(); it != map.end();
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +00001002 ++it) {
1003 fFilter.addItem((it->first).c_str());
1004 }
chudy@google.com902ebe52012-06-29 14:21:22 +00001005
1006 // NOTE(chudy): Makes first item unselectable.
chudy@google.com7dcae672012-07-09 20:26:53 +00001007 QStandardItemModel* model = qobject_cast<QStandardItemModel*>(
chudy@google.comc432f002012-07-10 13:19:25 +00001008 fFilter.model());
1009 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(),
1010 fFilter.rootModelIndex());
chudy@google.com902ebe52012-06-29 14:21:22 +00001011 QStandardItem* firstItem = model->itemFromIndex(firstIndex);
1012 firstItem->setSelectable(false);
1013}