summaryrefslogtreecommitdiff
path: root/src/plugins/qmlprofiler/qml/TimeDisplay.qml
diff options
context:
space:
mode:
authorChristiaan Janssen <christiaan.janssen@nokia.com>2011-10-11 17:52:39 +0200
committerChristiaan Janssen <christiaan.janssen@nokia.com>2011-11-01 15:13:39 +0100
commitc9f977c39a185f0a8a53a4bf820ff812520fbcd1 (patch)
treea7177400a9087fa7df380ca861ccbed261d61198 /src/plugins/qmlprofiler/qml/TimeDisplay.qml
parenteb5a60db14009ec38e6090b52f4665ea87ae6464 (diff)
downloadqt-creator-c9f977c39a185f0a8a53a4bf820ff812520fbcd1.tar.gz
QmlProfiler: main view with fixed height and scrollable
Change-Id: Ib77ad6ba5afe13d692d85c7027e3e1d4b2fbb6a7 Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'src/plugins/qmlprofiler/qml/TimeDisplay.qml')
-rw-r--r--src/plugins/qmlprofiler/qml/TimeDisplay.qml123
1 files changed, 23 insertions, 100 deletions
diff --git a/src/plugins/qmlprofiler/qml/TimeDisplay.qml b/src/plugins/qmlprofiler/qml/TimeDisplay.qml
index 06c84a70b0..b96740d9b5 100644
--- a/src/plugins/qmlprofiler/qml/TimeDisplay.qml
+++ b/src/plugins/qmlprofiler/qml/TimeDisplay.qml
@@ -32,37 +32,43 @@
import QtQuick 1.0
import Monitor 1.0
-import "MainView.js" as Plotter
TiledCanvas {
id: timeDisplay
- canvasSize {
- width: timeDisplay.width
- height: timeDisplay.height
- }
+ property variant startTime : 0
+ property variant endTime : 0
+ property variant timePerPixel: 0
+
+ canvasSize.width: timeDisplay.width
+ canvasSize.height: timeDisplay.height
tileSize.width: width
tileSize.height: height
canvasWindow.width: width
canvasWindow.height: height
+ Connections {
+ target: zoomControl
+ onRangeChanged: {
+ startTime = zoomControl.startTime();
+ endTime = zoomControl.endTime();
+ requestPaint();
+ }
+ }
Component.onCompleted: {
requestPaint();
}
-
- property variant startTime;
- property variant endTime;
-
- onStartTimeChanged: requestPaint();
- onEndTimeChanged: requestPaint();
- onWidthChanged: requestPaint();
- onHeightChanged: requestPaint();
-
- property variant timePerPixel;
+ onWidthChanged: {
+ requestPaint();
+ }
+ onHeightChanged: {
+ requestPaint();
+ }
onDrawRegion: {
- drawBackgroundBars( ctxt, region );
+ ctxt.fillStyle = "white";
+ ctxt.fillRect(0, 0, width, height);
var totalTime = endTime - startTime;
var spacing = width / totalTime;
@@ -89,30 +95,8 @@ TiledCanvas {
ctxt.lineTo(x, height);
ctxt.stroke();
- ctxt.strokeStyle = "#C0C0C0";
- for (var jj=1; jj < 5; jj++) {
- var xx = Math.floor(ii*pixelsPerBlock + jj*pixelsPerSection - realStartPos);
- ctxt.beginPath();
- ctxt.moveTo(xx, labels.y);
- ctxt.lineTo(xx, height);
- ctxt.stroke();
- }
-
- ctxt.fillText(prettyPrintTime(ii*timePerBlock + realStartTime), x + 5, 5 + labels.y/2);
- }
- }
-
- function drawBackgroundBars( ctxt, region ) {
- var barHeight = Math.round(labels.height / labels.rowCount);
- var originY = labels.y
- for (var i=0; i<labels.rowCount; i++) {
- ctxt.fillStyle = i%2 ? "#f3f3f3" : "white"
- ctxt.strokeStyle = i%2 ? "#f3f3f3" : "white"
- ctxt.fillRect(0, i * barHeight + originY, width, barHeight);
+ ctxt.fillText(prettyPrintTime(ii*timePerBlock + realStartTime), x + 5, height/2 + 4);
}
-
- ctxt.fillStyle = "white";
- ctxt.fillRect(0, 0, width, originY);
}
function prettyPrintTime( t )
@@ -129,65 +113,4 @@ TiledCanvas {
t = Math.floor(t - m*60);
return m+"m"+t+"s";
}
-
- function detailedPrintTime( t )
- {
- if (t <= 0) return "0";
- if (t<1000) return t+" ns";
- t = Math.floor(t/1000);
- if (t<1000) return t+" μs";
- return (t/1000) + " ms";
- }
-
- // show exact time
- MouseArea {
- width: parent.width
- height: labels.y
- hoverEnabled: true
-
- function setStartTime(xpos) {
- var realTime = startTime + xpos * timePerPixel;
- timeDisplayText.text = detailedPrintTime(realTime);
- timeDisplayBegin.visible = true;
- timeDisplayBegin.x = xpos + flick.x;
- }
-
- function setEndTime(xpos) {
- var bt = startTime + (timeDisplayBegin.x - flick.x) * timePerPixel;
- var et = startTime + xpos * timePerPixel;
- var timeDisplayBeginTime = Math.min(bt, et);
- var timeDisplayEndTime = Math.max(bt, et);
-
- timeDisplayText.text = qsTr("length: %1").arg(detailedPrintTime(timeDisplayEndTime-timeDisplayBeginTime));
- timeDisplayEnd.visible = true;
- timeDisplayEnd.x = xpos + flick.x
- }
-
- onMousePositionChanged: {
- if (!root.eventCount)
- return;
-
- if (!pressed && timeDisplayEnd.visible)
- return;
-
- timeDisplayLabel.x = mouseX + flick.x
- timeDisplayLabel.visible = true
-
- if (pressed) {
- setEndTime(mouseX);
- } else {
- setStartTime(mouseX);
- }
- }
-
- onPressed: {
- setStartTime(mouseX);
- }
-
- onExited: {
- if ((!pressed) && (!timeDisplayEnd.visible)) {
- timeDisplayLabel.hideAll();
- }
- }
- }
}