2011-03-25 09:25:17 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-07-06 15:48:52 +00:00
|
|
|
** 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.
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-07-06 15:48:52 +00:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2011-03-25 09:25:17 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-07-06 15:48:52 +00:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2011-03-25 09:25:17 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2011-03-25 09:26:55 +01:00
|
|
|
import QtQuick 1.0
|
2011-03-11 12:22:57 +01:00
|
|
|
import Monitor 1.0
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: root
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
// ***** properties
|
|
|
|
|
|
|
|
|
|
property int candidateHeight: 0
|
2011-11-16 16:08:05 +01:00
|
|
|
property int scrollY: 0
|
2011-10-26 11:32:01 +02:00
|
|
|
height: Math.max( candidateHeight, labels.height + 2 )
|
|
|
|
|
|
|
|
|
|
property int singleRowHeight: 30
|
2011-10-11 17:52:39 +02:00
|
|
|
|
|
|
|
|
property bool dataAvailable: true
|
|
|
|
|
property int eventCount: 0
|
|
|
|
|
property real progress: 0
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
property alias selectionLocked : view.selectionLocked
|
|
|
|
|
signal updateLockButton
|
|
|
|
|
property alias selectedItem: view.selectedItem
|
2011-11-09 12:57:41 +01:00
|
|
|
signal selectedEventIdChanged(int eventId)
|
|
|
|
|
property bool lockItemSelection : false
|
2011-09-23 15:58:41 +02:00
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
property variant names: [ qsTr("Painting"), qsTr("Compiling"), qsTr("Creating"), qsTr("Binding"), qsTr("Handling Signal")]
|
|
|
|
|
property variant colors : [ "#99CCB3", "#99CCCC", "#99B3CC", "#9999CC", "#CC99B3", "#CC99CC", "#CCCC99", "#CCB399" ]
|
|
|
|
|
|
|
|
|
|
property variant mainviewTimePerPixel : 0
|
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
signal updateCursorPosition
|
|
|
|
|
property string fileName: ""
|
|
|
|
|
property int lineNumber: -1
|
2011-10-11 17:52:39 +02:00
|
|
|
|
|
|
|
|
property real elapsedTime
|
|
|
|
|
signal updateTimer
|
|
|
|
|
|
2011-10-19 14:28:21 +02:00
|
|
|
signal updateRangeButton
|
|
|
|
|
property bool selectionRangeMode: false
|
|
|
|
|
|
2011-11-08 16:54:23 +01:00
|
|
|
property bool selectionRangeReady: selectionRange.ready
|
|
|
|
|
property variant selectionRangeStart: selectionRange.startTime
|
|
|
|
|
property variant selectionRangeEnd: selectionRange.startTime + selectionRange.duration
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
// ***** connections with external objects
|
|
|
|
|
Connections {
|
|
|
|
|
target: zoomControl
|
|
|
|
|
onRangeChanged: {
|
|
|
|
|
var startTime = zoomControl.startTime();
|
|
|
|
|
var endTime = zoomControl.endTime();
|
|
|
|
|
var duration = Math.abs(endTime - startTime);
|
|
|
|
|
|
|
|
|
|
mainviewTimePerPixel = duration / root.width;
|
|
|
|
|
|
|
|
|
|
backgroundMarks.updateMarks(startTime, endTime);
|
|
|
|
|
view.updateFlickRange(startTime, endTime);
|
|
|
|
|
if (duration > 0) {
|
2011-11-02 16:57:31 +01:00
|
|
|
var candidateWidth = qmlEventList.traceDuration() * flick.width / duration;
|
2011-10-11 17:52:39 +02:00
|
|
|
if (flick.contentWidth !== candidateWidth)
|
|
|
|
|
flick.contentWidth = candidateWidth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
|
target: qmlEventList
|
|
|
|
|
onCountChanged: {
|
|
|
|
|
eventCount = qmlEventList.count();
|
|
|
|
|
if (eventCount === 0)
|
|
|
|
|
root.clearAll();
|
|
|
|
|
if (eventCount > 1) {
|
|
|
|
|
root.progress = Math.min(1.0,
|
2011-11-28 16:30:30 +01:00
|
|
|
(qmlEventList.lastTimeMark() - qmlEventList.traceStartTime()) / root.elapsedTime * 1e-9 );
|
2011-10-11 17:52:39 +02:00
|
|
|
} else {
|
|
|
|
|
root.progress = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-08 16:13:09 +01:00
|
|
|
onProcessingData: {
|
2011-10-11 17:52:39 +02:00
|
|
|
root.dataAvailable = false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-28 16:30:30 +01:00
|
|
|
onPostProcessing: {
|
|
|
|
|
root.progress = 0.9; // jump to 90%
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
onDataReady: {
|
|
|
|
|
if (eventCount > 0) {
|
|
|
|
|
view.clearData();
|
2011-10-26 11:32:01 +02:00
|
|
|
progress = 1.0;
|
|
|
|
|
dataAvailable = true;
|
|
|
|
|
view.visible = true;
|
|
|
|
|
view.requestPaint();
|
2011-11-02 16:57:31 +01:00
|
|
|
zoomControl.setRange(qmlEventList.traceStartTime(), qmlEventList.traceStartTime() + qmlEventList.traceDuration()/10);
|
2011-10-11 17:52:39 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***** functions
|
2011-03-11 12:22:57 +01:00
|
|
|
function gotoSourceLocation(file,line) {
|
|
|
|
|
root.fileName = file;
|
|
|
|
|
root.lineNumber = line;
|
|
|
|
|
root.updateCursorPosition();
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-24 18:19:08 +02:00
|
|
|
function clearData() {
|
2011-04-06 16:04:18 +02:00
|
|
|
view.clearData();
|
2011-11-16 16:08:05 +01:00
|
|
|
dataAvailable = false;
|
|
|
|
|
eventCount = 0;
|
2011-09-23 15:58:41 +02:00
|
|
|
hideRangeDetails();
|
2011-11-16 16:08:05 +01:00
|
|
|
selectionRangeMode = false;
|
|
|
|
|
updateRangeButton();
|
|
|
|
|
zoomControl.setRange(0,0);
|
2011-04-06 16:04:18 +02:00
|
|
|
}
|
|
|
|
|
|
2011-10-11 12:08:17 +02:00
|
|
|
function clearDisplay() {
|
2011-06-24 18:19:08 +02:00
|
|
|
clearData();
|
|
|
|
|
view.visible = false;
|
2011-10-11 12:08:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clearAll() {
|
|
|
|
|
clearDisplay();
|
2011-06-24 18:19:08 +02:00
|
|
|
root.elapsedTime = 0;
|
|
|
|
|
root.updateTimer();
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-24 18:19:08 +02:00
|
|
|
function nextEvent() {
|
2011-10-26 11:32:01 +02:00
|
|
|
view.selectNext();
|
2011-06-24 18:19:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function prevEvent() {
|
2011-10-26 11:32:01 +02:00
|
|
|
view.selectPrev();
|
2011-06-24 18:19:08 +02:00
|
|
|
}
|
|
|
|
|
|
2011-10-20 17:38:24 +02:00
|
|
|
function updateWindowLength(absoluteFactor) {
|
|
|
|
|
var windowLength = view.endTime - view.startTime;
|
2011-11-02 16:57:31 +01:00
|
|
|
if (qmlEventList.traceEndTime() <= qmlEventList.traceStartTime() || windowLength <= 0)
|
2011-10-20 17:38:24 +02:00
|
|
|
return;
|
2011-11-02 16:57:31 +01:00
|
|
|
var currentFactor = windowLength / qmlEventList.traceDuration();
|
2011-10-20 17:38:24 +02:00
|
|
|
updateZoom(absoluteFactor / currentFactor);
|
2011-06-27 18:25:50 +02:00
|
|
|
}
|
|
|
|
|
|
2011-10-20 17:38:24 +02:00
|
|
|
function updateZoom(relativeFactor) {
|
2011-10-11 17:52:39 +02:00
|
|
|
var min_length = 1e5; // 0.1 ms
|
|
|
|
|
var windowLength = view.endTime - view.startTime;
|
|
|
|
|
if (windowLength < min_length)
|
|
|
|
|
windowLength = min_length;
|
2011-10-20 17:38:24 +02:00
|
|
|
var newWindowLength = windowLength * relativeFactor;
|
2011-10-11 17:52:39 +02:00
|
|
|
|
2011-11-02 16:57:31 +01:00
|
|
|
if (newWindowLength > qmlEventList.traceDuration()) {
|
|
|
|
|
newWindowLength = qmlEventList.traceDuration();
|
2011-10-20 17:38:24 +02:00
|
|
|
relativeFactor = newWindowLength / windowLength;
|
2011-10-11 17:52:39 +02:00
|
|
|
}
|
|
|
|
|
if (newWindowLength < min_length) {
|
|
|
|
|
newWindowLength = min_length;
|
2011-10-20 17:38:24 +02:00
|
|
|
relativeFactor = newWindowLength / windowLength;
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
var fixedPoint = (view.startTime + view.endTime) / 2;
|
2011-10-26 11:32:01 +02:00
|
|
|
if (view.selectedItem !== -1) {
|
2011-10-11 17:52:39 +02:00
|
|
|
// center on selected item if it's inside the current screen
|
2011-10-26 11:32:01 +02:00
|
|
|
var newFixedPoint = qmlEventList.getStartTime(view.selectedItem);
|
2011-10-11 17:52:39 +02:00
|
|
|
if (newFixedPoint >= view.startTime && newFixedPoint < view.endTime)
|
|
|
|
|
fixedPoint = newFixedPoint;
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
2011-10-20 17:38:24 +02:00
|
|
|
var startTime = fixedPoint - relativeFactor*(fixedPoint - view.startTime);
|
|
|
|
|
zoomControl.setRange(startTime, startTime + newWindowLength);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateZoomCentered(centerX, relativeFactor)
|
|
|
|
|
{
|
|
|
|
|
var min_length = 1e5; // 0.1 ms
|
|
|
|
|
var windowLength = view.endTime - view.startTime;
|
|
|
|
|
if (windowLength < min_length)
|
|
|
|
|
windowLength = min_length;
|
|
|
|
|
var newWindowLength = windowLength * relativeFactor;
|
|
|
|
|
|
2011-11-02 16:57:31 +01:00
|
|
|
if (newWindowLength > qmlEventList.traceDuration()) {
|
|
|
|
|
newWindowLength = qmlEventList.traceDuration();
|
2011-10-20 17:38:24 +02:00
|
|
|
relativeFactor = newWindowLength / windowLength;
|
|
|
|
|
}
|
|
|
|
|
if (newWindowLength < min_length) {
|
|
|
|
|
newWindowLength = min_length;
|
|
|
|
|
relativeFactor = newWindowLength / windowLength;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var fixedPoint = (centerX - flick.x) * windowLength / flick.width + view.startTime;
|
|
|
|
|
var startTime = fixedPoint - relativeFactor*(fixedPoint - view.startTime);
|
2011-10-11 17:52:39 +02:00
|
|
|
zoomControl.setRange(startTime, startTime + newWindowLength);
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-19 14:28:21 +02:00
|
|
|
function recenter( centerPoint ) {
|
|
|
|
|
var windowLength = view.endTime - view.startTime;
|
|
|
|
|
var newStart = Math.floor(centerPoint - windowLength/2);
|
|
|
|
|
if (newStart < 0)
|
|
|
|
|
newStart = 0;
|
|
|
|
|
if (newStart + windowLength > qmlEventList.traceEndTime())
|
|
|
|
|
newStart = qmlEventList.traceEndTime() - windowLength;
|
|
|
|
|
zoomControl.setRange(newStart, newStart + windowLength);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-03 16:15:50 +01:00
|
|
|
function recenterOnItem( itemIndex )
|
|
|
|
|
{
|
2011-11-09 12:57:41 +01:00
|
|
|
if (itemIndex === -1)
|
|
|
|
|
return;
|
|
|
|
|
|
2011-11-03 16:15:50 +01:00
|
|
|
// if item is outside of the view, jump back to its position
|
|
|
|
|
if (qmlEventList.getEndTime(itemIndex) < view.startTime || qmlEventList.getStartTime(itemIndex) > view.endTime) {
|
|
|
|
|
recenter((qmlEventList.getStartTime(itemIndex) + qmlEventList.getEndTime(itemIndex)) / 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-20 17:38:24 +02:00
|
|
|
function globalZoom() {
|
|
|
|
|
zoomControl.setRange(qmlEventList.traceStartTime(), qmlEventList.traceEndTime());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function wheelZoom(wheelCenter, wheelDelta) {
|
2011-11-02 16:57:31 +01:00
|
|
|
if (qmlEventList.traceEndTime() > qmlEventList.traceStartTime() && wheelDelta !== 0) {
|
2011-10-20 17:38:24 +02:00
|
|
|
if (wheelDelta>0)
|
|
|
|
|
updateZoomCentered(wheelCenter, 1/1.2);
|
|
|
|
|
else
|
|
|
|
|
updateZoomCentered(wheelCenter, 1.2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
function hideRangeDetails() {
|
|
|
|
|
rangeDetails.visible = false;
|
|
|
|
|
rangeDetails.duration = "";
|
|
|
|
|
rangeDetails.label = "";
|
|
|
|
|
rangeDetails.type = "";
|
|
|
|
|
rangeDetails.file = "";
|
|
|
|
|
rangeDetails.line = -1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-09 12:57:41 +01:00
|
|
|
function selectNextWithId( eventId )
|
|
|
|
|
{
|
|
|
|
|
if (!lockItemSelection) {
|
|
|
|
|
lockItemSelection = true;
|
|
|
|
|
var itemIndex = view.nextItemFromId( eventId );
|
|
|
|
|
// select an item, lock to it, and recenter if necessary
|
|
|
|
|
if (view.selectedItem != itemIndex) {
|
|
|
|
|
view.selectedItem = itemIndex;
|
|
|
|
|
if (itemIndex !== -1) {
|
|
|
|
|
view.selectionLocked = true;
|
|
|
|
|
recenterOnItem(itemIndex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
lockItemSelection = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
// ***** slots
|
2011-10-19 14:28:21 +02:00
|
|
|
onSelectionRangeModeChanged: {
|
|
|
|
|
selectionRangeControl.enabled = selectionRangeMode;
|
|
|
|
|
selectionRange.reset(selectionRangeMode);
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
onSelectionLockedChanged: {
|
|
|
|
|
updateLockButton();
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-09 12:57:41 +01:00
|
|
|
onSelectedItemChanged: {
|
|
|
|
|
if (selectedItem != -1 && !lockItemSelection) {
|
|
|
|
|
lockItemSelection = true;
|
|
|
|
|
selectedEventIdChanged( qmlEventList.getEventId(selectedItem) );
|
|
|
|
|
lockItemSelection = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
// ***** child items
|
2011-03-24 12:42:15 +01:00
|
|
|
Timer {
|
2011-07-21 11:24:49 +02:00
|
|
|
id: elapsedTimer
|
2011-03-24 12:42:15 +01:00
|
|
|
property date startDate
|
2011-10-20 17:38:24 +02:00
|
|
|
property bool reset: true
|
2011-11-10 17:08:07 +01:00
|
|
|
running: connection.recording && connection.enabled
|
2011-03-24 12:42:15 +01:00
|
|
|
repeat: true
|
2011-10-11 17:52:39 +02:00
|
|
|
onRunningChanged: {
|
|
|
|
|
if (running) reset = true;
|
|
|
|
|
}
|
2011-03-24 12:42:15 +01:00
|
|
|
interval: 100
|
|
|
|
|
triggeredOnStart: true
|
|
|
|
|
onTriggered: {
|
|
|
|
|
if (reset) {
|
2011-10-11 17:52:39 +02:00
|
|
|
startDate = new Date();
|
|
|
|
|
reset = false;
|
2011-03-24 12:42:15 +01:00
|
|
|
}
|
2011-10-11 17:52:39 +02:00
|
|
|
var time = (new Date() - startDate)/1000;
|
2011-03-24 12:42:15 +01:00
|
|
|
root.elapsedTime = time.toFixed(1);
|
|
|
|
|
root.updateTimer();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
TimeMarks {
|
|
|
|
|
id: backgroundMarks
|
|
|
|
|
y: labels.y
|
|
|
|
|
height: flick.height
|
2011-06-20 18:11:17 +02:00
|
|
|
anchors.left: flick.left
|
|
|
|
|
anchors.right: flick.right
|
2011-06-24 18:19:08 +02:00
|
|
|
}
|
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
Flickable {
|
|
|
|
|
id: flick
|
|
|
|
|
anchors.top: parent.top
|
2011-06-20 18:11:17 +02:00
|
|
|
anchors.topMargin: labels.y
|
2011-03-11 12:22:57 +01:00
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.left: labels.right
|
2011-10-11 17:52:39 +02:00
|
|
|
height: root.height
|
|
|
|
|
contentWidth: 0;
|
2011-10-26 11:32:01 +02:00
|
|
|
contentHeight: labels.height
|
2011-05-17 18:03:59 +02:00
|
|
|
flickableDirection: Flickable.HorizontalFlick
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
onContentXChanged: {
|
|
|
|
|
if (Math.round(view.startX) !== contentX)
|
|
|
|
|
view.startX = contentX;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-10 16:21:10 +02:00
|
|
|
clip:true
|
|
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
MouseArea {
|
|
|
|
|
id: selectionRangeDrag
|
|
|
|
|
enabled: selectionRange.ready
|
|
|
|
|
anchors.fill: selectionRange
|
|
|
|
|
drag.target: selectionRange
|
|
|
|
|
drag.axis: "XAxis"
|
|
|
|
|
drag.minimumX: 0
|
|
|
|
|
drag.maximumX: flick.contentWidth - selectionRange.width
|
|
|
|
|
onPressed: {
|
|
|
|
|
selectionRange.isDragging = true;
|
|
|
|
|
}
|
|
|
|
|
onReleased: {
|
|
|
|
|
selectionRange.isDragging = false;
|
|
|
|
|
}
|
|
|
|
|
onDoubleClicked: {
|
|
|
|
|
zoomControl.setRange(selectionRange.startTime, selectionRange.startTime + selectionRange.duration);
|
|
|
|
|
root.selectionRangeMode = false;
|
|
|
|
|
root.updateRangeButton();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SelectionRange {
|
|
|
|
|
id: selectionRange
|
|
|
|
|
visible: root.selectionRangeMode
|
|
|
|
|
height: root.height
|
|
|
|
|
z: 2
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
TimelineView {
|
|
|
|
|
id: view
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
eventList: qmlEventList
|
2011-07-26 13:56:14 +02:00
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
x: flick.contentX
|
2011-10-11 17:52:39 +02:00
|
|
|
width: flick.width
|
2011-10-26 11:32:01 +02:00
|
|
|
height: root.height
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
property variant startX: 0
|
2011-03-11 12:22:57 +01:00
|
|
|
onStartXChanged: {
|
2011-11-02 16:57:31 +01:00
|
|
|
var newStartTime = Math.round(startX * (endTime - startTime) / flick.width) + qmlEventList.traceStartTime();
|
2011-10-11 17:52:39 +02:00
|
|
|
if (Math.abs(newStartTime - startTime) > 1) {
|
2011-11-02 16:57:31 +01:00
|
|
|
var newEndTime = Math.round((startX+flick.width)* (endTime - startTime) / flick.width) + qmlEventList.traceStartTime();
|
2011-10-11 17:52:39 +02:00
|
|
|
zoomControl.setRange(newStartTime, newEndTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Math.round(startX) !== flick.contentX)
|
|
|
|
|
flick.contentX = startX;
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
2011-10-11 17:52:39 +02:00
|
|
|
|
|
|
|
|
function updateFlickRange(start, end) {
|
|
|
|
|
if (start !== startTime || end !== endTime) {
|
|
|
|
|
startTime = start;
|
|
|
|
|
endTime = end;
|
2011-11-02 16:57:31 +01:00
|
|
|
var newStartX = (startTime - qmlEventList.traceStartTime()) * flick.width / (endTime-startTime);
|
2011-10-11 17:52:39 +02:00
|
|
|
if (Math.abs(newStartX - startX) >= 1)
|
|
|
|
|
startX = newStartX;
|
|
|
|
|
}
|
2011-09-23 15:58:41 +02:00
|
|
|
}
|
|
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
onSelectedItemChanged: {
|
|
|
|
|
if (selectedItem !== -1) {
|
|
|
|
|
// display details
|
|
|
|
|
rangeDetails.duration = qmlEventList.getDuration(selectedItem)/1000.0;
|
|
|
|
|
rangeDetails.label = qmlEventList.getDetails(selectedItem);
|
|
|
|
|
rangeDetails.file = qmlEventList.getFilename(selectedItem);
|
|
|
|
|
rangeDetails.line = qmlEventList.getLine(selectedItem);
|
|
|
|
|
rangeDetails.type = root.names[qmlEventList.getType(selectedItem)];
|
2011-06-24 18:19:08 +02:00
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
rangeDetails.visible = true;
|
2011-06-24 18:19:08 +02:00
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
// center view
|
|
|
|
|
var windowLength = view.endTime - view.startTime;
|
|
|
|
|
var eventStartTime = qmlEventList.getStartTime(selectedItem);
|
|
|
|
|
var eventEndTime = eventStartTime + qmlEventList.getDuration(selectedItem);
|
2011-06-24 18:19:08 +02:00
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
if (eventEndTime < view.startTime || eventStartTime > view.endTime) {
|
|
|
|
|
var center = (eventStartTime + eventEndTime)/2;
|
|
|
|
|
var from = Math.min(qmlEventList.traceEndTime()-windowLength,
|
|
|
|
|
Math.max(0, Math.floor(center - windowLength/2)));
|
2011-06-24 18:19:08 +02:00
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
zoomControl.setRange(from, from + windowLength);
|
2011-09-23 15:58:41 +02:00
|
|
|
}
|
2011-10-26 11:32:01 +02:00
|
|
|
} else {
|
2011-10-11 17:52:39 +02:00
|
|
|
root.hideRangeDetails();
|
|
|
|
|
}
|
2011-09-23 15:58:41 +02:00
|
|
|
}
|
2011-10-19 14:28:21 +02:00
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
onItemPressed: {
|
|
|
|
|
if (pressedItem !== -1) {
|
|
|
|
|
root.gotoSourceLocation(qmlEventList.getFilename(pressedItem), qmlEventList.getLine(pressedItem));
|
2011-10-19 14:28:21 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
// hack to pass mouse events to the other mousearea if enabled
|
|
|
|
|
startDragArea: selectionRangeDrag.enabled ? selectionRangeDrag.x : -flick.contentX
|
|
|
|
|
endDragArea: selectionRangeDrag.enabled ?
|
|
|
|
|
selectionRangeDrag.x + selectionRangeDrag.width : -flick.contentX-1
|
|
|
|
|
}
|
|
|
|
|
MouseArea {
|
|
|
|
|
id: selectionRangeControl
|
|
|
|
|
enabled: false
|
|
|
|
|
width: flick.width
|
|
|
|
|
height: root.height
|
|
|
|
|
x: flick.contentX
|
|
|
|
|
hoverEnabled: enabled
|
|
|
|
|
z: 2
|
2011-10-19 14:28:21 +02:00
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
onReleased: {
|
|
|
|
|
selectionRange.releasedOnCreation();
|
|
|
|
|
}
|
|
|
|
|
onPressed: {
|
|
|
|
|
selectionRange.pressedOnCreation();
|
|
|
|
|
}
|
|
|
|
|
onMousePositionChanged: {
|
|
|
|
|
selectionRange.movedOnCreation();
|
2011-10-19 14:28:21 +02:00
|
|
|
}
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
}
|
2011-10-11 17:52:39 +02:00
|
|
|
|
2011-10-19 14:28:21 +02:00
|
|
|
SelectionRangeDetails {
|
|
|
|
|
id: selectionRangeDetails
|
|
|
|
|
visible: root.selectionRangeMode
|
|
|
|
|
startTime: selectionRange.startTimeString
|
|
|
|
|
duration: selectionRange.durationString
|
|
|
|
|
endTime: selectionRange.endTimeString
|
|
|
|
|
showDuration: selectionRange.width > 1
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
RangeDetails {
|
|
|
|
|
id: rangeDetails
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: labels
|
|
|
|
|
width: 150
|
|
|
|
|
color: "#dcdcdc"
|
2011-10-26 11:32:01 +02:00
|
|
|
height: col.height
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-06-09 14:54:56 +02:00
|
|
|
property int rowCount: 5
|
2011-10-26 11:32:01 +02:00
|
|
|
property variant rowExpanded: [false,false,false,false,false];
|
2011-06-09 14:54:56 +02:00
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
Column {
|
2011-06-09 14:54:56 +02:00
|
|
|
id: col
|
2011-10-11 17:52:39 +02:00
|
|
|
Repeater {
|
|
|
|
|
model: labels.rowCount
|
|
|
|
|
delegate: Label {
|
|
|
|
|
text: root.names[index]
|
|
|
|
|
height: labels.height/labels.rowCount
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-27 18:33:20 +02:00
|
|
|
Rectangle {
|
2011-10-11 17:52:39 +02:00
|
|
|
id: labelsTail
|
|
|
|
|
anchors.top: labels.bottom
|
|
|
|
|
anchors.bottom: root.bottom
|
|
|
|
|
width: labels.width
|
|
|
|
|
color: labels.color
|
2011-06-27 18:33:20 +02:00
|
|
|
}
|
2011-07-11 16:05:37 +02:00
|
|
|
|
|
|
|
|
StatusDisplay {
|
2011-10-11 17:52:39 +02:00
|
|
|
anchors.horizontalCenter: flick.horizontalCenter
|
|
|
|
|
anchors.verticalCenter: labels.verticalCenter
|
|
|
|
|
z:3
|
2011-07-11 16:05:37 +02:00
|
|
|
}
|
2011-11-16 16:08:05 +01:00
|
|
|
|
|
|
|
|
// Gradient borders
|
|
|
|
|
Item {
|
|
|
|
|
anchors.left: labels.right
|
|
|
|
|
width: 6
|
|
|
|
|
anchors.top: root.top
|
|
|
|
|
anchors.bottom: root.bottom
|
|
|
|
|
Rectangle {
|
|
|
|
|
x: parent.width
|
|
|
|
|
transformOrigin: Item.TopLeft
|
|
|
|
|
rotation: 90
|
|
|
|
|
width: parent.height
|
|
|
|
|
height: parent.width
|
|
|
|
|
gradient: Gradient {
|
2011-11-29 12:32:35 +01:00
|
|
|
GradientStop { position: 0.0; color: "#00000000"; }
|
|
|
|
|
GradientStop { position: 1.0; color: "#86000000"; }
|
2011-11-16 16:08:05 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
anchors.right: root.right
|
|
|
|
|
width: 6
|
|
|
|
|
anchors.top: root.top
|
|
|
|
|
anchors.bottom: root.bottom
|
|
|
|
|
Rectangle {
|
|
|
|
|
x: parent.width
|
|
|
|
|
transformOrigin: Item.TopLeft
|
|
|
|
|
rotation: 90
|
|
|
|
|
width: parent.height
|
|
|
|
|
height: parent.width
|
|
|
|
|
gradient: Gradient {
|
2011-11-29 12:32:35 +01:00
|
|
|
GradientStop { position: 0.0; color: "#86000000"; }
|
|
|
|
|
GradientStop { position: 1.0; color: "#00000000"; }
|
2011-11-16 16:08:05 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
y: root.scrollY + root.candidateHeight - height
|
|
|
|
|
height: 6
|
|
|
|
|
width: root.width
|
|
|
|
|
x: 0
|
|
|
|
|
gradient: Gradient {
|
2011-11-29 12:32:35 +01:00
|
|
|
GradientStop { position: 0.0; color: "#00000000"; }
|
|
|
|
|
GradientStop { position: 1.0; color: "#86000000"; }
|
2011-11-16 16:08:05 +01:00
|
|
|
}
|
|
|
|
|
}
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|