aboutsummaryrefslogtreecommitdiffhomepage
path: root/debugger/QT
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-12 20:42:12 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-12 20:42:12 +0000
commitd26c70688fda9dd33369f5ea9da78f26c8666d63 (patch)
treece3aa7fb49c1d211c287405d17b77bc62eaacea9 /debugger/QT
parent4349c31077fb4b5129e06a83098214047e6e8417 (diff)
Update debugger GUI to have profile button & list widget to optionally display time
Diffstat (limited to 'debugger/QT')
-rw-r--r--debugger/QT/SkDebuggerGUI.cpp56
-rw-r--r--debugger/QT/SkDebuggerGUI.h11
-rw-r--r--debugger/QT/SkListWidget.cpp18
3 files changed, 62 insertions, 23 deletions
diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp
index 140841d459..ef970f4010 100644
--- a/debugger/QT/SkDebuggerGUI.cpp
+++ b/debugger/QT/SkDebuggerGUI.cpp
@@ -17,6 +17,7 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
, fToolBar(this)
, fActionOpen(this)
, fActionBreakpoint(this)
+ , fActionProfile(this)
, fActionCancel(this)
, fActionClearBreakpoints(this)
, fActionClearDeletes(this)
@@ -64,6 +65,7 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionInspector()));
connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionSettings()));
connect(&fFilter, SIGNAL(activated(QString)), this, SLOT(toggleFilter(QString)));
+ connect(&fActionProfile, SIGNAL(triggered()), this, SLOT(actionProfile()));
connect(&fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel()));
connect(&fActionClearBreakpoints, SIGNAL(triggered()), this, SLOT(actionClearBreakpoints()));
connect(&fActionClearDeletes, SIGNAL(triggered()), this, SLOT(actionClearDeletes()));
@@ -117,6 +119,9 @@ void SkDebuggerGUI::showDeletes() {
}
}
+void SkDebuggerGUI::actionProfile() {
+}
+
void SkDebuggerGUI::actionCancel() {
for (int row = 0; row < fListWidget.count(); row++) {
fListWidget.item(row)->setHidden(false);
@@ -207,11 +212,10 @@ void SkDebuggerGUI::actionRewind() {
}
void SkDebuggerGUI::actionSave() {
- QString filename;
- filename.append(fPath);
- filename.append("/");
- filename.append(fDirectoryWidget.currentItem()->text());
- saveToFile(filename);
+ fFileName = fPath.toAscii();
+ fFileName.append("/");
+ fFileName.append(fDirectoryWidget.currentItem()->text().toAscii());
+ saveToFile(fFileName);
}
void SkDebuggerGUI::actionSaveAs() {
@@ -220,7 +224,7 @@ void SkDebuggerGUI::actionSaveAs() {
if (!filename.endsWith(".skp", Qt::CaseInsensitive)) {
filename.append(".skp");
}
- saveToFile(filename);
+ saveToFile(SkString(filename.toAscii()));
}
void SkDebuggerGUI::actionScale(float scaleFactor) {
@@ -256,29 +260,28 @@ void SkDebuggerGUI::drawComplete() {
fInspectorWidget.setClip(fDebugger.getCurrentClip());
}
-void SkDebuggerGUI::saveToFile(QString filename) {
- SkFILEWStream file(filename.toAscii());
+void SkDebuggerGUI::saveToFile(const SkString& filename) {
+ SkFILEWStream file(filename.c_str());
fDebugger.makePicture()->serialize(&file);
}
void SkDebuggerGUI::loadFile(QListWidgetItem *item) {
if (fDirectoryWidgetActive) {
- QString fileName;
- fileName.append(fPath);
- fileName.append("/");
- fileName.append(item->text());
- loadPicture(fileName);
+ fFileName = fPath.toAscii();
+ fFileName.append("/");
+ fFileName.append(item->text().toAscii());
+ loadPicture(fFileName);
}
}
void SkDebuggerGUI::openFile() {
- QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "",
+ QString temp = QFileDialog::getOpenFileName(this, tr("Open File"), "",
tr("Files (*.*)"));
fDirectoryWidgetActive = false;
- if (!fileName.isNull()) {
- QFileInfo pathInfo(fileName);
+ if (!temp.isEmpty()) {
+ QFileInfo pathInfo(temp);
fPath = pathInfo.path();
- loadPicture(fileName);
+ loadPicture(SkString(temp.toAscii()));
setupDirectoryWidget();
}
fDirectoryWidgetActive = true;
@@ -392,6 +395,12 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
fActionDirectory.setShortcut(QKeySequence(tr("Ctrl+D")));
fActionDirectory.setText("Directory");
+ QIcon profile;
+ profile.addFile(QString::fromUtf8(":/images/Ico/reload.png"), QSize(),
+ QIcon::Normal, QIcon::Off);
+ fActionProfile.setIcon(profile);
+ fActionProfile.setText("Profile");
+
QIcon inspector;
inspector.addFile(QString::fromUtf8(":/images/Ico/inspector.png"),
QSize(), QIcon::Normal, QIcon::Off);
@@ -505,13 +514,17 @@ void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
fToolBar.addSeparator();
fToolBar.addAction(&fActionInspector);
fToolBar.addSeparator();
+ fToolBar.addAction(&fActionProfile);
+
+ fToolBar.addSeparator();
fToolBar.addWidget(&fSpacer);
fToolBar.addWidget(&fFilter);
fToolBar.addAction(&fActionCancel);
// TODO(chudy): Remove static call.
fDirectoryWidgetActive = false;
- fPath = "/usr/local/google/home/chudy/trunk-git/trunk/skp";
+ fPath = "";
+ fFileName = "";
setupDirectoryWidget();
fDirectoryWidgetActive = true;
@@ -572,9 +585,10 @@ void SkDebuggerGUI::setupDirectoryWidget() {
}
}
-void SkDebuggerGUI::loadPicture(QString fileName) {
+void SkDebuggerGUI::loadPicture(const SkString& fileName) {
+ fFileName = fileName;
fLoading = true;
- SkStream* stream = SkNEW_ARGS(SkFILEStream, (fileName.toAscii()));
+ SkStream* stream = SkNEW_ARGS(SkFILEStream, (fileName.c_str()));
SkPicture* picture = SkNEW_ARGS(SkPicture, (stream, NULL, &SkImageDecoder::DecodeStream));
fCanvasWidget.resetWidgetTransform();
fDebugger.loadPicture(picture);
@@ -625,6 +639,8 @@ void SkDebuggerGUI::setupListWidget(SkTDArray<SkString*>* command) {
indent += 10;
}
+ item->setData(Qt::UserRole + 4, -1.0);
+
fListWidget.addItem(item);
}
}
diff --git a/debugger/QT/SkDebuggerGUI.h b/debugger/QT/SkDebuggerGUI.h
index f460067675..0ad275e76a 100644
--- a/debugger/QT/SkDebuggerGUI.h
+++ b/debugger/QT/SkDebuggerGUI.h
@@ -61,6 +61,11 @@ private slots:
void actionBreakpoints();
/**
+ Profile the commands
+ */
+ void actionProfile();
+
+ /**
Cancels the command filter in the list widget.
*/
void actionCancel();
@@ -206,6 +211,7 @@ private:
QAction fActionOpen;
QAction fActionBreakpoint;
+ QAction fActionProfile;
QAction fActionCancel;
QAction fActionClearBreakpoints;
QAction fActionClearDeletes;
@@ -244,6 +250,7 @@ private:
SkSettingsWidget fSettingsWidget;
QString fPath;
+ SkString fFileName;
bool fDirectoryWidgetActive;
QMenuBar fMenuBar;
@@ -268,12 +275,12 @@ private:
Pipes a QString in with the location of the filename, proceeds to updating
the listwidget, combowidget and inspectorwidget.
*/
- void loadPicture(QString fileName);
+ void loadPicture(const SkString& fileName);
/**
Creates a picture of the current canvas.
*/
- void saveToFile(QString filename);
+ void saveToFile(const SkString& filename);
/**
Populates the list widget with the vector of strings passed in.
diff --git a/debugger/QT/SkListWidget.cpp b/debugger/QT/SkListWidget.cpp
index 2d8d2da9a4..c03ac56304 100644
--- a/debugger/QT/SkListWidget.cpp
+++ b/debugger/QT/SkListWidget.cpp
@@ -65,6 +65,9 @@ void SkListWidget::paint (QPainter *painter,
QString drawCommandText = index.data(Qt::DisplayRole).toString();
QString drawCommandNumber = index.data(Qt::UserRole + 1).toString();
+ float time = index.data(Qt::UserRole + 4).toFloat();
+ QString drawTime;
+ drawTime.setNum(time, 'g', 3);
/* option.rect is a struct that Qt uses as a target to draw into. Following
* the format (x1,y1,x2,y2) x1 and y1 represent where the painter can start
@@ -77,6 +80,7 @@ void SkListWidget::paint (QPainter *painter,
* affect size of text but will scale icons. */
static const int kImageSpace = 35;
static const int kCommandNumberSpace = 30;
+ static const int kTimeSpace = 30;
// Breakpoint Icon
r = option.rect.adjusted(5, 10, -10, -10);
@@ -87,7 +91,12 @@ void SkListWidget::paint (QPainter *painter,
deleteIcon.paint(painter, r, Qt::AlignVCenter|Qt::AlignLeft);
// Draw Command
- r = option.rect.adjusted(kImageSpace+kCommandNumberSpace+indent, 0, -10, -7);
+ if (time >= 0.0) {
+ r = option.rect.adjusted(kImageSpace+kCommandNumberSpace+kTimeSpace+indent, 0, -10, -7);
+ } else {
+ // don't need time offset
+ r = option.rect.adjusted(kImageSpace+kCommandNumberSpace+indent, 0, -10, -7);
+ }
painter->drawText(r.left(), r.top(), r.width(), r.height(),
Qt::AlignBottom|Qt::AlignLeft, drawCommandText, &r);
@@ -95,6 +104,13 @@ void SkListWidget::paint (QPainter *painter,
r = option.rect.adjusted(kImageSpace, 0, -10, -7);
painter->drawText(r.left(), r.top(), r.width(), r.height(),
Qt::AlignBottom|Qt::AlignLeft, drawCommandNumber, &r);
+
+ if (time >= 0.0) {
+ // Draw time
+ r = option.rect.adjusted(kImageSpace+kCommandNumberSpace, 0, -10, -7);
+ painter->drawText(r.left(), r.top(), r.width(), r.height(),
+ Qt::AlignBottom|Qt::AlignLeft, drawTime, &r);
+ }
}
QSize SkListWidget::sizeHint ( const QStyleOptionViewItem & option,