2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-03-25 09:25:17 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 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
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
property alias selectionLocked : view.selectionLocked
|
|
|
|
|
signal updateLockButton
|
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)
|
|
|
|
|
|
2014-02-27 12:14:45 +01:00
|
|
|
color: "#dcdcdc"
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
// ***** connections with external objects
|
|
|
|
|
Connections {
|
|
|
|
|
target: zoomControl
|
|
|
|
|
onRangeChanged: {
|
|
|
|
|
var startTime = zoomControl.startTime();
|
|
|
|
|
var endTime = zoomControl.endTime();
|
|
|
|
|
|
2013-12-02 16:16:33 +01:00
|
|
|
mainviewTimePerPixel = Math.abs(endTime - startTime) / root.width;
|
2011-10-11 17:52:39 +02:00
|
|
|
|
|
|
|
|
backgroundMarks.updateMarks(startTime, endTime);
|
2014-03-28 16:11:16 +01:00
|
|
|
view.startTime = startTime;
|
|
|
|
|
view.endTime = endTime;
|
|
|
|
|
view.updateWindow();
|
|
|
|
|
}
|
|
|
|
|
onWindowChanged: {
|
|
|
|
|
view.updateWindow();
|
2011-10-11 17:52:39 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
2012-02-13 15:26:57 +01:00
|
|
|
onStateChanged: {
|
2014-02-12 18:13:10 +01:00
|
|
|
// Clear if model is empty.
|
|
|
|
|
if (qmlProfilerModelProxy.getState() === 0)
|
2014-03-25 17:10:25 +01:00
|
|
|
root.clear();
|
2011-10-11 17:52:39 +02:00
|
|
|
}
|
2013-08-08 13:28:08 +02:00
|
|
|
onDataAvailable: {
|
|
|
|
|
view.clearData();
|
|
|
|
|
zoomControl.setRange(qmlProfilerModelProxy.traceStartTime(),
|
|
|
|
|
qmlProfilerModelProxy.traceStartTime() +
|
|
|
|
|
qmlProfilerModelProxy.traceDuration()/10);
|
2014-03-25 17:10:25 +01:00
|
|
|
view.requestPaint();
|
2013-08-08 13:28:08 +02:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
2014-03-25 17:10:25 +01:00
|
|
|
function clear() {
|
|
|
|
|
flick.contentY = 0;
|
|
|
|
|
flick.contentX = 0;
|
|
|
|
|
flick.contentWidth = 0;
|
2011-04-06 16:04:18 +02:00
|
|
|
view.clearData();
|
2014-03-25 17:10:25 +01:00
|
|
|
view.startTime = view.endTime = 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);
|
2014-03-25 17:10:25 +01:00
|
|
|
zoomSlider.externalUpdate = true;
|
|
|
|
|
zoomSlider.value = zoomSlider.minimumValue;
|
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-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);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-26 11:25:10 +01: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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
function hideRangeDetails() {
|
|
|
|
|
rangeDetails.visible = false;
|
|
|
|
|
rangeDetails.duration = "";
|
|
|
|
|
rangeDetails.label = "";
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2014-04-03 11:15:56 +02:00
|
|
|
function selectById(eventId)
|
2011-11-09 12:57:41 +01:00
|
|
|
{
|
2014-04-03 11:15:56 +02:00
|
|
|
if (eventId === -1 ||
|
|
|
|
|
eventId === qmlProfilerModelProxy.getEventId(view.selectedModel, view.selectedItem))
|
|
|
|
|
return;
|
|
|
|
|
|
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();
|
2014-03-26 11:25:10 +01:00
|
|
|
var itemIndex = view.nextItemFromId(modelIndex, eventId);
|
2011-11-09 12:57:41 +01:00
|
|
|
// select an item, lock to it, and recenter if necessary
|
2014-03-26 11:47:52 +01:00
|
|
|
view.selectFromId(modelIndex, itemIndex); // triggers recentering
|
|
|
|
|
if (itemIndex !== -1)
|
|
|
|
|
view.selectionLocked = true;
|
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;
|
2014-02-20 15:22:22 +01:00
|
|
|
selectionRange.reset();
|
2011-10-19 14:28:21 +02:00
|
|
|
}
|
|
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
onSelectionLockedChanged: {
|
|
|
|
|
updateLockButton();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-08 12:05:18 +01:00
|
|
|
Flickable {
|
2014-02-27 12:14:45 +01:00
|
|
|
id: labelsflick
|
2013-11-08 12:05:18 +01:00
|
|
|
flickableDirection: Flickable.VerticalFlick
|
2014-02-27 12:14:45 +01:00
|
|
|
interactive: false
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
width: labels.width
|
|
|
|
|
contentY: flick.contentY
|
|
|
|
|
|
2014-03-04 17:56:14 +01:00
|
|
|
// reserve some more space than needed to prevent weird effects when resizing
|
|
|
|
|
contentHeight: labels.height + height
|
|
|
|
|
|
2014-02-27 12:14:45 +01:00
|
|
|
Rectangle {
|
|
|
|
|
id: labels
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
width: 150
|
|
|
|
|
color: root.color
|
|
|
|
|
height: col.height
|
|
|
|
|
|
|
|
|
|
property int rowCount: qmlProfilerModelProxy.categoryCount();
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
id: col
|
|
|
|
|
Repeater {
|
|
|
|
|
model: labels.rowCount
|
|
|
|
|
delegate: CategoryLabel { }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// border between labels and timeline
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: labelsborder
|
|
|
|
|
anchors.left: labelsflick.right
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
width: 1
|
|
|
|
|
color: "#858585"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Flickable {
|
|
|
|
|
id: flick
|
2013-11-08 12:05:18 +01:00
|
|
|
contentHeight: labels.height
|
2014-02-27 12:14:45 +01:00
|
|
|
contentWidth: 0
|
|
|
|
|
flickableDirection: Flickable.HorizontalAndVerticalFlick
|
2013-11-14 13:06:44 +01:00
|
|
|
boundsBehavior: Flickable.StopAtBounds
|
2014-02-27 12:14:45 +01:00
|
|
|
clip:true
|
2013-11-14 13:06:44 +01:00
|
|
|
|
|
|
|
|
// ScrollView will try to deinteractivate it. We don't want that
|
2013-11-20 15:57:07 +01:00
|
|
|
// as the horizontal flickable is interactive, too. We do occasionally
|
|
|
|
|
// switch to non-interactive ourselves, though.
|
|
|
|
|
property bool stayInteractive: true
|
|
|
|
|
onInteractiveChanged: interactive = stayInteractive
|
|
|
|
|
onStayInteractiveChanged: interactive = stayInteractive
|
2012-02-24 10:47:17 +01:00
|
|
|
|
2014-03-03 14:04:50 +01:00
|
|
|
onContentXChanged: view.updateZoomControl()
|
|
|
|
|
onWidthChanged: {
|
2014-02-27 12:14:45 +01:00
|
|
|
var duration = Math.abs(zoomControl.endTime() - zoomControl.startTime());
|
|
|
|
|
if (duration > 0)
|
2014-03-28 16:11:16 +01:00
|
|
|
contentWidth = zoomControl.windowLength() * width / duration;
|
2014-02-27 12:14:45 +01:00
|
|
|
}
|
|
|
|
|
|
2013-11-11 16:55:15 +01:00
|
|
|
// ***** child items
|
|
|
|
|
TimeMarks {
|
|
|
|
|
id: backgroundMarks
|
2014-02-27 12:14:45 +01:00
|
|
|
y: flick.contentY
|
|
|
|
|
x: flick.contentX
|
|
|
|
|
height: flick.height
|
|
|
|
|
width: scroller.width
|
2011-10-11 17:52:39 +02:00
|
|
|
}
|
|
|
|
|
|
2014-02-27 12:14:45 +01:00
|
|
|
SelectionRange {
|
|
|
|
|
id: selectionRange
|
|
|
|
|
visible: root.selectionRangeMode && creationState !== 0
|
|
|
|
|
z: 2
|
|
|
|
|
}
|
2011-09-23 15:58:41 +02:00
|
|
|
|
2014-02-27 12:14:45 +01:00
|
|
|
TimelineRenderer {
|
|
|
|
|
id: view
|
2011-06-24 18:19:08 +02:00
|
|
|
|
2014-02-27 12:14:45 +01:00
|
|
|
profilerModelProxy: qmlProfilerModelProxy
|
2011-06-24 18:19:08 +02:00
|
|
|
|
2014-02-27 12:14:45 +01:00
|
|
|
x: flick.contentX
|
|
|
|
|
y: flick.contentY
|
2011-06-24 18:19:08 +02:00
|
|
|
|
2014-02-27 12:14:45 +01:00
|
|
|
// paint "under" the vertical scrollbar, so that it always matches with the timemarks
|
|
|
|
|
width: scroller.width
|
|
|
|
|
height: flick.height
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2014-02-27 12:14:45 +01:00
|
|
|
onEndTimeChanged: requestPaint()
|
|
|
|
|
onYChanged: requestPaint()
|
|
|
|
|
onHeightChanged: requestPaint()
|
2014-03-03 14:04:50 +01:00
|
|
|
property bool recursionGuard: false
|
2011-10-19 14:28:21 +02:00
|
|
|
|
2014-02-27 12:14:45 +01:00
|
|
|
function updateZoomControl() {
|
2014-03-03 14:04:50 +01:00
|
|
|
// Don't updateZoomControl if we're just updating the flick range, _from_
|
|
|
|
|
// zoomControl. The other way round is OK. We _want_ the flick range to be updated
|
|
|
|
|
// on external changes to zoomControl.
|
|
|
|
|
if (recursionGuard)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-02-27 12:14:45 +01:00
|
|
|
var newStartTime = Math.round(flick.contentX * (endTime - startTime) / flick.width) +
|
2014-03-28 16:11:16 +01:00
|
|
|
zoomControl.windowStart();
|
2014-02-27 12:14:45 +01:00
|
|
|
if (Math.abs(newStartTime - startTime) > 1) {
|
|
|
|
|
var newEndTime = Math.round((flick.contentX + flick.width) *
|
|
|
|
|
(endTime - startTime) /
|
2014-03-28 16:11:16 +01:00
|
|
|
flick.width) + zoomControl.windowStart();
|
2014-02-27 12:14:45 +01:00
|
|
|
zoomControl.setRange(newStartTime, newEndTime);
|
2013-11-11 16:55:15 +01:00
|
|
|
}
|
2011-10-26 11:32:01 +02:00
|
|
|
}
|
2014-02-27 12:14:45 +01:00
|
|
|
|
2014-03-28 16:11:16 +01:00
|
|
|
function updateWindow() {
|
|
|
|
|
var duration = zoomControl.duration();
|
|
|
|
|
if (recursionGuard || duration <= 0)
|
2014-03-03 14:04:50 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
recursionGuard = true;
|
|
|
|
|
|
2014-03-28 16:11:16 +01:00
|
|
|
if (!flick.movingHorizontally) {
|
2014-03-03 14:04:50 +01:00
|
|
|
// This triggers an unwanted automatic change in contentX. We ignore that by
|
|
|
|
|
// checking recursionGuard in this function and in updateZoomControl.
|
2014-03-28 16:11:16 +01:00
|
|
|
flick.contentWidth = zoomControl.windowLength() * flick.width / duration;
|
2014-03-03 14:04:50 +01:00
|
|
|
|
2014-03-28 16:11:16 +01:00
|
|
|
var newStartX = (startTime - zoomControl.windowStart()) * flick.width /
|
|
|
|
|
duration;
|
2014-03-03 14:04:50 +01:00
|
|
|
|
|
|
|
|
if (isFinite(newStartX) && Math.abs(newStartX - flick.contentX) >= 1)
|
|
|
|
|
flick.contentX = newStartX;
|
2013-11-11 16:55:15 +01:00
|
|
|
}
|
2014-03-03 14:04:50 +01:00
|
|
|
recursionGuard = false;
|
2011-10-19 14:28:21 +02:00
|
|
|
}
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2014-03-26 11:47:52 +01:00
|
|
|
onSelectionChanged: {
|
2014-02-27 12:14:45 +01:00
|
|
|
if (selectedItem !== -1) {
|
|
|
|
|
// display details
|
|
|
|
|
rangeDetails.showInfo(qmlProfilerModelProxy.getEventDetails(selectedModel, selectedItem));
|
|
|
|
|
rangeDetails.setLocation(qmlProfilerModelProxy.getEventLocation(selectedModel, selectedItem));
|
2013-11-11 16:55:15 +01:00
|
|
|
|
2014-02-27 12:14:45 +01:00
|
|
|
// center view (horizontally)
|
2014-03-26 11:41:46 +01:00
|
|
|
recenterOnItem(selectedModel, selectedItem);
|
2014-03-26 11:36:13 +01:00
|
|
|
if (!lockItemSelection) {
|
|
|
|
|
lockItemSelection = true;
|
|
|
|
|
// update in other views
|
|
|
|
|
var eventLocation = qmlProfilerModelProxy.getEventLocation(
|
|
|
|
|
view.selectedModel, view.selectedItem);
|
|
|
|
|
gotoSourceLocation(eventLocation.file, eventLocation.line,
|
|
|
|
|
eventLocation.column);
|
|
|
|
|
lockItemSelection = false;
|
2014-02-27 12:14:45 +01:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
root.hideRangeDetails();
|
2013-11-11 16:55:15 +01:00
|
|
|
}
|
2011-10-11 17:52:39 +02:00
|
|
|
}
|
2011-07-11 16:05:37 +02:00
|
|
|
|
2014-02-27 12:14:45 +01:00
|
|
|
onItemPressed: {
|
|
|
|
|
var location = qmlProfilerModelProxy.getEventLocation(modelIndex, pressedItem);
|
|
|
|
|
if (location.hasOwnProperty("file")) // not empty
|
|
|
|
|
root.gotoSourceLocation(location.file, location.line, location.column);
|
|
|
|
|
}
|
2013-11-11 16:55:15 +01:00
|
|
|
|
2014-02-27 12:14:45 +01:00
|
|
|
// hack to pass mouse events to the other mousearea if enabled
|
|
|
|
|
startDragArea: selectionRange.ready ? selectionRange.getLeft() : -flick.contentX
|
|
|
|
|
endDragArea: selectionRange.ready ? selectionRange.getRight() : -flick.contentX-1
|
|
|
|
|
}
|
|
|
|
|
MouseArea {
|
|
|
|
|
id: selectionRangeControl
|
|
|
|
|
enabled: false
|
|
|
|
|
width: flick.width
|
|
|
|
|
height: flick.height
|
|
|
|
|
x: flick.contentX
|
|
|
|
|
y: flick.contentY
|
|
|
|
|
hoverEnabled: enabled
|
|
|
|
|
z: 2
|
|
|
|
|
|
|
|
|
|
onReleased: {
|
|
|
|
|
selectionRange.releasedOnCreation();
|
|
|
|
|
}
|
|
|
|
|
onPressed: {
|
|
|
|
|
selectionRange.pressedOnCreation();
|
|
|
|
|
}
|
|
|
|
|
onCanceled: {
|
|
|
|
|
selectionRange.releasedOnCreation();
|
|
|
|
|
}
|
|
|
|
|
onPositionChanged: {
|
|
|
|
|
selectionRange.movedOnCreation();
|
|
|
|
|
}
|
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 {
|
2014-02-27 12:14:45 +01:00
|
|
|
id: scroller
|
|
|
|
|
contentItem: flick
|
|
|
|
|
anchors.left: labelsborder.right
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.right: parent.right
|
2013-11-14 13:06:44 +01:00
|
|
|
}
|
|
|
|
|
|
2013-11-08 12:05:18 +01:00
|
|
|
SelectionRangeDetails {
|
|
|
|
|
id: selectionRangeDetails
|
2014-02-20 15:22:22 +01:00
|
|
|
visible: selectionRange.visible
|
2013-11-08 12:05:18 +01:00
|
|
|
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
|
|
|
|
|
|
2013-11-12 16:12:43 +01:00
|
|
|
function updateZoomLevel() {
|
|
|
|
|
zoomSlider.externalUpdate = true;
|
2014-03-28 16:11:16 +01:00
|
|
|
zoomSlider.value = Math.pow((view.endTime - view.startTime) /
|
|
|
|
|
zoomControl.windowLength(),
|
|
|
|
|
1 / zoomSlider.exponent) * zoomSlider.maximumValue;
|
2013-11-12 16:12:43 +01:00
|
|
|
}
|
|
|
|
|
|
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: {
|
2014-03-28 16:11:16 +01:00
|
|
|
if (externalUpdate || zoomControl.windowEnd() <= zoomControl.windowStart()) {
|
2013-11-12 16:12:43 +01:00
|
|
|
// 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(
|
2014-03-28 16:11:16 +01:00
|
|
|
Math.pow(value / maximumValue, exponent) * zoomControl.windowLength(),
|
2013-11-12 16:12:43 +01:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-28 16:11:16 +01:00
|
|
|
var startTime = Math.max(zoomControl.windowStart(), fixedPoint - windowLength / 2)
|
2013-11-12 16:12:43 +01:00
|
|
|
zoomControl.setRange(startTime, startTime + windowLength);
|
|
|
|
|
}
|
2013-11-12 12:44:54 +01:00
|
|
|
}
|
|
|
|
|
}
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|