Commit 2b892040 authored by Christiaan Janssen's avatar Christiaan Janssen
Browse files

QmlProfiler: Next and Previous controls

Change-Id: Iedac6ee9f3cc9855a5825fc5f82b79a06da4f1fb
Reviewed-on: http://codereview.qt.nokia.com/767

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
Reviewed-by: default avatarChristiaan Janssen <christiaan.janssen@nokia.com>
parent 33256aa6
......@@ -72,6 +72,38 @@ Rectangle {
property int selectedEventIndex : -1;
property bool mouseTracking: false;
onSelectedEventIndexChanged: {
if ((!mouseTracking) && Plotter.ranges.length > 0
&& selectedEventIndex > -1 && selectedEventIndex < Plotter.ranges.length) {
// re-center flickable if necessary
var event = Plotter.ranges[selectedEventIndex];
var xs = Plotter.xScale(canvas);
var startTime = Plotter.ranges[0].start;
if (rangeMover.value + startTime> event.start) {
rangeMover.x = Math.max(0,
Math.floor((event.start - startTime) / xs - canvas.canvasWindow.x - rangeMover.width/2) );
} else if (rangeMover.value + startTime + rangeMover.width * xs < event.start + event.duration) {
rangeMover.x = Math.floor((event.start + event.duration - startTime) / xs - canvas.canvasWindow.x - rangeMover.width/2);
}
}
}
function nextEvent() {
if (Plotter.ranges.length > 0) {
++selectedEventIndex;
if (selectedEventIndex >= Plotter.ranges.length)
selectedEventIndex = 0;
}
}
function prevEvent() {
if (Plotter.ranges.length > 0) {
--selectedEventIndex;
if (selectedEventIndex < 0)
selectedEventIndex = Plotter.ranges.length - 1;
}
}
//handle debug data coming from C++
Connections {
target: connection
......@@ -225,10 +257,14 @@ Rectangle {
smooth: true
property bool componentIsCompleted: false
Component.onCompleted: componentIsCompleted = true;
Component.onCompleted: {
componentIsCompleted = true;
updateDetails();
}
property bool isSelected: root.selectedEventIndex == index;
onIsSelectedChanged: {
onIsSelectedChanged: updateDetails();
function updateDetails() {
if (!root.mouseTracking && componentIsCompleted) {
if (isSelected) {
enableSelected(0, 0);
......@@ -307,7 +343,7 @@ Rectangle {
id: labels
width: 150
color: "#dcdcdc"
y: 12
y: 24
height: flick.height
property int rowCount: 5
......@@ -329,6 +365,12 @@ Rectangle {
anchors.right: parent.right
color: "#cccccc"
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: root.hideRangeDetails();
}
}
//bottom border divider
......
......@@ -69,6 +69,7 @@ BorderImage {
Column {
id: col
anchors.top: typeTitle.bottom
x: 2
Detail {
label: "Duration"
content: rangeDetails.duration < 1000 ?
......
......@@ -66,7 +66,7 @@ TiledCanvas {
ctxt.stroke();
}
ctxt.fillText(prettyPrintTime(ii*timePerBlock + realStartTime), x + 5, 10);
ctxt.fillText(prettyPrintTime(ii*timePerBlock + realStartTime), x + 5, 5 + labels.y/2);
}
}
......@@ -119,6 +119,7 @@ TiledCanvas {
displayRect.visible = true
}
onExited: displayRect.visible = false
onEntered: root.hideRangeDetails();
}
Rectangle {
......@@ -127,12 +128,14 @@ TiledCanvas {
border.color: Qt.darker(color)
border.width: 1
radius: 2
height: labels.y
height: labels.y - 2
y: 1
width: displayText.width + 10
visible: false
Text {
id: displayText
x: 5
y: labels.y/2 - 6
font.pointSize: 8
}
}
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at info@qt.nokia.com.
**
**************************************************************************/
import QtQuick 1.0
import Monitor 1.0
import "MainView.js" as Plotter
Rectangle {
property string label
signal clicked
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: -1
width: 30; height: 22
border.color: "#cc80b2f6"
color: "transparent"
Text {
anchors.centerIn: parent
text: label
color: "white"
font.pixelSize: 14
}
MouseArea {
anchors.fill: parent
onClicked: parent.clicked()
}
}
......@@ -2,16 +2,17 @@
<qresource prefix="/qmlprofiler">
<file>Detail.qml</file>
<file>Label.qml</file>
<file>lock.png</file>
<file>MainView.js</file>
<file>MainView.qml</file>
<file>popup.png</file>
<file>range.png</file>
<file>RangeDetails.qml</file>
<file>RangeMover.qml</file>
<file>ToolButton.qml</file>
<file>analyzer_category_small.png</file>
<file>TimeDisplay.qml</file>
<file>clean_pane_small.png</file>
<file>prev.png</file>
<file>next.png</file>
<file>toolbarbg.png</file>
</qresource>
</RCC>
......@@ -55,7 +55,6 @@ OTHER_FILES += \
qml/MainView.qml \
qml/RangeDetails.qml \
qml/RangeMover.qml \
qml/ToolButton.qml \
qml/MainView.js \
qml/TimeDisplay.qml
......
......@@ -34,7 +34,7 @@
#include "tracewindow.h"
#include "qmlprofilerplugin.h"
#include <utils/styledbar.h>
#include <QtCore/qdebug.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qdatastream.h>
......@@ -47,6 +47,7 @@
#include <QtCore/qstack.h>
#include <QGraphicsObject>
#include <QToolButton>
#include <QtDeclarative/qdeclarativeview.h>
#include <QtDeclarative/qdeclarativecontext.h>
......@@ -282,6 +283,21 @@ TraceWindow::TraceWindow(QWidget *parent)
//new QmlJSDebugger::QDeclarativeViewObserver(m_view, m_view);
}
Utils::StyledBar *bar = new Utils::StyledBar(this);
bar->setSingleRow(true);
bar->setMinimumWidth(150);
QHBoxLayout *toolBarLayout = new QHBoxLayout(bar);
toolBarLayout->setMargin(0);
toolBarLayout->setSpacing(0);
QToolButton *buttonPrev= new QToolButton;
buttonPrev->setIcon(QIcon(":/qmlprofiler/prev.png"));
connect(buttonPrev, SIGNAL(clicked()), this, SIGNAL(jumpToPrev()));
QToolButton *buttonNext= new QToolButton;
buttonNext->setIcon(QIcon(":/qmlprofiler/next.png"));
connect(buttonNext, SIGNAL(clicked()), this, SIGNAL(jumpToNext()));
toolBarLayout->addWidget(buttonPrev);
toolBarLayout->addWidget(buttonNext);
m_view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
m_view->setFocus();
groupLayout->addWidget(m_view);
......@@ -312,6 +328,8 @@ void TraceWindow::reset(QDeclarativeDebugConnection *conn)
connect(m_view->rootObject(), SIGNAL(updateCursorPosition()), this, SLOT(updateCursorPosition()));
connect(m_view->rootObject(), SIGNAL(updateTimer()), this, SLOT(updateTimer()));
connect(this, SIGNAL(jumpToPrev()), m_view->rootObject(), SLOT(prevEvent()));
connect(this, SIGNAL(jumpToNext()), m_view->rootObject(), SLOT(nextEvent()));
connect(this, SIGNAL(internalClearDisplay()), m_view->rootObject(), SLOT(clearAll()));
}
......
......@@ -76,6 +76,8 @@ signals:
void range(int type, int nestingLevel, int nestingInType, qint64 startTime, qint64 length, const QStringList &data, const QString &fileName, int line);
void internalClearDisplay();
void jumpToPrev();
void jumpToNext();
private:
QWeakPointer<TracePlugin> m_plugin;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment