2012-06-29 14:21:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SkDebuggerGUI.h"
|
2012-08-13 14:26:36 +00:00
|
|
|
#include "SkGraphics.h"
|
2012-06-29 14:21:22 +00:00
|
|
|
#include <QListWidgetItem>
|
|
|
|
|
|
|
|
SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
|
2012-07-10 13:19:25 +00:00
|
|
|
QMainWindow(parent)
|
2012-07-31 12:49:52 +00:00
|
|
|
, fCentralWidget(this)
|
|
|
|
, fStatusBar(this)
|
|
|
|
, fToolBar(this)
|
2012-07-10 13:19:25 +00:00
|
|
|
, fActionOpen(this)
|
|
|
|
, fActionBreakpoint(this)
|
|
|
|
, fActionCancel(this)
|
2012-07-17 15:40:51 +00:00
|
|
|
, fActionClearBreakpoints(this)
|
2012-07-16 18:35:23 +00:00
|
|
|
, fActionClearDeletes(this)
|
2012-07-10 13:19:25 +00:00
|
|
|
, fActionClose(this)
|
2012-07-16 18:35:23 +00:00
|
|
|
, fActionCreateBreakpoint(this)
|
2012-07-10 13:19:25 +00:00
|
|
|
, fActionDelete(this)
|
|
|
|
, fActionDirectory(this)
|
|
|
|
, fActionGoToLine(this)
|
|
|
|
, fActionInspector(this)
|
|
|
|
, fActionPlay(this)
|
2012-07-16 18:35:23 +00:00
|
|
|
, fActionPause(this)
|
2012-07-10 13:19:25 +00:00
|
|
|
, fActionRewind(this)
|
2012-07-28 20:16:11 +00:00
|
|
|
, fActionSave(this)
|
|
|
|
, fActionSaveAs(this)
|
2012-07-17 15:40:51 +00:00
|
|
|
, fActionShowDeletes(this)
|
2012-07-10 13:19:25 +00:00
|
|
|
, fActionStepBack(this)
|
|
|
|
, fActionStepForward(this)
|
2012-07-26 20:26:44 +00:00
|
|
|
, fActionZoomIn(this)
|
|
|
|
, fActionZoomOut(this)
|
|
|
|
, fMapper(this)
|
2012-07-10 13:19:25 +00:00
|
|
|
, fListWidget(&fCentralWidget)
|
|
|
|
, fDirectoryWidget(&fCentralWidget)
|
2012-08-07 16:12:23 +00:00
|
|
|
, fCanvasWidget(this, &fDebugger)
|
2012-07-10 13:19:25 +00:00
|
|
|
, fMenuBar(this)
|
|
|
|
, fMenuFile(this)
|
|
|
|
, fMenuNavigate(this)
|
|
|
|
, fMenuView(this)
|
2012-07-17 15:40:51 +00:00
|
|
|
, fBreakpointsActivated(false)
|
|
|
|
, fDeletesActivated(false)
|
|
|
|
, fPause(false)
|
2012-07-19 13:41:27 +00:00
|
|
|
, fLoading(false)
|
2012-07-10 13:19:25 +00:00
|
|
|
{
|
2012-06-29 14:21:22 +00:00
|
|
|
setupUi(this);
|
2012-07-26 19:38:22 +00:00
|
|
|
connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(registerListClick(QListWidgetItem *)));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fActionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
|
2012-07-26 19:38:22 +00:00
|
|
|
connect(&fActionDirectory, SIGNAL(triggered()), this, SLOT(toggleDirectory()));
|
|
|
|
connect(&fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(loadFile(QListWidgetItem *)));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete()));
|
2012-07-26 19:38:22 +00:00
|
|
|
connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(toggleBreakpoint()));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind()));
|
|
|
|
connect(&fActionPlay, SIGNAL(triggered()), this, SLOT(actionPlay()));
|
|
|
|
connect(&fActionStepBack, SIGNAL(triggered()), this, SLOT(actionStepBack()));
|
2012-07-26 19:38:22 +00:00
|
|
|
connect(&fActionStepForward, SIGNAL(triggered()), this, SLOT(actionStepForward()));
|
|
|
|
connect(&fActionBreakpoint, SIGNAL(triggered()), this, SLOT(actionBreakpoints()));
|
|
|
|
connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionInspector()));
|
|
|
|
connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionSettings()));
|
|
|
|
connect(&fFilter, SIGNAL(activated(QString)), this, SLOT(toggleFilter(QString)));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel()));
|
2012-07-17 15:40:51 +00:00
|
|
|
connect(&fActionClearBreakpoints, SIGNAL(triggered()), this, SLOT(actionClearBreakpoints()));
|
|
|
|
connect(&fActionClearDeletes, SIGNAL(triggered()), this, SLOT(actionClearDeletes()));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose()));
|
2012-07-26 19:38:22 +00:00
|
|
|
connect(fSettingsWidget.getVisibilityButton(), SIGNAL(toggled(bool)), this, SLOT(actionCommandFilter()));
|
|
|
|
connect(fSettingsWidget.getGLCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionGLWidget(bool)));
|
|
|
|
connect(fSettingsWidget.getRasterCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionRasterWidget(bool)));
|
|
|
|
connect(&fActionPause, SIGNAL(toggled(bool)), this, SLOT(pauseDrawing(bool)));
|
2012-07-16 18:35:23 +00:00
|
|
|
connect(&fActionCreateBreakpoint, SIGNAL(activated()), this, SLOT(toggleBreakpoint()));
|
2012-07-17 15:40:51 +00:00
|
|
|
connect(&fActionShowDeletes, SIGNAL(triggered()), this, SLOT(showDeletes()));
|
2012-07-26 19:38:22 +00:00
|
|
|
connect(&fCanvasWidget, SIGNAL(hitChanged(int)), this, SLOT(selectCommand(int)));
|
|
|
|
connect(&fCanvasWidget, SIGNAL(hitChanged(int)), &fSettingsWidget, SLOT(updateHit(int)));
|
|
|
|
connect(&fCanvasWidget, SIGNAL(scaleFactorChanged(float)), this, SLOT(actionScale(float)));
|
|
|
|
connect(&fCanvasWidget, SIGNAL(commandChanged(int)), &fSettingsWidget, SLOT(updateCommand(int)));
|
2012-07-28 20:16:11 +00:00
|
|
|
connect(&fActionSaveAs, SIGNAL(triggered()), this, SLOT(actionSaveAs()));
|
|
|
|
connect(&fActionSave, SIGNAL(triggered()), this, SLOT(actionSave()));
|
2012-07-17 15:40:51 +00:00
|
|
|
|
2012-07-26 20:26:44 +00:00
|
|
|
fMapper.setMapping(&fActionZoomIn, 1);
|
|
|
|
fMapper.setMapping(&fActionZoomOut, -1);
|
|
|
|
|
|
|
|
connect(&fActionZoomIn, SIGNAL(triggered()), &fMapper, SLOT(map()));
|
|
|
|
connect(&fActionZoomOut, SIGNAL(triggered()), &fMapper, SLOT(map()));
|
|
|
|
connect(&fMapper, SIGNAL(mapped(int)), &fCanvasWidget, SLOT(keyZoom(int)));
|
|
|
|
|
2012-07-17 15:40:51 +00:00
|
|
|
fInspectorWidget.setDisabled(true);
|
2012-07-19 13:41:27 +00:00
|
|
|
fMenuEdit.setDisabled(true);
|
|
|
|
fMenuNavigate.setDisabled(true);
|
|
|
|
fMenuView.setDisabled(true);
|
2012-08-13 14:26:36 +00:00
|
|
|
|
|
|
|
SkGraphics::Init();
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-08-13 14:26:36 +00:00
|
|
|
SkDebuggerGUI::~SkDebuggerGUI() {
|
|
|
|
SkGraphics::Term();
|
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
void SkDebuggerGUI::actionBreakpoints() {
|
2012-07-17 15:40:51 +00:00
|
|
|
fBreakpointsActivated = !fBreakpointsActivated;
|
|
|
|
for (int row = 0; row < fListWidget.count(); row++) {
|
|
|
|
QListWidgetItem *item = fListWidget.item(row);
|
|
|
|
item->setHidden(item->checkState() == Qt::Unchecked && fBreakpointsActivated);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
2012-07-17 15:40:51 +00:00
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-17 15:40:51 +00:00
|
|
|
void SkDebuggerGUI::showDeletes() {
|
|
|
|
fDeletesActivated = !fDeletesActivated;
|
2012-07-10 13:19:25 +00:00
|
|
|
for (int row = 0; row < fListWidget.count(); row++) {
|
|
|
|
QListWidgetItem *item = fListWidget.item(row);
|
2012-08-07 16:12:23 +00:00
|
|
|
item->setHidden(fDebugger.isCommandVisible(row)
|
|
|
|
&& fDeletesActivated);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionCancel() {
|
2012-07-10 13:19:25 +00:00
|
|
|
for (int row = 0; row < fListWidget.count(); row++) {
|
|
|
|
fListWidget.item(row)->setHidden(false);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-17 15:40:51 +00:00
|
|
|
void SkDebuggerGUI::actionClearBreakpoints() {
|
|
|
|
for (int row = 0; row < fListWidget.count(); row++) {
|
|
|
|
QListWidgetItem* item = fListWidget.item(row);
|
|
|
|
item->setCheckState(Qt::Unchecked);
|
|
|
|
item->setData(Qt::DecorationRole,
|
|
|
|
QPixmap(":/images/Icons/blank.png"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionClearDeletes() {
|
|
|
|
for (int row = 0; row < fListWidget.count(); row++) {
|
|
|
|
QListWidgetItem* item = fListWidget.item(row);
|
|
|
|
item->setData(Qt::UserRole + 2, QPixmap(":/images/Icons/blank.png"));
|
2012-08-07 16:12:23 +00:00
|
|
|
fDebugger.setCommandVisible(row, true);
|
2012-07-17 15:40:51 +00:00
|
|
|
}
|
|
|
|
if (fPause) {
|
|
|
|
fCanvasWidget.drawTo(fPausedRow);
|
|
|
|
} else {
|
|
|
|
fCanvasWidget.drawTo(fListWidget.currentRow());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::actionCommandFilter() {
|
2012-08-07 16:12:23 +00:00
|
|
|
fDebugger.highlightCurrentCommand(
|
2012-07-10 13:19:25 +00:00
|
|
|
fSettingsWidget.getVisibilityButton()->isChecked());
|
|
|
|
fCanvasWidget.drawTo(fListWidget.currentRow());
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionClose() {
|
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionDelete() {
|
2012-07-17 15:40:51 +00:00
|
|
|
int currentRow = fListWidget.currentRow();
|
2012-07-10 13:19:25 +00:00
|
|
|
QListWidgetItem* item = fListWidget.currentItem();
|
2012-07-17 15:40:51 +00:00
|
|
|
|
2012-08-07 16:12:23 +00:00
|
|
|
if (fDebugger.isCommandVisible(currentRow)) {
|
2012-07-17 15:40:51 +00:00
|
|
|
item->setData(Qt::UserRole + 2, QPixmap(":/images/Icons/delete.png"));
|
2012-08-07 16:12:23 +00:00
|
|
|
fDebugger.setCommandVisible(currentRow, false);
|
2012-06-29 14:21:22 +00:00
|
|
|
} else {
|
2012-07-17 15:40:51 +00:00
|
|
|
item->setData(Qt::UserRole + 2, QPixmap(":/images/Icons/blank.png"));
|
2012-08-07 16:12:23 +00:00
|
|
|
fDebugger.setCommandVisible(currentRow, true);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
2012-07-17 15:40:51 +00:00
|
|
|
|
2012-07-16 18:35:23 +00:00
|
|
|
if (fPause) {
|
|
|
|
fCanvasWidget.drawTo(fPausedRow);
|
|
|
|
} else {
|
|
|
|
fCanvasWidget.drawTo(currentRow);
|
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-07-26 19:38:22 +00:00
|
|
|
void SkDebuggerGUI::actionGLWidget(bool isToggled) {
|
|
|
|
fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kGPU_WidgetType, !isToggled);
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::actionInspector() {
|
2012-07-10 13:19:25 +00:00
|
|
|
if (fInspectorWidget.isHidden()) {
|
|
|
|
fInspectorWidget.setHidden(false);
|
2012-06-29 14:21:22 +00:00
|
|
|
} else {
|
2012-07-10 13:19:25 +00:00
|
|
|
fInspectorWidget.setHidden(true);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionPlay() {
|
2012-07-10 13:19:25 +00:00
|
|
|
for (int row = fListWidget.currentRow() + 1; row < fListWidget.count();
|
2012-07-09 20:26:53 +00:00
|
|
|
row++) {
|
2012-07-10 13:19:25 +00:00
|
|
|
QListWidgetItem *item = fListWidget.item(row);
|
2012-06-29 14:21:22 +00:00
|
|
|
if (item->checkState() == Qt::Checked) {
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.setCurrentItem(item);
|
2012-06-29 14:21:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.setCurrentRow(fListWidget.count() - 1);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-07-26 19:38:22 +00:00
|
|
|
void SkDebuggerGUI::actionRasterWidget(bool isToggled) {
|
|
|
|
fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kRaster_8888_WidgetType, !isToggled);
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::actionRewind() {
|
2012-07-16 18:35:23 +00:00
|
|
|
fListWidget.setCurrentRow(0);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-07-28 20:16:11 +00:00
|
|
|
void SkDebuggerGUI::actionSave() {
|
|
|
|
QString filename;
|
|
|
|
filename.append(fPath);
|
|
|
|
filename.append("/");
|
|
|
|
filename.append(fDirectoryWidget.currentItem()->text());
|
|
|
|
saveToFile(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionSaveAs() {
|
|
|
|
QString filename = QFileDialog::getSaveFileName(this, "Save File", "",
|
|
|
|
"Skia Picture (*skp)");
|
2012-07-28 23:26:10 +00:00
|
|
|
if (!filename.endsWith(".skp", Qt::CaseInsensitive)) {
|
2012-07-28 20:16:11 +00:00
|
|
|
filename.append(".skp");
|
|
|
|
}
|
|
|
|
saveToFile(filename);
|
|
|
|
}
|
|
|
|
|
2012-07-09 20:26:53 +00:00
|
|
|
void SkDebuggerGUI::actionScale(float scaleFactor) {
|
2012-07-10 13:19:25 +00:00
|
|
|
fSettingsWidget.setZoomText(scaleFactor);
|
2012-07-09 20:26:53 +00:00
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::actionSettings() {
|
2012-07-10 13:19:25 +00:00
|
|
|
if (fSettingsWidget.isHidden()) {
|
|
|
|
fSettingsWidget.setHidden(false);
|
2012-06-29 14:21:22 +00:00
|
|
|
} else {
|
2012-07-10 13:19:25 +00:00
|
|
|
fSettingsWidget.setHidden(true);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionStepBack() {
|
2012-07-10 13:19:25 +00:00
|
|
|
int currentRow = fListWidget.currentRow();
|
2012-06-29 14:21:22 +00:00
|
|
|
if (currentRow != 0) {
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.setCurrentRow(currentRow - 1);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionStepForward() {
|
2012-07-10 13:19:25 +00:00
|
|
|
int currentRow = fListWidget.currentRow();
|
2012-06-29 14:21:22 +00:00
|
|
|
QString curRow = QString::number(currentRow);
|
2012-07-10 13:19:25 +00:00
|
|
|
QString curCount = QString::number(fListWidget.count());
|
|
|
|
if (currentRow < fListWidget.count() - 1) {
|
|
|
|
fListWidget.setCurrentRow(currentRow + 1);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-03 17:32:05 +00:00
|
|
|
void SkDebuggerGUI::drawComplete() {
|
2012-08-07 16:12:23 +00:00
|
|
|
fInspectorWidget.setMatrix(fDebugger.getCurrentMatrix());
|
|
|
|
fInspectorWidget.setClip(fDebugger.getCurrentClip());
|
2012-08-03 17:32:05 +00:00
|
|
|
}
|
|
|
|
|
2012-07-28 20:16:11 +00:00
|
|
|
void SkDebuggerGUI::saveToFile(QString filename) {
|
|
|
|
SkFILEWStream file(filename.toAscii());
|
2012-08-07 16:12:23 +00:00
|
|
|
fDebugger.makePicture()->serialize(&file);
|
2012-07-28 20:16:11 +00:00
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::loadFile(QListWidgetItem *item) {
|
|
|
|
if (fDirectoryWidgetActive) {
|
|
|
|
QString fileName;
|
|
|
|
fileName.append(fPath);
|
|
|
|
fileName.append("/");
|
|
|
|
fileName.append(item->text());
|
|
|
|
loadPicture(fileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::openFile() {
|
2012-07-09 20:26:53 +00:00
|
|
|
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "",
|
|
|
|
tr("Files (*.*)"));
|
2012-06-29 14:21:22 +00:00
|
|
|
fDirectoryWidgetActive = false;
|
|
|
|
if (!fileName.isNull()) {
|
|
|
|
QFileInfo pathInfo(fileName);
|
|
|
|
fPath = pathInfo.path();
|
|
|
|
loadPicture(fileName);
|
|
|
|
setupDirectoryWidget();
|
|
|
|
}
|
|
|
|
fDirectoryWidgetActive = true;
|
|
|
|
}
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
void SkDebuggerGUI::pauseDrawing(bool isPaused) {
|
2012-08-07 16:12:23 +00:00
|
|
|
fPause = isPaused;
|
|
|
|
fPausedRow = fListWidget.currentRow();
|
|
|
|
fCanvasWidget.drawTo(fPausedRow);
|
2012-07-09 20:26:53 +00:00
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
|
2012-07-19 13:41:27 +00:00
|
|
|
if(!fLoading) {
|
|
|
|
int currentRow = fListWidget.currentRow();
|
2012-07-26 19:38:22 +00:00
|
|
|
|
|
|
|
if (currentRow != -1) {
|
|
|
|
if (!fPause) {
|
|
|
|
fCanvasWidget.drawTo(currentRow);
|
|
|
|
}
|
2012-08-07 20:41:37 +00:00
|
|
|
SkTDArray<SkString*> *currInfo = fDebugger.getCommandInfo(
|
2012-07-26 19:38:22 +00:00
|
|
|
currentRow);
|
|
|
|
|
|
|
|
/* TODO(chudy): Add command type before parameters. Rename v
|
|
|
|
* to something more informative. */
|
2012-08-07 20:41:37 +00:00
|
|
|
if (currInfo) {
|
2012-07-26 19:38:22 +00:00
|
|
|
QString info;
|
|
|
|
info.append("<b>Parameters: </b><br/>");
|
2012-08-07 20:41:37 +00:00
|
|
|
for (int i = 0; i < currInfo->count(); i++) {
|
|
|
|
|
|
|
|
info.append(QString((*currInfo)[i]->c_str()));
|
2012-07-26 19:38:22 +00:00
|
|
|
info.append("<br/>");
|
|
|
|
}
|
|
|
|
fInspectorWidget.setDetailText(info);
|
|
|
|
fInspectorWidget.setDisabled(false);
|
2012-07-19 13:41:27 +00:00
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
2012-07-26 19:38:22 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-12 21:58:14 +00:00
|
|
|
void SkDebuggerGUI::selectCommand(int command) {
|
|
|
|
if (fPause) {
|
|
|
|
fListWidget.setCurrentRow(command);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::toggleBreakpoint() {
|
2012-07-10 13:19:25 +00:00
|
|
|
QListWidgetItem* item = fListWidget.currentItem();
|
2012-06-29 14:21:22 +00:00
|
|
|
if (item->checkState() == Qt::Unchecked) {
|
|
|
|
item->setCheckState(Qt::Checked);
|
2012-07-12 14:15:54 +00:00
|
|
|
item->setData(Qt::DecorationRole,
|
|
|
|
QPixmap(":/images/Icons/breakpoint_16x16.png"));
|
2012-06-29 14:21:22 +00:00
|
|
|
} else {
|
|
|
|
item->setCheckState(Qt::Unchecked);
|
2012-07-12 14:15:54 +00:00
|
|
|
item->setData(Qt::DecorationRole,
|
|
|
|
QPixmap(":/images/Icons/blank.png"));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::toggleDirectory() {
|
2012-08-07 16:12:23 +00:00
|
|
|
fDirectoryWidget.setHidden(!fDirectoryWidget.isHidden());
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::toggleFilter(QString string) {
|
2012-07-10 13:19:25 +00:00
|
|
|
for (int row = 0; row < fListWidget.count(); row++) {
|
|
|
|
QListWidgetItem *item = fListWidget.item(row);
|
2012-08-07 16:12:23 +00:00
|
|
|
item->setHidden(item->text() != string);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
|
|
|
|
QIcon windowIcon;
|
2012-07-09 20:26:53 +00:00
|
|
|
windowIcon.addFile(QString::fromUtf8(":/images/Icons/skia.png"), QSize(),
|
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-06-29 14:21:22 +00:00
|
|
|
SkDebuggerGUI->setObjectName(QString::fromUtf8("SkDebuggerGUI"));
|
|
|
|
SkDebuggerGUI->resize(1200, 1000);
|
|
|
|
SkDebuggerGUI->setWindowIcon(windowIcon);
|
2012-07-10 13:19:25 +00:00
|
|
|
SkDebuggerGUI->setWindowTitle("Skia Debugger");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionOpen.setShortcuts(QKeySequence::Open);
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionOpen.setText("Open");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon breakpoint;
|
|
|
|
breakpoint.addFile(QString::fromUtf8(":/images/Icons/breakpoint.png"),
|
2012-07-09 20:26:53 +00:00
|
|
|
QSize(), QIcon::Normal, QIcon::Off);
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionBreakpoint.setShortcut(QKeySequence(tr("Ctrl+B")));
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionBreakpoint.setIcon(breakpoint);
|
2012-07-17 15:40:51 +00:00
|
|
|
fActionBreakpoint.setText("Breakpoints");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon cancel;
|
2012-07-16 18:35:23 +00:00
|
|
|
cancel.addFile(QString::fromUtf8(":/images/Ico/reload.png"), QSize(),
|
2012-07-09 20:26:53 +00:00
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionCancel.setIcon(cancel);
|
|
|
|
fActionCancel.setText("Clear Filter");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-17 15:40:51 +00:00
|
|
|
fActionClearBreakpoints.setShortcut(QKeySequence(tr("Alt+B")));
|
|
|
|
fActionClearBreakpoints.setText("Clear Breakpoints");
|
|
|
|
|
|
|
|
fActionClearDeletes.setShortcut(QKeySequence(tr("Alt+X")));
|
|
|
|
fActionClearDeletes.setText("Clear Deletes");
|
|
|
|
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionClose.setShortcuts(QKeySequence::Quit);
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionClose.setText("Exit");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionCreateBreakpoint.setShortcut(QKeySequence(tr("B")));
|
|
|
|
fActionCreateBreakpoint.setText("Set Breakpoint");
|
|
|
|
|
|
|
|
fActionDelete.setShortcut(QKeySequence(tr("X")));
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionDelete.setText("Delete Command");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionDirectory.setShortcut(QKeySequence(tr("Ctrl+D")));
|
|
|
|
fActionDirectory.setText("Directory");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
QIcon inspector;
|
2012-07-16 18:35:23 +00:00
|
|
|
inspector.addFile(QString::fromUtf8(":/images/Ico/inspector.png"),
|
2012-07-09 20:26:53 +00:00
|
|
|
QSize(), QIcon::Normal, QIcon::Off);
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionInspector.setShortcut(QKeySequence(tr("Ctrl+I")));
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionInspector.setIcon(inspector);
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionInspector.setText("Inspector");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon play;
|
2012-07-16 18:35:23 +00:00
|
|
|
play.addFile(QString::fromUtf8(":/images/Ico/play.png"), QSize(),
|
2012-07-09 20:26:53 +00:00
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionPlay.setShortcut(QKeySequence(tr("Ctrl+P")));
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionPlay.setIcon(play);
|
|
|
|
fActionPlay.setText("Play");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-16 18:35:23 +00:00
|
|
|
QIcon pause;
|
|
|
|
pause.addFile(QString::fromUtf8(":/images/Ico/pause.png"), QSize(),
|
2012-07-09 20:26:53 +00:00
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionPause.setShortcut(QKeySequence(tr("Space")));
|
|
|
|
fActionPause.setCheckable(true);
|
|
|
|
fActionPause.setIcon(pause);
|
|
|
|
fActionPause.setText("Pause");
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon rewind;
|
2012-07-16 18:35:23 +00:00
|
|
|
rewind.addFile(QString::fromUtf8(":/images/Ico/rewind.png"), QSize(),
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionRewind.setShortcut(QKeySequence(tr("Ctrl+R")));
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionRewind.setIcon(rewind);
|
|
|
|
fActionRewind.setText("Rewind");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-28 20:16:11 +00:00
|
|
|
fActionSave.setShortcut(QKeySequence::Save);
|
|
|
|
fActionSave.setText("Save");
|
|
|
|
fActionSave.setDisabled(true);
|
|
|
|
fActionSaveAs.setShortcut(QKeySequence::SaveAs);
|
|
|
|
fActionSaveAs.setText("Save As");
|
|
|
|
fActionSaveAs.setDisabled(true);
|
|
|
|
|
2012-07-17 15:40:51 +00:00
|
|
|
fActionShowDeletes.setShortcut(QKeySequence(tr("Ctrl+X")));
|
|
|
|
fActionShowDeletes.setText("Deleted Commands");
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon stepBack;
|
2012-07-16 18:35:23 +00:00
|
|
|
stepBack.addFile(QString::fromUtf8(":/images/Ico/previous.png"), QSize(),
|
2012-07-09 20:26:53 +00:00
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionStepBack.setShortcut(QKeySequence(tr("[")));
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionStepBack.setIcon(stepBack);
|
|
|
|
fActionStepBack.setText("Step Back");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon stepForward;
|
2012-07-16 18:35:23 +00:00
|
|
|
stepForward.addFile(QString::fromUtf8(":/images/Ico/next.png"),
|
2012-07-10 13:19:25 +00:00
|
|
|
QSize(), QIcon::Normal, QIcon::Off);
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionStepForward.setShortcut(QKeySequence(tr("]")));
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionStepForward.setIcon(stepForward);
|
|
|
|
fActionStepForward.setText("Step Forward");
|
|
|
|
|
2012-07-26 20:26:44 +00:00
|
|
|
fActionZoomIn.setShortcut(QKeySequence(tr("Ctrl+=")));
|
|
|
|
fActionZoomIn.setText("Zoom In");
|
|
|
|
fActionZoomOut.setShortcut(QKeySequence(tr("Ctrl+-")));
|
|
|
|
fActionZoomOut.setText("Zoom Out");
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.setItemDelegate(new SkListWidget(&fListWidget));
|
|
|
|
fListWidget.setObjectName(QString::fromUtf8("listWidget"));
|
|
|
|
fListWidget.setMaximumWidth(250);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fFilter.addItem("--Filter By Available Commands--");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fDirectoryWidget.setMaximumWidth(250);
|
|
|
|
fDirectoryWidget.setStyleSheet("QListWidget::Item {padding: 5px;}");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fCanvasWidget.setSizePolicy(QSizePolicy::Expanding,
|
2012-07-09 20:26:53 +00:00
|
|
|
QSizePolicy::Expanding);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fInspectorWidget.setSizePolicy(QSizePolicy::Expanding,
|
2012-07-09 20:26:53 +00:00
|
|
|
QSizePolicy::Expanding);
|
2012-07-10 13:19:25 +00:00
|
|
|
fInspectorWidget.setMaximumHeight(300);
|
|
|
|
|
|
|
|
fSettingsWidget.setSizePolicy(QSizePolicy::Expanding,
|
|
|
|
QSizePolicy::Expanding);
|
|
|
|
fSettingsWidget.setMaximumWidth(250);
|
|
|
|
|
|
|
|
fLeftColumnLayout.setSpacing(6);
|
|
|
|
fLeftColumnLayout.addWidget(&fListWidget);
|
|
|
|
fLeftColumnLayout.addWidget(&fDirectoryWidget);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fCanvasAndSettingsLayout.setSpacing(6);
|
|
|
|
fCanvasAndSettingsLayout.addWidget(&fCanvasWidget);
|
|
|
|
fCanvasAndSettingsLayout.addWidget(&fSettingsWidget);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fMainAndRightColumnLayout.setSpacing(6);
|
|
|
|
fMainAndRightColumnLayout.addLayout(&fCanvasAndSettingsLayout);
|
|
|
|
fMainAndRightColumnLayout.addWidget(&fInspectorWidget);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-31 12:49:52 +00:00
|
|
|
fCentralWidget.setLayout(&fContainerLayout);
|
2012-07-10 13:19:25 +00:00
|
|
|
fContainerLayout.setSpacing(6);
|
|
|
|
fContainerLayout.setContentsMargins(11, 11, 11, 11);
|
|
|
|
fContainerLayout.addLayout(&fLeftColumnLayout);
|
|
|
|
fContainerLayout.addLayout(&fMainAndRightColumnLayout);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
SkDebuggerGUI->setCentralWidget(&fCentralWidget);
|
|
|
|
SkDebuggerGUI->setStatusBar(&fStatusBar);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-16 18:35:23 +00:00
|
|
|
fToolBar.setIconSize(QSize(32, 32));
|
2012-07-10 13:19:25 +00:00
|
|
|
fToolBar.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
|
|
SkDebuggerGUI->addToolBar(Qt::TopToolBarArea, &fToolBar);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-28 20:16:11 +00:00
|
|
|
fSpacer.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fToolBar.addAction(&fActionRewind);
|
|
|
|
fToolBar.addAction(&fActionStepBack);
|
2012-07-16 18:35:23 +00:00
|
|
|
fToolBar.addAction(&fActionPause);
|
2012-07-10 13:19:25 +00:00
|
|
|
fToolBar.addAction(&fActionStepForward);
|
|
|
|
fToolBar.addAction(&fActionPlay);
|
|
|
|
fToolBar.addSeparator();
|
2012-07-16 18:35:23 +00:00
|
|
|
fToolBar.addAction(&fActionInspector);
|
2012-07-10 13:19:25 +00:00
|
|
|
fToolBar.addSeparator();
|
2012-07-28 20:16:11 +00:00
|
|
|
fToolBar.addWidget(&fSpacer);
|
2012-07-10 13:19:25 +00:00
|
|
|
fToolBar.addWidget(&fFilter);
|
|
|
|
fToolBar.addAction(&fActionCancel);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
// TODO(chudy): Remove static call.
|
|
|
|
fDirectoryWidgetActive = false;
|
2012-07-26 19:38:22 +00:00
|
|
|
fPath = "/usr/local/google/home/chudy/trunk-git/trunk/skp";
|
2012-06-29 14:21:22 +00:00
|
|
|
setupDirectoryWidget();
|
|
|
|
fDirectoryWidgetActive = true;
|
|
|
|
|
|
|
|
// Menu Bar
|
2012-07-10 13:19:25 +00:00
|
|
|
fMenuFile.setTitle("File");
|
|
|
|
fMenuFile.addAction(&fActionOpen);
|
2012-07-28 20:16:11 +00:00
|
|
|
fMenuFile.addAction(&fActionSave);
|
|
|
|
fMenuFile.addAction(&fActionSaveAs);
|
2012-07-10 13:19:25 +00:00
|
|
|
fMenuFile.addAction(&fActionClose);
|
2012-07-16 18:35:23 +00:00
|
|
|
|
|
|
|
fMenuEdit.setTitle("Edit");
|
|
|
|
fMenuEdit.addAction(&fActionDelete);
|
2012-07-17 15:40:51 +00:00
|
|
|
fMenuEdit.addAction(&fActionClearDeletes);
|
|
|
|
fMenuEdit.addSeparator();
|
2012-07-16 18:35:23 +00:00
|
|
|
fMenuEdit.addAction(&fActionCreateBreakpoint);
|
2012-07-17 15:40:51 +00:00
|
|
|
fMenuEdit.addAction(&fActionClearBreakpoints);
|
2012-07-16 18:35:23 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fMenuNavigate.setTitle("Navigate");
|
2012-07-16 18:35:23 +00:00
|
|
|
fMenuNavigate.addAction(&fActionRewind);
|
|
|
|
fMenuNavigate.addAction(&fActionStepBack);
|
|
|
|
fMenuNavigate.addAction(&fActionStepForward);
|
|
|
|
fMenuNavigate.addAction(&fActionPlay);
|
|
|
|
fMenuNavigate.addAction(&fActionPause);
|
2012-07-10 13:19:25 +00:00
|
|
|
fMenuNavigate.addAction(&fActionGoToLine);
|
2012-07-16 18:35:23 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fMenuView.setTitle("View");
|
2012-07-16 18:35:23 +00:00
|
|
|
fMenuView.addAction(&fActionBreakpoint);
|
2012-07-17 15:40:51 +00:00
|
|
|
fMenuView.addAction(&fActionShowDeletes);
|
2012-07-26 20:26:44 +00:00
|
|
|
fMenuView.addAction(&fActionZoomIn);
|
|
|
|
fMenuView.addAction(&fActionZoomOut);
|
2012-07-16 18:35:23 +00:00
|
|
|
|
|
|
|
fMenuWindows.setTitle("Window");
|
|
|
|
fMenuWindows.addAction(&fActionInspector);
|
|
|
|
fMenuWindows.addAction(&fActionDirectory);
|
2012-07-10 13:19:25 +00:00
|
|
|
|
|
|
|
fActionGoToLine.setText("Go to Line...");
|
|
|
|
fActionGoToLine.setDisabled(true);
|
|
|
|
fMenuBar.addAction(fMenuFile.menuAction());
|
2012-07-16 18:35:23 +00:00
|
|
|
fMenuBar.addAction(fMenuEdit.menuAction());
|
2012-07-10 13:19:25 +00:00
|
|
|
fMenuBar.addAction(fMenuView.menuAction());
|
|
|
|
fMenuBar.addAction(fMenuNavigate.menuAction());
|
2012-07-16 18:35:23 +00:00
|
|
|
fMenuBar.addAction(fMenuWindows.menuAction());
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-09 20:26:53 +00:00
|
|
|
fPause = false;
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
SkDebuggerGUI->setMenuBar(&fMenuBar);
|
2012-06-29 14:21:22 +00:00
|
|
|
QMetaObject::connectSlotsByName(SkDebuggerGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::setupDirectoryWidget() {
|
2012-07-10 13:19:25 +00:00
|
|
|
QDir dir(fPath);
|
2012-06-29 14:21:22 +00:00
|
|
|
QRegExp r(".skp");
|
2012-07-10 13:19:25 +00:00
|
|
|
fDirectoryWidget.clear();
|
|
|
|
const QStringList files = dir.entryList();
|
2012-06-29 14:21:22 +00:00
|
|
|
foreach (QString f, files) {
|
2012-07-09 20:26:53 +00:00
|
|
|
if (f.contains(r))
|
2012-07-10 13:19:25 +00:00
|
|
|
fDirectoryWidget.addItem(f);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::loadPicture(QString fileName) {
|
2012-07-19 13:41:27 +00:00
|
|
|
fLoading = true;
|
2012-08-07 16:12:23 +00:00
|
|
|
SkStream* stream = new SkFILEStream(fileName.toAscii());
|
|
|
|
SkPicture* picture = new SkPicture(stream);
|
2012-08-14 16:00:32 +00:00
|
|
|
fCanvasWidget.resetWidgetTransform();
|
2012-08-07 16:12:23 +00:00
|
|
|
fDebugger.loadPicture(picture);
|
2012-08-14 16:00:32 +00:00
|
|
|
fCanvasWidget.drawTo(fDebugger.index());
|
2012-08-07 16:12:23 +00:00
|
|
|
SkSafeUnref(stream);
|
|
|
|
SkSafeUnref(picture);
|
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
// Will this automatically clear out due to nature of refcnt?
|
|
|
|
SkTDArray<SkString*>* commands = fDebugger.getDrawCommands();
|
2012-08-07 16:12:23 +00:00
|
|
|
|
2012-07-09 20:26:53 +00:00
|
|
|
/* fDebugCanvas is reinitialized every load picture. Need it to retain value
|
2012-08-07 16:12:23 +00:00
|
|
|
* of the visibility filter.
|
|
|
|
* TODO(chudy): This should be deprecated since fDebugger is not
|
|
|
|
* recreated.
|
|
|
|
* */
|
|
|
|
fDebugger.highlightCurrentCommand(fSettingsWidget.getVisibilityButton()->isChecked());
|
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
setupListWidget(commands);
|
|
|
|
setupComboBox(commands);
|
2012-07-17 15:40:51 +00:00
|
|
|
fInspectorWidget.setDisabled(false);
|
2012-07-12 14:31:25 +00:00
|
|
|
fSettingsWidget.setDisabled(false);
|
2012-07-19 13:41:27 +00:00
|
|
|
fMenuEdit.setDisabled(false);
|
|
|
|
fMenuNavigate.setDisabled(false);
|
|
|
|
fMenuView.setDisabled(false);
|
2012-07-28 20:16:11 +00:00
|
|
|
fActionSave.setDisabled(false);
|
|
|
|
fActionSaveAs.setDisabled(false);
|
2012-07-19 13:41:27 +00:00
|
|
|
fLoading = false;
|
|
|
|
actionPlay();
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
void SkDebuggerGUI::setupListWidget(SkTDArray<SkString*>* command) {
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.clear();
|
2012-06-29 14:21:22 +00:00
|
|
|
int counter = 0;
|
2012-08-07 20:41:37 +00:00
|
|
|
for (int i = 0; i < command->count(); i++) {
|
2012-06-29 14:21:22 +00:00
|
|
|
QListWidgetItem *item = new QListWidgetItem();
|
2012-08-07 20:41:37 +00:00
|
|
|
item->setData(Qt::DisplayRole, (*command)[i]->c_str());
|
2012-06-29 14:21:22 +00:00
|
|
|
item->setData(Qt::UserRole + 1, counter++);
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.addItem(item);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
void SkDebuggerGUI::setupComboBox(SkTDArray<SkString*>* command) {
|
2012-07-10 13:19:25 +00:00
|
|
|
fFilter.clear();
|
|
|
|
fFilter.addItem("--Filter By Available Commands--");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
std::map<std::string, int> map;
|
2012-08-07 20:41:37 +00:00
|
|
|
for (int i = 0; i < command->count(); i++) {
|
|
|
|
map[(*command)[i]->c_str()]++;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString overview;
|
2012-08-07 16:12:23 +00:00
|
|
|
int counter = 0;
|
2012-07-09 20:26:53 +00:00
|
|
|
for (std::map<std::string, int>::iterator it = map.begin(); it != map.end();
|
|
|
|
++it) {
|
2012-06-29 14:21:22 +00:00
|
|
|
overview.append((it->first).c_str());
|
|
|
|
overview.append(": ");
|
|
|
|
overview.append(QString::number(it->second));
|
|
|
|
overview.append("<br/>");
|
2012-07-09 20:26:53 +00:00
|
|
|
counter += it->second;
|
2012-07-10 13:19:25 +00:00
|
|
|
fFilter.addItem((it->first).c_str());
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
QString total;
|
|
|
|
total.append("Total Draw Commands: ");
|
|
|
|
total.append(QString::number(counter));
|
|
|
|
total.append("<br/>");
|
|
|
|
overview.insert(0, total);
|
|
|
|
|
|
|
|
overview.append("<br/>");
|
2012-08-07 16:12:23 +00:00
|
|
|
overview.append("SkPicture Width: ");
|
2012-06-29 14:21:22 +00:00
|
|
|
// NOTE(chudy): This is where we can pull out the SkPictures width.
|
2012-08-07 16:12:23 +00:00
|
|
|
overview.append(QString::number(fDebugger.pictureWidth()));
|
2012-06-29 14:21:22 +00:00
|
|
|
overview.append("px<br/>");
|
2012-08-07 16:12:23 +00:00
|
|
|
overview.append("SkPicture Height: ");
|
|
|
|
overview.append(QString::number(fDebugger.pictureHeight()));
|
2012-06-29 14:21:22 +00:00
|
|
|
overview.append("px");
|
2012-07-10 13:19:25 +00:00
|
|
|
fInspectorWidget.setOverviewText(overview);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
// NOTE(chudy): Makes first item unselectable.
|
2012-07-09 20:26:53 +00:00
|
|
|
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(
|
2012-07-10 13:19:25 +00:00
|
|
|
fFilter.model());
|
|
|
|
QModelIndex firstIndex = model->index(0, fFilter.modelColumn(),
|
|
|
|
fFilter.rootModelIndex());
|
2012-06-29 14:21:22 +00:00
|
|
|
QStandardItem* firstItem = model->itemFromIndex(firstIndex);
|
|
|
|
firstItem->setSelectable(false);
|
|
|
|
}
|