blob: 9c98f485a2b57bf05e2e91cdf3579b6c923f943c [file] [log] [blame]
chudy@google.com902ebe52012-06-29 14:21:22 +00001
2/*
3 * Copyright 2012 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#include <iostream>
10#include "SkDebuggerGUI.h"
11#include <QListWidgetItem>
12
13SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
14 QMainWindow(parent) {
15
16 setupUi(this);
17 connect(fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,
18 QListWidgetItem*)), this, SLOT(registerListClick(QListWidgetItem *)));
19 connect(fActionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
20 connect(fActionDirectory, SIGNAL(triggered()), this, SLOT(toggleDirectory()));
21 connect(fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*,
22 QListWidgetItem*)), this, SLOT(loadFile(QListWidgetItem *)));
23 connect(fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete()));
24 connect(fActionReload, SIGNAL(triggered()), this, SLOT(actionReload()));
25 connect(fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(toggleBreakpoint()));
26 connect(fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind()));
27 connect(fActionPlay, SIGNAL(triggered()), this, SLOT(actionPlay()));
28 connect(fActionStepBack, SIGNAL(triggered()), this, SLOT(actionStepBack()));
29 connect(fActionStepForward, SIGNAL(triggered()), this, SLOT(actionStepForward()));
30 connect(fActionBreakpoint, SIGNAL(triggered()), this, SLOT(actionBreakpoints()));
31 connect(fActionInspector, SIGNAL(triggered()), this, SLOT(actionInspector()));
32 connect(fFilter, SIGNAL(activated(QString)), this, SLOT(toggleFilter(QString)));
33 connect(fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel()));
34 connect(fActionClose, SIGNAL(triggered()), this, SLOT(actionClose()));
35 connect(fActionSettings, SIGNAL(triggered()), this, SLOT(actionSettings()));
36 connect(fActionToggleCurrentCommand, SIGNAL(triggered()), this, SLOT(actionCommandFilter()));
37}
38
39SkDebuggerGUI::~SkDebuggerGUI() {
40}
41
42void SkDebuggerGUI::actionBreakpoints() {
43 if(!fBreakpointsActivated) {
44 fBreakpointsActivated = true;
45 } else {
46 fBreakpointsActivated = false;
47 }
48
49 for(int row=0; row<fListWidget->count(); row++) {
50 QListWidgetItem *item = fListWidget->item(row);
51
52 if (item->checkState() == Qt::Unchecked && fBreakpointsActivated) {
53 item->setHidden(true);
54 } else {
55 item->setHidden(false);
56 }
57 }
58}
59
60void SkDebuggerGUI::actionCancel() {
61 for(int row=0; row<fListWidget->count(); row++) {
62 fListWidget->item(row)->setHidden(false);
63 }
64}
65
66void SkDebuggerGUI::actionCommandFilter() {
67 if (fActionToggleCurrentCommand->text() == "Show Filter") {
68 fCanvasWidget->toggleCurrentCommandFilter(true);
69 fActionToggleCurrentCommand->setText("Hide Filter");
70 } else {
71 fActionToggleCurrentCommand->setText("Show Filter");
72 fCanvasWidget->toggleCurrentCommandFilter(false);
73 }
74
75 fCanvasWidget->drawTo(fListWidget->currentRow());
76
77}
78
79void SkDebuggerGUI::actionClose() {
80 this->close();
81}
82
83void SkDebuggerGUI::actionDelete() {
84 QListWidgetItem* item = fListWidget->currentItem();
85
86 if(item->data(Qt::UserRole + 2) == true) {
87 item->setData(Qt::UserRole + 2, false);
88 item->setData(Qt::DecorationRole,
89 QPixmap(":/images/Icons/delete.png"));
90
91 } else {
92 item->setData(Qt::UserRole + 2, true);
93 if(item->checkState() == Qt::Unchecked) {
94 item->setData(Qt::DecorationRole,
95 QPixmap(":/images/Icons/blank.png"));
96 } else {
97 item->setData(Qt::DecorationRole,
98 QPixmap(":/images/Icons/breakpoint_16x16.png"));
99 }
100
101 }
102
103 int currentRow = fListWidget->currentRow();
104
105 // NOTE(chudy): Forces a redraw up to current selected command.
106 if (fCanvasWidget) {
107 fCanvasWidget->toggleCommand(currentRow);
108 fCanvasWidget->drawTo(currentRow);
109 }
110}
111
112void SkDebuggerGUI::actionInspector() {
113 if (fInspectorWidget->isHidden()) {
114 fInspectorWidget->setHidden(false);
115 } else {
116 fInspectorWidget->setHidden(true);
117 }
118}
119
120void SkDebuggerGUI::actionPlay() {
121 for(int row=fListWidget->currentRow()+1; row<fListWidget->count(); row++) {
122 QListWidgetItem *item = fListWidget->item(row);
123 if (item->checkState() == Qt::Checked) {
124 fListWidget->setCurrentItem(item);
125 return;
126 }
127 }
128
129 fListWidget->setCurrentRow(fListWidget->count() - 1);
130}
131
132void SkDebuggerGUI::actionReload() {
133 for(int row=0; row<fListWidget->count(); row++) {
134 QListWidgetItem* item = fListWidget->item(row);
135 item->setData(Qt::UserRole + 2, true);
136 item->setData(Qt::DecorationRole,
137 QPixmap(":/images/Icons/blank.png"));
138 fCanvasWidget->toggleCommand(row, true);
139 }
140
141 fCanvasWidget->drawTo(fListWidget->currentRow());
142}
143
144void SkDebuggerGUI::actionRewind() {
145 /* NOTE(chudy): Hack. All skps opened so far start with save and concat
146 * commands that don't clear or reset the canvas. */
147 fListWidget->setCurrentRow(2);
148}
149
150void SkDebuggerGUI::actionSettings() {
151 if (fSettingsWidget->isHidden()) {
152 fSettingsWidget->setHidden(false);
153 } else {
154 fSettingsWidget->setHidden(true);
155 }
156}
157
158void SkDebuggerGUI::actionStepBack() {
159 int currentRow = fListWidget->currentRow();
160 if (currentRow != 0) {
161 fListWidget->setCurrentRow(currentRow - 1);
162 }
163}
164
165void SkDebuggerGUI::actionStepForward() {
166 int currentRow = fListWidget->currentRow();
167
168 QString curRow = QString::number(currentRow);
169 QString curCount = QString::number(fListWidget->count());
170
171
172 if (currentRow < fListWidget->count() - 1) {
173 fListWidget->setCurrentRow(currentRow + 1);
174 }
175}
176
177void SkDebuggerGUI::loadFile(QListWidgetItem *item) {
178 if (fDirectoryWidgetActive) {
179 QString fileName;
180 fileName.append(fPath);
181 fileName.append("/");
182 fileName.append(item->text());
183 loadPicture(fileName);
184 }
185}
186
187void SkDebuggerGUI::openFile() {
188 QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
189 "",
190 tr("Files (*.*)"));
191 fDirectoryWidgetActive = false;
192 if (!fileName.isNull()) {
193
194 QFileInfo pathInfo(fileName);
195 fPath = pathInfo.path();
196 loadPicture(fileName);
197 setupDirectoryWidget();
198 }
199 /* TODO(chudy): Need something here that sets the active directory
200 * widget selection to what was opened. OR we can just add a new function
201 * to change the directory (would be much easier).
202 */
203 fDirectoryWidgetActive = true;
204}
205
206void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
207 int currentRow = fListWidget->currentRow();
208
209 // NOTE(chudy): Prevents initialization errors.
210 if (fCanvasWidget) {
211 fCanvasWidget->drawTo(currentRow);
212 std::vector<std::string> *v =
213 fCanvasWidget->getCurrentCommandInfo(currentRow);
214
215
216 /* TODO(chudy): Add command type before parameters. Rename v
217 * to something more informative. */
218 if (v) {
219 std::vector<std::string>::iterator it;
220
221 QString info;
222 info.append("<b>Parameters: </b><br/>");
223 for (it = v->begin(); it != v->end(); ++it) {
224 info.append(QString((*it).c_str()));
225 info.append("<br/>");
226 }
227 fInspectorWidget->setDetailText(info);
228 }
229 }
230}
231
232void SkDebuggerGUI::toggleBreakpoint() {
233 QListWidgetItem* item = fListWidget->currentItem();
234 if (item->checkState() == Qt::Unchecked) {
235 item->setCheckState(Qt::Checked);
236
237
238 /* NOTE(chudy): If the command is toggled as hidden that takes
239 * precendence over the breakpoint icon.
240 */
241 if(item->data(Qt::UserRole + 2) == false) {
242 item->setData(Qt::DecorationRole,
243 QPixmap(":/images/Icons/delete.png"));
244 } else {
245 item->setData(Qt::DecorationRole,
246 QPixmap(":/images/Icons/breakpoint_16x16.png"));
247 }
248
249 } else {
250
251 /* NOTE(chudy): When untoggling as a breakpoint if the command
252 * is hidden then the portraying icon should remain the delete icon.
253 */
254 item->setCheckState(Qt::Unchecked);
255
256 if(item->data(Qt::UserRole + 2) == false) {
257 item->setData(Qt::DecorationRole,
258 QPixmap(":/images/Icons/delete.png"));
259 } else {
260 item->setData(Qt::DecorationRole,
261 QPixmap(":/images/Icons/blank.png"));
262 }
263
264 }
265}
266
267void SkDebuggerGUI::toggleDirectory() {
268 if (fDirectoryWidget->isHidden()) {
269 fDirectoryWidget->setHidden(false);
270 } else {
271 fDirectoryWidget->setHidden(true);
272 }
273}
274
275void SkDebuggerGUI::toggleFilter(QString string) {
276 for(int row=0; row<fListWidget->count(); row++) {
277 QListWidgetItem *item = fListWidget->item(row);
278 if (item->text() == string) {
279 item->setHidden(false);
280 } else {
281 item->setHidden(true);
282 }
283 }
284}
285
286void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
287 QIcon windowIcon;
288 windowIcon.addFile(QString::fromUtf8(":/images/Icons/skia.png"), QSize(), QIcon::Normal, QIcon::Off);
289 SkDebuggerGUI->setObjectName(QString::fromUtf8("SkDebuggerGUI"));
290 SkDebuggerGUI->resize(1200, 1000);
291 SkDebuggerGUI->setWindowIcon(windowIcon);
292
293 QIcon open;
294 open.addFile(QString::fromUtf8(":/images/Icons/package-br32.png"), QSize(), QIcon::Normal, QIcon::Off);
295 fActionOpen = new QAction(SkDebuggerGUI);
296 fActionOpen->setObjectName(QString::fromUtf8("actionOpen"));
297 fActionOpen->setIcon(open);
298
299 QIcon directory;
300 directory.addFile(QString::fromUtf8(":/images/Icons/drawer-open-icon.png"), QSize(), QIcon::Normal, QIcon::Off);
301 fActionDirectory = new QAction(SkDebuggerGUI);
302 fActionDirectory->setObjectName(QString::fromUtf8("actionDirectory"));
303 fActionDirectory->setIcon(directory);
304 fActionDirectory->setText("Toggle Directory");
305
306 QIcon rewind;
307 rewind.addFile(QString::fromUtf8(":/images/Icons/rewind.png"), QSize(), QIcon::Normal, QIcon::Off);
308 fActionRewind = new QAction(SkDebuggerGUI);
309 fActionRewind->setObjectName(QString::fromUtf8("actionRewind"));
310 fActionRewind->setIcon(rewind);
311 fActionRewind->setText("Rewind");
312
313 QIcon stepBack;
314 stepBack.addFile(QString::fromUtf8(":/images/Icons/back.png"), QSize(), QIcon::Normal, QIcon::Off);
315 fActionStepBack = new QAction(SkDebuggerGUI);
316 fActionStepBack->setObjectName(QString::fromUtf8("actionStepBack"));
317 fActionStepBack->setIcon(stepBack);
318 fActionStepBack->setText("Step Back");
319
320 QIcon stepForward;
321 stepForward.addFile(QString::fromUtf8(":/images/Icons/go-next.png"), QSize(), QIcon::Normal, QIcon::Off);
322 fActionStepForward = new QAction(SkDebuggerGUI);
323 fActionStepForward->setObjectName(QString::fromUtf8("actionStepBack"));
324 fActionStepForward->setIcon(stepForward);
325 fActionStepForward->setText("Step Forward");
326
327 QIcon play;
328 play.addFile(QString::fromUtf8(":/images/Icons/play.png"), QSize(), QIcon::Normal, QIcon::Off);
329 fActionPlay = new QAction(SkDebuggerGUI);
330 fActionPlay->setObjectName(QString::fromUtf8("actionPlay"));
331 fActionPlay->setIcon(play);
332 fActionPlay->setText("Play");
333
334 QIcon breakpoint;
335 breakpoint.addFile(QString::fromUtf8(":/images/Icons/breakpoint.png"), QSize(), QIcon::Normal, QIcon::Off);
336 fActionBreakpoint = new QAction(SkDebuggerGUI);
337 fActionBreakpoint->setObjectName(QString::fromUtf8("actionBreakpoint"));
338 fActionBreakpoint->setIcon(breakpoint);
339 fActionBreakpoint->setText("Show Breakpoints");
340
341 QIcon inspector;
342 inspector.addFile(QString::fromUtf8(":/images/Icons/inspector.png"), QSize(), QIcon::Normal, QIcon::Off);
343 fActionInspector = new QAction(SkDebuggerGUI);
344 fActionInspector->setObjectName(QString::fromUtf8("actionInspector"));
345 fActionInspector->setIcon(inspector);
346 fActionInspector->setText("Inspector");
347
348 QIcon deleteIcon;
349 deleteIcon.addFile(QString::fromUtf8(":/images/Icons/delete.png"), QSize(), QIcon::Normal, QIcon::Off);
350 fActionDelete = new QAction(SkDebuggerGUI);
351 fActionDelete->setObjectName(QString::fromUtf8("actionDelete"));
352 fActionDelete->setIcon(deleteIcon);
353 fActionDelete->setText("Delete Command");
354
355 QIcon reload;
356 reload.addFile(QString::fromUtf8(":/images/Icons/reload.png"), QSize(), QIcon::Normal, QIcon::Off);
357 fActionReload = new QAction(SkDebuggerGUI);
358 fActionReload->setObjectName(QString::fromUtf8("actionReload"));
359 fActionReload->setIcon(reload);
360 fActionReload->setText("Reset Picture");
361
362 QIcon settings;
363 settings.addFile(QString::fromUtf8(":/images/Icons/settings.png"), QSize(), QIcon::Normal, QIcon::Off);
364 fActionSettings = new QAction(SkDebuggerGUI);
365 fActionSettings->setObjectName(QString::fromUtf8("actionSettings"));
366 fActionSettings->setIcon(settings);
367 fActionSettings->setText("Settings");
368
369 QIcon cancel;
370 cancel.addFile(QString::fromUtf8(":/images/Icons/reset.png"), QSize(), QIcon::Normal, QIcon::Off);
371 fActionCancel = new QAction(SkDebuggerGUI);
372 fActionCancel->setObjectName(QString::fromUtf8("actionCancel"));
373 fActionCancel->setIcon(cancel);
374 fActionCancel->setText("Clear Filter");
375
376 fCentralWidget = new QWidget(SkDebuggerGUI);
377 fCentralWidget->setObjectName(QString::fromUtf8("centralWidget"));
378
379 fHorizontalLayout = new QHBoxLayout(fCentralWidget);
380 fHorizontalLayout->setSpacing(6);
381 fHorizontalLayout->setContentsMargins(11, 11, 11, 11);
382 fHorizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
383
384 fVerticalLayout = new QVBoxLayout();
385 fVerticalLayout->setSpacing(6);
386 fVerticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
387
388 fVerticalLayout_2 = new QVBoxLayout();
389 fVerticalLayout_2->setSpacing(6);
390 fVerticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
391
392 fListWidget = new QListWidget(fCentralWidget);
393 fListWidget->setItemDelegate(new SkListWidget(fListWidget));
394 fListWidget->setObjectName(QString::fromUtf8("listWidget"));
395 fListWidget->setMaximumWidth(250);
396
397 fInspectorWidget = new SkInspectorWidget();
398 fInspectorWidget->setObjectName(QString::fromUtf8("inspectorWidget"));
399 fInspectorWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
400 fInspectorWidget->setMaximumHeight(300);
401
402 fFilter = new QComboBox(fCentralWidget);
403 fFilter->setObjectName(QString::fromUtf8("comboBox"));
404 fFilter->addItem("--Filter By Available Commands--");
405
406 fDirectoryWidget = new QListWidget(fCentralWidget);
407 fDirectoryWidget->setObjectName(QString::fromUtf8("listWidget_2"));
408 fDirectoryWidget->setMaximumWidth(250);
409 fDirectoryWidget->setStyleSheet("QListWidget::Item {padding: 5px;}");
410
411 fVerticalLayout_2->addWidget(fListWidget);
412 fVerticalLayout_2->addWidget(fDirectoryWidget);
413
414 fCanvasWidget = new SkCanvasWidget(fCentralWidget);
415 fCanvasWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
416
417 fSettingsWidget = new SkSettingsWidget(fCentralWidget);
418 fSettingsWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
419 fSettingsWidget->setMaximumWidth(250);
420 fSettingsWidget->setHidden(true);
421
422 fHorizontalLayout_2 = new QHBoxLayout();
423 fHorizontalLayout_2->setSpacing(6);
424
425 fHorizontalLayout_2->addWidget(fCanvasWidget);
426 fHorizontalLayout_2->addWidget(fSettingsWidget);
427
428 fVerticalLayout->addLayout(fHorizontalLayout_2);
429 fVerticalLayout->addWidget(fInspectorWidget);
430
431 fHorizontalLayout->addLayout(fVerticalLayout_2);
432 fHorizontalLayout->addLayout(fVerticalLayout);
433
434 SkDebuggerGUI->setCentralWidget(fCentralWidget);
435 fStatusBar = new QStatusBar(SkDebuggerGUI);
436 fStatusBar->setObjectName(QString::fromUtf8("statusBar"));
437 SkDebuggerGUI->setStatusBar(fStatusBar);
438 fToolBar = new QToolBar(SkDebuggerGUI);
439 fToolBar->setObjectName(QString::fromUtf8("toolBar"));
440 fToolBar->setIconSize(QSize(24, 24));
441 //fToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
442 SkDebuggerGUI->addToolBar(Qt::TopToolBarArea, fToolBar);
443
444 QWidget *spacer = new QWidget();
445 spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
446
447 fToolBar->addAction(fActionOpen);
448 fToolBar->addSeparator();
449 fToolBar->addAction(fActionDirectory);
450 fToolBar->addSeparator();
451 fToolBar->addAction(fActionRewind);
452 fToolBar->addAction(fActionStepBack);
453 fToolBar->addAction(fActionStepForward);
454 fToolBar->addAction(fActionPlay);
455 fToolBar->addSeparator();
456 fToolBar->addAction(fActionBreakpoint);
457 fToolBar->addAction(fActionInspector);
458 fToolBar->addSeparator();
459 fToolBar->addAction(fActionDelete);
460 fToolBar->addAction(fActionReload);
461 fToolBar->addSeparator();
462 fToolBar->addAction(fActionSettings);
463 fToolBar->addWidget(spacer);
464 fToolBar->addWidget(fFilter);
465 fToolBar->addAction(fActionCancel);
466
467 // TODO(chudy): Remove static call.
468 fDirectoryWidgetActive = false;
469 fPath= "/usr/local/google/home/chudy/trunk-linux/debugger/skp";
470 setupDirectoryWidget();
471 fDirectoryWidgetActive = true;
472
473 fMenuBar = new QMenuBar(SkDebuggerGUI);
474
475 // File
476 fMenuFile = new QMenu(SkDebuggerGUI);
477 fMenuFile->setTitle("File");
478
479 fActionClose = new QAction(SkDebuggerGUI);
480 fActionClose->setText("Close");
481
482 fMenuFile->addAction(fActionOpen);
483 fMenuFile->addAction(fActionClose);
484
485 // View
486 fMenuView = new QMenu(SkDebuggerGUI);
487 fMenuView->setTitle("View");
488
489 fActionToggleCurrentCommand = new QAction(SkDebuggerGUI);
490 fActionToggleCurrentCommand->setText("Show Filter");
491
492 fMenuView->addAction(fActionToggleCurrentCommand);
493
494 // Navigate
495 fMenuNavigate = new QMenu(SkDebuggerGUI);
496 fMenuNavigate->setTitle("Navigate");
497
498 fActionGoToLine = new QAction(SkDebuggerGUI);
499 fActionGoToLine->setText("Go to Line...");
500 fActionGoToLine->setDisabled(true);
501
502 fMenuNavigate->addAction(fActionGoToLine);
503
504 // Menu Bar
505 fMenuBar->addAction(fMenuFile->menuAction());
506 fMenuBar->addAction(fMenuView->menuAction());
507 fMenuBar->addAction(fMenuNavigate->menuAction());
508
509 SkDebuggerGUI->setMenuBar(fMenuBar);
510
511 retranslateUi(SkDebuggerGUI);
512 QMetaObject::connectSlotsByName(SkDebuggerGUI);
513}
514
515void SkDebuggerGUI::setupDirectoryWidget() {
516 fDir = new QDir(fPath);
517 QRegExp r(".skp");
518 fDirectoryWidget->clear();
519 const QStringList files = fDir->entryList();
520 foreach (QString f, files) {
521 if (f.contains(r)) fDirectoryWidget->addItem(f);
522 }
523}
524
525// TODO(chudy): Is this necessary?
526void SkDebuggerGUI::retranslateUi(QMainWindow *SkDebuggerGUI) {
527 SkDebuggerGUI->setWindowTitle(QApplication::translate("SkDebuggerGUI", "SkDebuggerGUI", 0, QApplication::UnicodeUTF8));
528 fActionOpen->setText(QApplication::translate("SkDebuggerGUI", "Open", 0, QApplication::UnicodeUTF8));
529 fToolBar->setWindowTitle(QApplication::translate("SkDebuggerGUI", "toolBar", 0, QApplication::UnicodeUTF8));
530}
531
532void SkDebuggerGUI::loadPicture(QString fileName) {
533 fCanvasWidget->loadPicture(fileName);
534 std::vector<std::string> *cv = fCanvasWidget->getDrawCommands();
535 setupListWidget(cv);
536 setupComboBox(cv);
537}
538
539void SkDebuggerGUI::setupListWidget(std::vector<std::string>* cv) {
540 fListWidget->clear();
541 int counter = 0;
542 for (unsigned int i = 0; i < cv->size(); i++) {
543 QListWidgetItem *item = new QListWidgetItem();
544 item->setData(Qt::DisplayRole, (*cv)[i].c_str());
545 item->setData(Qt::UserRole + 1, counter++);
546 item->setData(Qt::UserRole + 2, true);
547 fListWidget->addItem(item);
548 }
549}
550
551void SkDebuggerGUI::setupComboBox(std::vector<std::string>* cv) {
552 fFilter->clear();
553 fFilter->addItem("--Filter By Available Commands--");
554
555 std::map<std::string, int> map;
556 for (unsigned int i = 0; i < cv->size(); i++) {
557 map[(*cv)[i]]++;
558 }
559
560 QString overview;
561 int counter;
562 for(std::map<std::string, int>::iterator it = map.begin(); it != map.end(); ++it) {
563 overview.append((it->first).c_str());
564 overview.append(": ");
565 overview.append(QString::number(it->second));
566 overview.append("<br/>");
567 counter+=it->second;
568 fFilter->addItem((it->first).c_str());
569 }
570 QString total;
571 total.append("Total Draw Commands: ");
572 total.append(QString::number(counter));
573 total.append("<br/>");
574 overview.insert(0, total);
575
576 overview.append("<br/>");
577 overview.append("SkBitmap Width: ");
578 // NOTE(chudy): This is where we can pull out the SkPictures width.
579 overview.append(QString::number(fCanvasWidget->getBitmapWidth()));
580 overview.append("px<br/>");
581 overview.append("SkBitmap Height: ");
582 overview.append(QString::number(fCanvasWidget->getBitmapHeight()));
583 overview.append("px");
584 fInspectorWidget->setOverviewText(overview);
585
586 // NOTE(chudy): Makes first item unselectable.
587 QStandardItemModel* model =
588 qobject_cast<QStandardItemModel*>(fFilter->model());
589 QModelIndex firstIndex = model->index(0, fFilter->modelColumn(),
590 fFilter->rootModelIndex());
591 QStandardItem* firstItem = model->itemFromIndex(firstIndex);
592 firstItem->setSelectable(false);
593}