2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2011-03-25 09:25:17 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
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
|
2012-02-24 10:47:17 +01:00
|
|
|
signal selectedEventChanged(int eventId)
|
2011-11-09 12:57:41 +01:00
|
|
|
property bool lockItemSelection : false
|
2011-09-23 15:58:41 +02:00
|
|
|
|
2012-02-24 10:47:17 +01: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" ]
|
2011-10-11 17:52:39 +02:00
|
|
|
|
|
|
|
|
property variant mainviewTimePerPixel : 0
|
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
signal updateCursorPosition
|
|
|
|
|
property string fileName: ""
|
|
|
|
|
property int lineNumber: -1
|
2012-01-12 16:36:40 +01:00
|
|
|
property int columnNumber: 0
|
2011-10-11 17:52:39 +02:00
|
|
|
|
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
|
|
|
|
|
|
2012-01-11 14:46:05 +01:00
|
|
|
signal changeToolTip(string text)
|
2012-02-03 16:33:51 +01:00
|
|
|
signal updateVerticalScroll(int newPosition)
|
2012-01-11 14:46:05 +01:00
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
property bool recordingEnabled: false
|
|
|
|
|
property bool appKilled : false
|
|
|
|
|
|
|
|
|
|
property date recordingStartDate
|
|
|
|
|
property real elapsedTime
|
2012-02-15 17:26:41 +01:00
|
|
|
|
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) {
|
2012-02-24 10:47:17 +01:00
|
|
|
var candidateWidth = qmlProfilerDataModel.traceDuration() *
|
|
|
|
|
flick.width / duration;
|
2011-10-11 17:52:39 +02:00
|
|
|
if (flick.contentWidth !== candidateWidth)
|
|
|
|
|
flick.contentWidth = candidateWidth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Connections {
|
2012-02-24 10:47:17 +01:00
|
|
|
target: qmlProfilerDataModel
|
2011-10-11 17:52:39 +02:00
|
|
|
onCountChanged: {
|
2012-02-24 10:47:17 +01:00
|
|
|
eventCount = qmlProfilerDataModel.count();
|
2011-10-11 17:52:39 +02:00
|
|
|
if (eventCount === 0)
|
|
|
|
|
root.clearAll();
|
|
|
|
|
if (eventCount > 1) {
|
|
|
|
|
root.progress = Math.min(1.0,
|
2012-02-24 10:47:17 +01:00
|
|
|
(qmlProfilerDataModel.lastTimeMark() -
|
|
|
|
|
qmlProfilerDataModel.traceStartTime()) / root.elapsedTime * 1e-9 );
|
2011-10-11 17:52:39 +02:00
|
|
|
} else {
|
|
|
|
|
root.progress = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-02-13 15:26:57 +01:00
|
|
|
onStateChanged: {
|
2012-02-24 10:47:17 +01:00
|
|
|
switch (qmlProfilerDataModel.getCurrentStateFromQml()) {
|
2012-02-13 15:26:57 +01:00
|
|
|
case 0: {
|
|
|
|
|
root.clearAll();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 1: {
|
|
|
|
|
root.dataAvailable = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 2: {
|
|
|
|
|
root.progress = 0.9; // jump to 90%
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 3: {
|
2011-10-11 17:52:39 +02:00
|
|
|
view.clearData();
|
2011-10-26 11:32:01 +02:00
|
|
|
progress = 1.0;
|
|
|
|
|
dataAvailable = true;
|
|
|
|
|
view.visible = true;
|
|
|
|
|
view.requestPaint();
|
2012-02-24 10:47:17 +01:00
|
|
|
zoomControl.setRange(qmlProfilerDataModel.traceStartTime(),
|
|
|
|
|
qmlProfilerDataModel.traceStartTime() +
|
|
|
|
|
qmlProfilerDataModel.traceDuration()/10);
|
2012-02-13 15:26:57 +01:00
|
|
|
break;
|
|
|
|
|
}
|
2011-10-11 17:52:39 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***** functions
|
2012-01-12 16:36:40 +01:00
|
|
|
function gotoSourceLocation(file,line,column) {
|
2011-03-11 12:22:57 +01:00
|
|
|
root.fileName = file;
|
|
|
|
|
root.lineNumber = line;
|
2012-01-12 16:36:40 +01:00
|
|
|
root.columnNumber = column;
|
2011-03-11 12:22:57 +01:00
|
|
|
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;
|
2012-02-24 10:47:17 +01:00
|
|
|
appKilled = false;
|
2011-11-16 16:08:05 +01:00
|
|
|
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();
|
2012-05-11 16:45:47 +02:00
|
|
|
elapsedTime = 0;
|
2011-06-24 18:19:08 +02:00
|
|
|
}
|
|
|
|
|
|
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;
|
2012-02-24 10:47:17 +01:00
|
|
|
if (qmlProfilerDataModel.traceEndTime() <= qmlProfilerDataModel.traceStartTime() ||
|
|
|
|
|
windowLength <= 0)
|
2011-10-20 17:38:24 +02:00
|
|
|
return;
|
2012-02-24 10:47:17 +01:00
|
|
|
var currentFactor = windowLength / qmlProfilerDataModel.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
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
if (newWindowLength > qmlProfilerDataModel.traceDuration()) {
|
|
|
|
|
newWindowLength = qmlProfilerDataModel.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
|
2012-02-24 10:47:17 +01:00
|
|
|
var newFixedPoint = qmlProfilerDataModel.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;
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
if (newWindowLength > qmlProfilerDataModel.traceDuration()) {
|
|
|
|
|
newWindowLength = qmlProfilerDataModel.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;
|
2012-02-24 10:47:17 +01:00
|
|
|
if (newStart + windowLength > qmlProfilerDataModel.traceEndTime())
|
|
|
|
|
newStart = qmlProfilerDataModel.traceEndTime() - windowLength;
|
2011-10-19 14:28:21 +02:00
|
|
|
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
|
2012-02-24 10:47:17 +01:00
|
|
|
if (qmlProfilerDataModel.getEndTime(itemIndex) < view.startTime ||
|
|
|
|
|
qmlProfilerDataModel.getStartTime(itemIndex) > view.endTime) {
|
|
|
|
|
recenter((qmlProfilerDataModel.getStartTime(itemIndex) +
|
|
|
|
|
qmlProfilerDataModel.getEndTime(itemIndex)) / 2);
|
2011-11-03 16:15:50 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-20 17:38:24 +02:00
|
|
|
function wheelZoom(wheelCenter, wheelDelta) {
|
2012-02-24 10:47:17 +01:00
|
|
|
if (qmlProfilerDataModel.traceEndTime() > qmlProfilerDataModel.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;
|
2012-01-12 16:36:40 +01:00
|
|
|
rangeDetails.column = 0;
|
2012-02-06 16:08:56 +01:00
|
|
|
rangeDetails.isBindingLoop = false;
|
2011-10-11 17:52:39 +02:00
|
|
|
}
|
|
|
|
|
|
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;
|
2012-02-24 10:47:17 +01:00
|
|
|
selectedEventChanged( qmlProfilerDataModel.getEventId(selectedItem) );
|
2011-11-09 12:57:41 +01:00
|
|
|
lockItemSelection = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
onRecordingEnabledChanged: {
|
|
|
|
|
if (recordingEnabled) {
|
|
|
|
|
recordingStartDate = new Date();
|
|
|
|
|
elapsedTime = 0;
|
|
|
|
|
} else {
|
|
|
|
|
elapsedTime = (new Date() - recordingStartDate)/1000.0;
|
2011-03-24 12:42:15 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
// ***** child items
|
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: {
|
2012-02-24 10:47:17 +01:00
|
|
|
zoomControl.setRange(selectionRange.startTime,
|
|
|
|
|
selectionRange.startTime + selectionRange.duration);
|
2011-10-26 11:32:01 +02:00
|
|
|
root.selectionRangeMode = false;
|
|
|
|
|
root.updateRangeButton();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SelectionRange {
|
|
|
|
|
id: selectionRange
|
|
|
|
|
visible: root.selectionRangeMode
|
|
|
|
|
height: root.height
|
|
|
|
|
z: 2
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
TimelineRenderer {
|
2011-03-11 12:22:57 +01:00
|
|
|
id: view
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
profilerDataModel: qmlProfilerDataModel
|
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: {
|
2012-02-24 10:47:17 +01:00
|
|
|
var newStartTime = Math.round(startX * (endTime - startTime) / flick.width) +
|
|
|
|
|
qmlProfilerDataModel.traceStartTime();
|
2011-10-11 17:52:39 +02:00
|
|
|
if (Math.abs(newStartTime - startTime) > 1) {
|
2012-02-24 10:47:17 +01:00
|
|
|
var newEndTime = Math.round((startX+flick.width) *
|
|
|
|
|
(endTime - startTime) /
|
|
|
|
|
flick.width) +
|
|
|
|
|
qmlProfilerDataModel.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;
|
2012-02-24 10:47:17 +01:00
|
|
|
var newStartX = (startTime - qmlProfilerDataModel.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
|
2012-02-24 10:47:17 +01:00
|
|
|
rangeDetails.duration = qmlProfilerDataModel.getDuration(selectedItem)/1000.0;
|
|
|
|
|
rangeDetails.label = qmlProfilerDataModel.getDetails(selectedItem);
|
|
|
|
|
rangeDetails.file = qmlProfilerDataModel.getFilename(selectedItem);
|
|
|
|
|
rangeDetails.line = qmlProfilerDataModel.getLine(selectedItem);
|
|
|
|
|
rangeDetails.column = qmlProfilerDataModel.getColumn(selectedItem);
|
|
|
|
|
rangeDetails.type = root.names[qmlProfilerDataModel.getType(selectedItem)];
|
|
|
|
|
rangeDetails.isBindingLoop = qmlProfilerDataModel.getBindingLoopDest(selectedItem)!==-1;
|
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
|
|
|
|
2012-02-03 16:33:51 +01:00
|
|
|
// center view (horizontally)
|
2011-10-26 11:32:01 +02:00
|
|
|
var windowLength = view.endTime - view.startTime;
|
2012-02-24 10:47:17 +01:00
|
|
|
var eventStartTime = qmlProfilerDataModel.getStartTime(selectedItem);
|
|
|
|
|
var eventEndTime = eventStartTime +
|
|
|
|
|
qmlProfilerDataModel.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;
|
2012-02-24 10:47:17 +01:00
|
|
|
var from = Math.min(qmlProfilerDataModel.traceEndTime()-windowLength,
|
2011-10-26 11:32:01 +02:00
|
|
|
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
|
|
|
}
|
2012-02-03 16:33:51 +01:00
|
|
|
|
|
|
|
|
// center view (vertically)
|
|
|
|
|
var itemY = view.getYPosition(selectedItem);
|
|
|
|
|
if (itemY < root.scrollY) {
|
|
|
|
|
root.updateVerticalScroll(itemY);
|
|
|
|
|
} else
|
2012-02-24 10:47:17 +01:00
|
|
|
if (itemY + root.singleRowHeight >
|
|
|
|
|
root.scrollY + root.candidateHeight) {
|
|
|
|
|
root.updateVerticalScroll(itemY + root.singleRowHeight -
|
|
|
|
|
root.candidateHeight);
|
2012-02-03 16:33:51 +01: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) {
|
2012-02-24 10:47:17 +01:00
|
|
|
root.gotoSourceLocation(qmlProfilerDataModel.getFilename(pressedItem),
|
|
|
|
|
qmlProfilerDataModel.getLine(pressedItem),
|
|
|
|
|
qmlProfilerDataModel.getColumn(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
|
2012-02-24 10:47:17 +01:00
|
|
|
startDragArea: selectionRangeDrag.enabled ? selectionRangeDrag.x :
|
|
|
|
|
-flick.contentX
|
2011-10-26 11:32:01 +02:00
|
|
|
endDragArea: selectionRangeDrag.enabled ?
|
2012-02-24 10:47:17 +01:00
|
|
|
selectionRangeDrag.x + selectionRangeDrag.width :
|
|
|
|
|
-flick.contentX-1
|
2011-10-26 11:32:01 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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
|
|
|
}
|