QmlProfiler: main view with fixed height and scrollable

Change-Id: Ib77ad6ba5afe13d692d85c7027e3e1d4b2fbb6a7
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
Christiaan Janssen
2011-10-11 17:52:39 +02:00
parent eb5a60db14
commit c9f977c39a
16 changed files with 738 additions and 543 deletions

View File

@@ -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,32 +95,10 @@ 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);
ctxt.fillText(prettyPrintTime(ii*timePerBlock + realStartTime), x + 5, height/2 + 4);
}
}
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.fillStyle = "white";
ctxt.fillRect(0, 0, width, originY);
}
function prettyPrintTime( t )
{
if (t <= 0) return "0";
@@ -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();
}
}
}
}