QmlProfiler: disable navigation buttons when no data

Change-Id: Ieee8a4c45919c4598d86a817e3489bd3e519d1c8
Reviewed-on: http://codereview.qt.nokia.com/1181
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
This commit is contained in:
Christiaan Janssen
2011-07-05 15:50:32 +02:00
parent 0358f70983
commit 7756371cea
4 changed files with 27 additions and 14 deletions

View File

@@ -36,7 +36,6 @@
var values = [ ]; //events
var ranges = [ ];
var frameFps = [ ];
var valuesdone = false;
var xmargin = 0;
var ymargin = 0;
var drawFpsGraph = false;
@@ -55,7 +54,6 @@ function reset()
frameFps = [];
xmargin = 0;
ymargin = 0;
valuesdone = false;
nestingDepth = [];
}

View File

@@ -38,9 +38,7 @@ import "MainView.js" as Plotter
Rectangle {
id: root
property variant colors: Plotter.colors //the colors used for the timeline data
property bool xRay: false //useful for seeing "nested" ranges (but redraw is buggy -- QGV problem?)
property Item currentItem //currently selected item in the view
property bool dataAvailable: false;
// move the cursor in the editor
signal updateCursorPosition
@@ -55,6 +53,7 @@ Rectangle {
function clearData() {
Plotter.reset();
view.clearData();
root.dataAvailable = false;
rangeMover.x = 2
rangeMover.opacity = 0
}
@@ -62,7 +61,6 @@ Rectangle {
function clearAll() {
clearData();
selectedEventIndex = -1;
Plotter.valuesdone = false;
canvas.requestPaint();
view.visible = false;
root.elapsedTime = 0;
@@ -132,21 +130,21 @@ Rectangle {
Connections {
target: connection
onEvent: {
if (Plotter.valuesdone) {
if (root.dataAvailable) {
root.clearData();
}
if (!Plotter.valuesdone && event === 0) //### only handle paint event
if (!root.dataAvailable && event === 0) //### only handle paint event
Plotter.values.push(time);
}
onRange: {
if (Plotter.valuesdone) {
if (root.dataAvailable) {
root.clearData();
}
// todo: consider nestingLevel
if (!Plotter.valuesdone) {
if (!root.dataAvailable) {
if (!Plotter.nestingDepth[type])
Plotter.nestingDepth[type] = nestingInType;
else
@@ -158,7 +156,7 @@ Rectangle {
}
onComplete: {
Plotter.valuesdone = true;
root.dataAvailable = true;
Plotter.calcFps();
view.visible = true;
view.setRanges(Plotter.ranges);
@@ -264,7 +262,7 @@ Rectangle {
delegate: Rectangle {
id: obj
property color baseColor: colors[type]
property color baseColor: Plotter.colors[type]
property color myColor: baseColor
function conditionalHide() {
@@ -302,7 +300,6 @@ Rectangle {
}
function enableSelected(x,y) {
currentItem = obj
myColor = Qt.darker(baseColor, 1.2)
rangeDetails.duration = duration
rangeDetails.label = label
@@ -429,7 +426,7 @@ Rectangle {
canvasWindow.height: height
onDrawRegion: {
if (Plotter.valuesdone)
if (root.dataAvailable)
Plotter.plot(canvas, ctxt, region);
else
Plotter.drawGraph(canvas, ctxt, region) //just draw the background

View File

@@ -73,20 +73,27 @@ TraceWindow::TraceWindow(QWidget *parent)
QToolButton *buttonPrev= new QToolButton;
buttonPrev->setIcon(QIcon(":/qmlprofiler/prev.png"));
connect(buttonPrev, SIGNAL(clicked()), this, SIGNAL(jumpToPrev()));
connect(this, SIGNAL(enableToolbar(bool)), buttonPrev, SLOT(setEnabled(bool)));
QToolButton *buttonNext= new QToolButton;
buttonNext->setIcon(QIcon(":/qmlprofiler/next.png"));
connect(buttonNext, SIGNAL(clicked()), this, SIGNAL(jumpToNext()));
connect(this, SIGNAL(enableToolbar(bool)), buttonNext, SLOT(setEnabled(bool)));
QToolButton *buttonZoomIn = new QToolButton;
buttonZoomIn->setIcon(QIcon(":/qmlprofiler/magnifier-plus.png"));
connect(buttonZoomIn, SIGNAL(clicked()), this, SIGNAL(zoomIn()));
connect(this, SIGNAL(enableToolbar(bool)), buttonZoomIn, SLOT(setEnabled(bool)));
QToolButton *buttonZoomOut = new QToolButton;
buttonZoomOut->setIcon(QIcon(":/qmlprofiler/magnifier-minus.png"));
connect(buttonZoomOut, SIGNAL(clicked()), this, SIGNAL(zoomOut()));
connect(this, SIGNAL(enableToolbar(bool)), buttonZoomOut, SLOT(setEnabled(bool)));
toolBarLayout->addWidget(buttonPrev);
toolBarLayout->addWidget(buttonNext);
toolBarLayout->addWidget(buttonZoomIn);
toolBarLayout->addWidget(buttonZoomOut);
m_view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
m_view->setFocus();
groupLayout->addWidget(m_view);
@@ -115,8 +122,11 @@ void TraceWindow::reset(QmlJsDebugClient::QDeclarativeDebugConnection *conn)
m_view->rootContext()->setContextProperty("connection", m_plugin.data());
m_view->setSource(QUrl("qrc:/qmlprofiler/MainView.qml"));
updateToolbar();
connect(m_view->rootObject(), SIGNAL(updateCursorPosition()), this, SLOT(updateCursorPosition()));
connect(m_view->rootObject(), SIGNAL(updateTimer()), this, SLOT(updateTimer()));
connect(m_view->rootObject(), SIGNAL(dataAvailableChanged()), this, SLOT(updateToolbar()));
connect(this, SIGNAL(jumpToPrev()), m_view->rootObject(), SLOT(prevEvent()));
connect(this, SIGNAL(jumpToNext()), m_view->rootObject(), SLOT(nextEvent()));
connect(this, SIGNAL(zoomIn()), m_view->rootObject(), SLOT(zoomIn()));
@@ -144,6 +154,12 @@ void TraceWindow::clearDisplay()
emit internalClearDisplay();
}
void TraceWindow::updateToolbar()
{
bool dataAvailable = m_view->rootObject()->property("dataAvailable").toBool();
emit enableToolbar(dataAvailable);
}
void TraceWindow::setRecording(bool recording)
{
if (m_plugin)

View File

@@ -64,6 +64,7 @@ public slots:
void updateCursorPosition();
void updateTimer();
void clearDisplay();
void updateToolbar();
signals:
void viewUpdated();
@@ -76,6 +77,7 @@ signals:
void jumpToNext();
void zoomIn();
void zoomOut();
void enableToolbar(bool);
private:
QWeakPointer<QmlProfilerTraceClient> m_plugin;