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
|
|
|
|
2013-09-03 12:53:48 +02:00
|
|
|
import QtQuick 2.1
|
2011-03-11 12:22:57 +01:00
|
|
|
import Monitor 1.0
|
2013-11-12 12:44:54 +01:00
|
|
|
import QtQuick.Controls 1.0
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: root
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
// ***** properties
|
|
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
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
|
|
|
|
2013-09-03 12:56:29 +02:00
|
|
|
property real mainviewTimePerPixel : 0
|
2011-10-11 17:52:39 +02:00
|
|
|
|
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
|
2013-09-03 12:56:29 +02:00
|
|
|
property real selectionRangeStart: selectionRange.startTime
|
|
|
|
|
property real selectionRangeEnd: selectionRange.startTime + selectionRange.duration
|
2011-11-08 16:54:23 +01:00
|
|
|
|
2012-01-11 14:46:05 +01:00
|
|
|
signal changeToolTip(string text)
|
|
|
|
|
|
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) {
|
2013-08-08 13:28:08 +02:00
|
|
|
var candidateWidth = qmlProfilerModelProxy.traceDuration() *
|
2012-02-24 10:47:17 +01:00
|
|
|
flick.width / duration;
|
2011-10-11 17:52:39 +02:00
|
|
|
if (flick.contentWidth !== candidateWidth)
|
|
|
|
|
flick.contentWidth = candidateWidth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
Connections {
|
2013-08-08 13:28:08 +02:00
|
|
|
target: qmlProfilerModelProxy
|
2011-10-11 17:52:39 +02:00
|
|
|
onCountChanged: {
|
2013-08-08 13:28:08 +02:00
|
|
|
eventCount = qmlProfilerModelProxy.count();
|
2011-10-11 17:52:39 +02:00
|
|
|
if (eventCount === 0)
|
|
|
|
|
root.clearAll();
|
|
|
|
|
if (eventCount > 1) {
|
|
|
|
|
root.progress = Math.min(1.0,
|
2013-08-08 13:28:08 +02:00
|
|
|
(qmlProfilerModelProxy.lastTimeMark() -
|
|
|
|
|
qmlProfilerModelProxy.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: {
|
2013-08-08 13:28:08 +02:00
|
|
|
switch (qmlProfilerModelProxy.getState()) {
|
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;
|
|
|
|
|
}
|
2011-10-11 17:52:39 +02:00
|
|
|
}
|
|
|
|
|
}
|
2013-08-08 13:28:08 +02:00
|
|
|
onDataAvailable: {
|
|
|
|
|
view.clearData();
|
|
|
|
|
zoomControl.setRange(0,0);
|
|
|
|
|
progress = 1.0;
|
|
|
|
|
dataAvailable = true;
|
|
|
|
|
view.visible = true;
|
|
|
|
|
view.requestPaint();
|
|
|
|
|
zoomControl.setRange(qmlProfilerModelProxy.traceStartTime(),
|
|
|
|
|
qmlProfilerModelProxy.traceStartTime() +
|
|
|
|
|
qmlProfilerModelProxy.traceDuration()/10);
|
|
|
|
|
}
|
2011-10-11 17:52:39 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
// ***** functions
|
2012-01-12 16:36:40 +01:00
|
|
|
function gotoSourceLocation(file,line,column) {
|
2013-08-08 13:28:08 +02:00
|
|
|
if (file !== undefined) {
|
|
|
|
|
root.fileName = file;
|
|
|
|
|
root.lineNumber = line;
|
|
|
|
|
root.columnNumber = column;
|
|
|
|
|
root.updateCursorPosition();
|
|
|
|
|
}
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
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 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;
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (newWindowLength > qmlProfilerModelProxy.traceDuration()) {
|
|
|
|
|
newWindowLength = qmlProfilerModelProxy.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;
|
2013-08-08 13:28:08 +02:00
|
|
|
if (newStart + windowLength > qmlProfilerModelProxy.traceEndTime())
|
|
|
|
|
newStart = qmlProfilerModelProxy.traceEndTime() - windowLength;
|
2011-10-19 14:28:21 +02:00
|
|
|
zoomControl.setRange(newStart, newStart + windowLength);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
function recenterOnItem( modelIndex, itemIndex )
|
2011-11-03 16:15:50 +01:00
|
|
|
{
|
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
|
2013-08-08 13:28:08 +02:00
|
|
|
if (qmlProfilerModelProxy.getEndTime(modelIndex, itemIndex) < view.startTime ||
|
|
|
|
|
qmlProfilerModelProxy.getStartTime(modelIndex, itemIndex) > view.endTime) {
|
|
|
|
|
recenter((qmlProfilerModelProxy.getStartTime(modelIndex, itemIndex) +
|
|
|
|
|
qmlProfilerModelProxy.getEndTime(modelIndex, itemIndex)) / 2);
|
2011-11-03 16:15:50 +01:00
|
|
|
}
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2011-11-03 16:15:50 +01:00
|
|
|
}
|
|
|
|
|
|
2011-10-20 17:38:24 +02:00
|
|
|
function wheelZoom(wheelCenter, wheelDelta) {
|
2013-08-08 13:28:08 +02:00
|
|
|
if (qmlProfilerModelProxy.traceEndTime() > qmlProfilerModelProxy.traceStartTime() &&
|
2012-02-24 10:47:17 +01:00
|
|
|
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 = "";
|
2013-08-08 13:28:08 +02:00
|
|
|
//rangeDetails.type = "";
|
2011-10-11 17:52:39 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
function selectNextByHash(hash) {
|
|
|
|
|
var eventId = qmlProfilerModelProxy.getEventIdForHash(hash);
|
|
|
|
|
if (eventId !== -1) {
|
|
|
|
|
selectNextById(eventId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function selectNextById(eventId)
|
2011-11-09 12:57:41 +01:00
|
|
|
{
|
2013-08-08 13:28:08 +02:00
|
|
|
// this is a slot responding to events from the other pane
|
|
|
|
|
// which tracks only events from the basic model
|
2011-11-09 12:57:41 +01:00
|
|
|
if (!lockItemSelection) {
|
|
|
|
|
lockItemSelection = true;
|
2013-08-08 13:28:08 +02:00
|
|
|
var modelIndex = qmlProfilerModelProxy.basicModelIndex();
|
|
|
|
|
var itemIndex = view.nextItemFromId( modelIndex, eventId );
|
2011-11-09 12:57:41 +01:00
|
|
|
// select an item, lock to it, and recenter if necessary
|
2013-08-08 13:28:08 +02:00
|
|
|
if (view.selectedItem != itemIndex || view.selectedModel != modelIndex) {
|
|
|
|
|
view.selectedModel = modelIndex;
|
2011-11-09 12:57:41 +01:00
|
|
|
view.selectedItem = itemIndex;
|
|
|
|
|
if (itemIndex !== -1) {
|
|
|
|
|
view.selectionLocked = true;
|
2013-08-08 13:28:08 +02:00
|
|
|
recenterOnItem(modelIndex, itemIndex);
|
2011-11-09 12:57:41 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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;
|
2013-08-08 13:28:08 +02:00
|
|
|
// update in other views
|
|
|
|
|
var eventLocation = qmlProfilerModelProxy.getEventLocation(view.selectedModel, view.selectedItem);
|
|
|
|
|
gotoSourceLocation(eventLocation.file, eventLocation.line, eventLocation.column);
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-08 12:05:18 +01:00
|
|
|
Flickable {
|
|
|
|
|
id: vertflick
|
|
|
|
|
flickableDirection: Flickable.VerticalFlick
|
2013-11-18 13:11:47 +01:00
|
|
|
anchors.fill: parent
|
2013-11-08 12:05:18 +01:00
|
|
|
clip: true
|
|
|
|
|
contentHeight: labels.height
|
2013-11-14 13:06:44 +01:00
|
|
|
boundsBehavior: Flickable.StopAtBounds
|
|
|
|
|
|
|
|
|
|
// ScrollView will try to deinteractivate it. We don't want that
|
|
|
|
|
// as the horizontal flickable is interactive, too.
|
|
|
|
|
onInteractiveChanged: interactive = true
|
2012-02-24 10:47:17 +01:00
|
|
|
|
2013-11-11 16:55:15 +01:00
|
|
|
// ***** child items
|
|
|
|
|
TimeMarks {
|
|
|
|
|
id: backgroundMarks
|
2013-11-08 18:06:13 +01:00
|
|
|
y: vertflick.contentY
|
|
|
|
|
height: vertflick.height
|
2013-11-18 13:11:47 +01:00
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.left: labels.right
|
2011-10-11 17:52:39 +02:00
|
|
|
}
|
|
|
|
|
|
2013-11-11 16:55:15 +01:00
|
|
|
Flickable {
|
|
|
|
|
id: flick
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: labels.y
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.left: labels.right
|
|
|
|
|
contentWidth: 0
|
|
|
|
|
height: labels.height + labelsTail.height
|
|
|
|
|
flickableDirection: Flickable.HorizontalFlick
|
|
|
|
|
|
2013-11-13 14:35:59 +01:00
|
|
|
onContentXChanged: view.updateZoomControl()
|
2013-11-11 16:55:15 +01:00
|
|
|
clip:true
|
|
|
|
|
|
|
|
|
|
SelectionRange {
|
|
|
|
|
id: selectionRange
|
|
|
|
|
visible: root.selectionRangeMode
|
|
|
|
|
height: parent.height
|
|
|
|
|
z: 2
|
|
|
|
|
}
|
2011-10-26 11:32:01 +02:00
|
|
|
|
2013-11-11 16:55:15 +01:00
|
|
|
TimelineRenderer {
|
|
|
|
|
id: view
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2013-11-11 16:55:15 +01:00
|
|
|
profilerModelProxy: qmlProfilerModelProxy
|
2011-07-26 13:56:14 +02:00
|
|
|
|
2013-11-11 16:55:15 +01:00
|
|
|
x: flick.contentX
|
2013-11-11 13:44:56 +01:00
|
|
|
y: vertflick.contentY
|
2013-11-11 16:55:15 +01:00
|
|
|
width: flick.width
|
2013-11-11 13:44:56 +01:00
|
|
|
height: vertflick.height
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2013-11-11 16:55:15 +01:00
|
|
|
onEndTimeChanged: requestPaint()
|
2013-11-11 13:44:56 +01:00
|
|
|
onYChanged: requestPaint()
|
|
|
|
|
onHeightChanged: requestPaint()
|
2013-11-08 16:18:48 +01:00
|
|
|
|
2013-11-13 14:35:59 +01:00
|
|
|
function updateZoomControl() {
|
|
|
|
|
var newStartTime = Math.round(flick.contentX * (endTime - startTime) / flick.width) +
|
2013-11-11 16:55:15 +01:00
|
|
|
qmlProfilerModelProxy.traceStartTime();
|
|
|
|
|
if (Math.abs(newStartTime - startTime) > 1) {
|
2013-11-13 14:35:59 +01:00
|
|
|
var newEndTime = Math.round((flick.contentX + flick.width) *
|
2013-11-11 16:55:15 +01:00
|
|
|
(endTime - startTime) /
|
|
|
|
|
flick.width) +
|
|
|
|
|
qmlProfilerModelProxy.traceStartTime();
|
|
|
|
|
zoomControl.setRange(newStartTime, newEndTime);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-10-11 17:52:39 +02:00
|
|
|
|
2013-11-11 16:55:15 +01:00
|
|
|
function updateFlickRange(start, end) {
|
|
|
|
|
if (start !== startTime || end !== endTime) {
|
|
|
|
|
startTime = start;
|
|
|
|
|
endTime = end;
|
|
|
|
|
var newStartX = (startTime - qmlProfilerModelProxy.traceStartTime()) *
|
|
|
|
|
flick.width / (endTime-startTime);
|
2013-11-13 14:35:59 +01:00
|
|
|
if (isFinite(newStartX) && Math.abs(newStartX - flick.contentX) >= 1)
|
|
|
|
|
flick.contentX = newStartX;
|
2013-11-11 16:55:15 +01:00
|
|
|
}
|
2011-10-11 17:52:39 +02:00
|
|
|
}
|
2011-09-23 15:58:41 +02:00
|
|
|
|
2013-11-11 16:55:15 +01:00
|
|
|
onSelectedItemChanged: {
|
|
|
|
|
if (selectedItem !== -1) {
|
|
|
|
|
// display details
|
|
|
|
|
rangeDetails.showInfo(qmlProfilerModelProxy.getEventDetails(selectedModel, selectedItem));
|
|
|
|
|
rangeDetails.setLocation(qmlProfilerModelProxy.getEventLocation(selectedModel, selectedItem));
|
2011-06-24 18:19:08 +02:00
|
|
|
|
2013-11-11 16:55:15 +01:00
|
|
|
// center view (horizontally)
|
|
|
|
|
var windowLength = view.endTime - view.startTime;
|
|
|
|
|
var eventStartTime = qmlProfilerModelProxy.getStartTime(selectedModel, selectedItem);
|
|
|
|
|
var eventEndTime = eventStartTime +
|
|
|
|
|
qmlProfilerModelProxy.getDuration(selectedModel, selectedItem);
|
2011-06-24 18:19:08 +02:00
|
|
|
|
2013-11-11 16:55:15 +01:00
|
|
|
if (eventEndTime < view.startTime || eventStartTime > view.endTime) {
|
|
|
|
|
var center = (eventStartTime + eventEndTime)/2;
|
|
|
|
|
var from = Math.min(qmlProfilerModelProxy.traceEndTime()-windowLength,
|
|
|
|
|
Math.max(0, Math.floor(center - windowLength/2)));
|
2011-06-24 18:19:08 +02:00
|
|
|
|
2013-11-11 16:55:15 +01:00
|
|
|
zoomControl.setRange(from, from + windowLength);
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2013-11-11 16:55:15 +01:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
root.hideRangeDetails();
|
2011-09-23 15:58:41 +02:00
|
|
|
}
|
2011-10-11 17:52:39 +02:00
|
|
|
}
|
2011-10-19 14:28:21 +02:00
|
|
|
|
2013-11-11 16:55:15 +01:00
|
|
|
onItemPressed: {
|
|
|
|
|
var location = qmlProfilerModelProxy.getEventLocation(modelIndex, pressedItem);
|
|
|
|
|
if (location.hasOwnProperty("file")) // not empty
|
|
|
|
|
root.gotoSourceLocation(location.file, location.line, location.column);
|
|
|
|
|
}
|
2011-10-19 14:28:21 +02:00
|
|
|
|
2013-11-11 16:55:15 +01:00
|
|
|
// hack to pass mouse events to the other mousearea if enabled
|
2013-11-13 13:46:55 +01:00
|
|
|
startDragArea: selectionRange.ready ? selectionRange.getLeft() : -flick.contentX
|
|
|
|
|
endDragArea: selectionRange.ready ? selectionRange.getRight() : -flick.contentX-1
|
2011-10-26 11:32:01 +02:00
|
|
|
}
|
2013-11-11 16:55:15 +01:00
|
|
|
MouseArea {
|
|
|
|
|
id: selectionRangeControl
|
|
|
|
|
enabled: false
|
|
|
|
|
width: flick.width
|
|
|
|
|
height: flick.height
|
|
|
|
|
x: flick.contentX
|
|
|
|
|
hoverEnabled: enabled
|
|
|
|
|
z: 2
|
|
|
|
|
|
|
|
|
|
onReleased: {
|
|
|
|
|
selectionRange.releasedOnCreation();
|
|
|
|
|
}
|
|
|
|
|
onPressed: {
|
|
|
|
|
selectionRange.pressedOnCreation();
|
|
|
|
|
}
|
|
|
|
|
onPositionChanged: {
|
|
|
|
|
selectionRange.movedOnCreation();
|
|
|
|
|
}
|
2011-10-19 14:28:21 +02:00
|
|
|
}
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
2013-11-11 16:55:15 +01:00
|
|
|
Rectangle {
|
|
|
|
|
id: labels
|
|
|
|
|
width: 150
|
|
|
|
|
color: "#dcdcdc"
|
|
|
|
|
height: col.height
|
|
|
|
|
|
|
|
|
|
property int rowCount: qmlProfilerModelProxy.categories();
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
id: col
|
|
|
|
|
Repeater {
|
|
|
|
|
model: labels.rowCount
|
|
|
|
|
delegate: CategoryLabel { }
|
|
|
|
|
}
|
2011-10-11 17:52:39 +02:00
|
|
|
}
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
2011-07-11 16:05:37 +02:00
|
|
|
|
2011-11-16 16:08:05 +01:00
|
|
|
Rectangle {
|
2013-11-11 16:55:15 +01:00
|
|
|
id: labelsTail
|
|
|
|
|
anchors.top: labels.bottom
|
|
|
|
|
height: Math.max(0, vertflick.height - labels.height)
|
|
|
|
|
width: labels.width
|
|
|
|
|
color: labels.color
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Gradient borders
|
|
|
|
|
Item {
|
|
|
|
|
anchors.left: labels.right
|
|
|
|
|
anchors.top: labels.top
|
|
|
|
|
anchors.bottom: labelsTail.bottom
|
|
|
|
|
width: 6
|
|
|
|
|
Rectangle {
|
|
|
|
|
x: parent.width
|
|
|
|
|
transformOrigin: Item.TopLeft
|
|
|
|
|
rotation: 90
|
|
|
|
|
width: parent.height
|
|
|
|
|
height: parent.width
|
|
|
|
|
gradient: Gradient {
|
|
|
|
|
GradientStop { position: 0.0; color: "#00000000"; }
|
|
|
|
|
GradientStop { position: 1.0; color: "#86000000"; }
|
|
|
|
|
}
|
2011-11-16 16:08:05 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-08 12:05:18 +01:00
|
|
|
|
2013-11-14 13:06:44 +01:00
|
|
|
ScrollView {
|
|
|
|
|
contentItem: vertflick
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-08 12:05:18 +01:00
|
|
|
SelectionRangeDetails {
|
|
|
|
|
id: selectionRangeDetails
|
|
|
|
|
visible: root.selectionRangeMode
|
|
|
|
|
startTime: selectionRange.startTimeString
|
|
|
|
|
duration: selectionRange.durationString
|
|
|
|
|
endTime: selectionRange.endTimeString
|
2013-11-13 13:46:55 +01:00
|
|
|
showDuration: selectionRange.getWidth() > 1
|
2013-11-08 12:05:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RangeDetails {
|
|
|
|
|
id: rangeDetails
|
|
|
|
|
}
|
2011-11-16 16:08:05 +01:00
|
|
|
|
2013-11-12 12:44:54 +01:00
|
|
|
Rectangle {
|
|
|
|
|
objectName: "zoomSliderToolBar"
|
|
|
|
|
color: "#9b9b9b"
|
|
|
|
|
enabled: false
|
|
|
|
|
visible: false
|
|
|
|
|
width: labels.width
|
|
|
|
|
height: 24
|
|
|
|
|
x: 0
|
|
|
|
|
y: 0
|
|
|
|
|
|
|
|
|
|
function toggleEnabled() {enabled = !enabled}
|
|
|
|
|
function toggleVisible() {visible = !visible}
|
2013-11-12 16:12:43 +01:00
|
|
|
function updateZoomLevel() {
|
|
|
|
|
zoomSlider.externalUpdate = true;
|
|
|
|
|
zoomSlider.value = Math.pow((view.endTime - view.startTime) / qmlProfilerModelProxy.traceDuration(), 1 / zoomSlider.exponent) * zoomSlider.maximumValue;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-12 12:44:54 +01:00
|
|
|
|
|
|
|
|
Slider {
|
|
|
|
|
id: zoomSlider
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
minimumValue: 1
|
|
|
|
|
maximumValue: 10000
|
|
|
|
|
stepSize: 100
|
|
|
|
|
|
2013-11-12 16:12:43 +01:00
|
|
|
property int exponent: 3
|
|
|
|
|
property bool externalUpdate: false
|
|
|
|
|
property int minWindowLength: 1e5 // 0.1 ms
|
|
|
|
|
|
|
|
|
|
onValueChanged: {
|
|
|
|
|
if (externalUpdate || qmlProfilerModelProxy.traceEndTime() <= qmlProfilerModelProxy.traceStartTime()) {
|
|
|
|
|
// Zoom range is independently updated. We shouldn't mess
|
|
|
|
|
// with it here as otherwise we might introduce rounding
|
|
|
|
|
// or arithmetic errors.
|
|
|
|
|
externalUpdate = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var windowLength = Math.max(
|
|
|
|
|
Math.pow(value / maximumValue, exponent) * qmlProfilerModelProxy.traceDuration(),
|
|
|
|
|
minWindowLength);
|
|
|
|
|
|
|
|
|
|
var fixedPoint = (view.startTime + view.endTime) / 2;
|
|
|
|
|
if (view.selectedItem !== -1) {
|
|
|
|
|
// center on selected item if it's inside the current screen
|
|
|
|
|
var newFixedPoint = qmlProfilerModelProxy.getStartTime(view.selectedModel, view.selectedItem);
|
|
|
|
|
if (newFixedPoint >= view.startTime && newFixedPoint < view.endTime)
|
|
|
|
|
fixedPoint = newFixedPoint;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var startTime = Math.max(qmlProfilerModelProxy.traceStartTime(), fixedPoint - windowLength / 2)
|
|
|
|
|
zoomControl.setRange(startTime, startTime + windowLength);
|
|
|
|
|
}
|
2013-11-12 12:44:54 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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 {
|
2013-11-08 18:32:02 +01:00
|
|
|
y: root.height - height
|
2011-11-16 16:08:05 +01:00
|
|
|
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
|
|
|
}
|