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
|
2014-10-01 13:21:18 +02:00
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/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
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
|
|
|
|
** 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
|
2014-10-30 14:57:49 +01:00
|
|
|
import QtQml.Models 2.1
|
2011-03-11 12:22:57 +01:00
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: root
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
// ***** properties
|
|
|
|
|
|
2014-10-30 14:57:49 +01:00
|
|
|
property bool selectionLocked : true
|
2011-11-09 12:57:41 +01:00
|
|
|
property bool lockItemSelection : false
|
2011-09-23 15:58:41 +02:00
|
|
|
|
2014-10-14 16:44:45 +02:00
|
|
|
property real mainviewTimePerPixel: zoomControl.rangeDuration / root.width
|
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
|
2014-09-29 16:24:34 +02:00
|
|
|
property int typeId: -1
|
2014-10-30 14:57:49 +01:00
|
|
|
property int selectedModel: -1
|
|
|
|
|
property int selectedItem: -1
|
2011-10-11 17:52:39 +02:00
|
|
|
|
2011-10-19 14:28:21 +02:00
|
|
|
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
|
|
|
|
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: {
|
2014-10-14 16:44:45 +02:00
|
|
|
zoomSliderToolBar.updateZoomLevel();
|
2014-10-30 14:57:49 +01:00
|
|
|
flick.updateWindow();
|
2014-03-28 16:11:16 +01:00
|
|
|
}
|
|
|
|
|
onWindowChanged: {
|
2014-10-30 14:57:49 +01:00
|
|
|
flick.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
|
|
|
|
|
onDataAvailable: {
|
2014-10-30 14:57:49 +01:00
|
|
|
timelineView.clearChildren();
|
2014-10-14 16:44:45 +02:00
|
|
|
zoomControl.setRange(zoomControl.traceStart,
|
|
|
|
|
zoomControl.traceStart + zoomControl.traceDuration / 10);
|
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;
|
|
|
|
|
}
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
2014-10-30 14:57:49 +01:00
|
|
|
function recenterOnItem() {
|
|
|
|
|
timelineView.select(selectedModel, selectedItem);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-25 17:10:25 +01:00
|
|
|
function clear() {
|
|
|
|
|
flick.contentY = 0;
|
|
|
|
|
flick.contentX = 0;
|
2014-10-30 14:57:49 +01:00
|
|
|
timelineView.clearChildren();
|
2014-09-25 12:50:10 +02:00
|
|
|
rangeDetails.hide();
|
2011-11-16 16:08:05 +01:00
|
|
|
selectionRangeMode = false;
|
2014-03-25 17:10:25 +01:00
|
|
|
zoomSlider.externalUpdate = true;
|
|
|
|
|
zoomSlider.value = zoomSlider.minimumValue;
|
2014-06-04 18:23:07 +02:00
|
|
|
overview.clear();
|
2011-06-24 18:19:08 +02:00
|
|
|
}
|
|
|
|
|
|
2014-10-30 14:57:49 +01:00
|
|
|
function propagateSelection(newModel, newItem) {
|
|
|
|
|
if (lockItemSelection || (newModel === selectedModel && newItem === selectedItem))
|
2011-11-09 12:57:41 +01:00
|
|
|
return;
|
|
|
|
|
|
2014-10-30 14:57:49 +01:00
|
|
|
lockItemSelection = true;
|
|
|
|
|
if (selectedModel !== -1 && selectedModel !== newModel)
|
|
|
|
|
timelineView.select(selectedModel, -1);
|
|
|
|
|
|
|
|
|
|
selectedItem = newItem
|
|
|
|
|
selectedModel = newModel
|
|
|
|
|
if (selectedItem !== -1) {
|
|
|
|
|
// display details
|
|
|
|
|
rangeDetails.showInfo(selectedModel, selectedItem);
|
|
|
|
|
|
|
|
|
|
// update in other views
|
|
|
|
|
var model = qmlProfilerModelProxy.models[selectedModel];
|
|
|
|
|
var eventLocation = model.location(selectedItem);
|
|
|
|
|
gotoSourceLocation(eventLocation.file, eventLocation.line,
|
|
|
|
|
eventLocation.column);
|
|
|
|
|
typeId = model.typeId(selectedItem);
|
|
|
|
|
updateCursorPosition();
|
|
|
|
|
} else {
|
|
|
|
|
rangeDetails.hide();
|
2011-11-03 16:15:50 +01:00
|
|
|
}
|
2014-10-30 14:57:49 +01:00
|
|
|
lockItemSelection = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function enableButtonsBar(enable) {
|
|
|
|
|
buttonsBar.enabled = enable;
|
2011-11-03 16:15:50 +01:00
|
|
|
}
|
|
|
|
|
|
2014-10-28 12:56:53 +01:00
|
|
|
function selectByTypeId(typeId)
|
2011-11-09 12:57:41 +01:00
|
|
|
{
|
2014-10-28 12:56:53 +01:00
|
|
|
if (lockItemSelection || typeId === -1)
|
2014-04-03 11:15:56 +02:00
|
|
|
return;
|
|
|
|
|
|
2014-10-28 12:56:53 +01:00
|
|
|
var itemIndex = -1;
|
|
|
|
|
var modelIndex = -1;
|
|
|
|
|
var notes = qmlProfilerModelProxy.notesByTypeId(typeId);
|
|
|
|
|
if (notes.length !== 0) {
|
|
|
|
|
modelIndex = qmlProfilerModelProxy.noteTimelineModel(notes[0]);
|
|
|
|
|
itemIndex = qmlProfilerModelProxy.noteTimelineIndex(notes[0]);
|
|
|
|
|
} else {
|
2014-10-30 14:57:49 +01:00
|
|
|
for (modelIndex = 0; modelIndex < qmlProfilerModelProxy.models.length; ++modelIndex) {
|
|
|
|
|
if (modelIndex === selectedModel && selectedItem !== -1 &&
|
|
|
|
|
typeId === qmlProfilerModelProxy.models[modelIndex].typeId(selectedItem))
|
2014-10-28 12:56:53 +01:00
|
|
|
break;
|
|
|
|
|
|
2014-10-30 14:57:49 +01:00
|
|
|
if (!qmlProfilerModelProxy.models[modelIndex].handlesTypeId(typeId))
|
2014-10-28 12:56:53 +01:00
|
|
|
continue;
|
|
|
|
|
|
2014-10-30 14:57:49 +01:00
|
|
|
itemIndex = qmlProfilerModelProxy.models[modelIndex].nextItemByTypeId(typeId,
|
|
|
|
|
zoomControl.rangeStart, selectedItem);
|
2014-10-28 12:56:53 +01:00
|
|
|
if (itemIndex !== -1)
|
|
|
|
|
break;
|
2014-09-29 18:20:26 +02:00
|
|
|
}
|
2014-10-28 12:56:53 +01:00
|
|
|
}
|
2014-09-29 18:20:26 +02:00
|
|
|
|
2014-10-28 12:56:53 +01:00
|
|
|
if (itemIndex !== -1) {
|
2011-11-09 12:57:41 +01:00
|
|
|
// select an item, lock to it, and recenter if necessary
|
2014-10-30 14:57:49 +01:00
|
|
|
timelineView.select(modelIndex, itemIndex);
|
|
|
|
|
root.selectionLocked = true;
|
2011-11-09 12:57:41 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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();
|
2014-06-04 18:23:07 +02:00
|
|
|
buttonsBar.updateRangeButton(selectionRangeMode);
|
2011-10-19 14:28:21 +02:00
|
|
|
}
|
|
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
onSelectionLockedChanged: {
|
2014-06-04 18:23:07 +02:00
|
|
|
buttonsBar.updateLockButton(selectionLocked);
|
2011-10-26 11:32:01 +02:00
|
|
|
}
|
|
|
|
|
|
2014-06-23 15:46:40 +02:00
|
|
|
focus: true
|
|
|
|
|
property bool shiftPressed: false;
|
|
|
|
|
Keys.onPressed: shiftPressed = (event.key === Qt.Key_Shift);
|
|
|
|
|
Keys.onReleased: shiftPressed = false;
|
|
|
|
|
|
2013-11-08 12:05:18 +01:00
|
|
|
Flickable {
|
2014-11-07 18:13:31 +01:00
|
|
|
id: categories
|
2013-11-08 12:05:18 +01:00
|
|
|
flickableDirection: Flickable.VerticalFlick
|
2014-02-27 12:14:45 +01:00
|
|
|
interactive: false
|
2014-06-04 18:23:07 +02:00
|
|
|
anchors.top: buttonsBar.bottom
|
|
|
|
|
anchors.bottom: overview.top
|
2014-02-27 12:14:45 +01:00
|
|
|
anchors.left: parent.left
|
2014-11-07 18:13:31 +01:00
|
|
|
anchors.right: parent.right
|
2014-02-27 12:14:45 +01:00
|
|
|
contentY: flick.contentY
|
|
|
|
|
|
2014-03-04 17:56:14 +01:00
|
|
|
// reserve some more space than needed to prevent weird effects when resizing
|
2014-11-07 18:13:31 +01:00
|
|
|
contentHeight: categoryContent.height + height
|
2014-03-04 17:56:14 +01:00
|
|
|
|
2014-11-07 18:13:31 +01:00
|
|
|
// Dispatch the cursor shape to all labels. When dragging the DropArea receiving
|
|
|
|
|
// the drag events is not necessarily related to the MouseArea receiving the mouse
|
|
|
|
|
// events, so we can't use the drag events to determine the cursor shape.
|
|
|
|
|
property bool dragging: false
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
id: categoryContent
|
2014-02-27 12:14:45 +01:00
|
|
|
anchors.left: parent.left
|
2014-11-07 18:13:31 +01:00
|
|
|
anchors.right: parent.right
|
|
|
|
|
|
|
|
|
|
DelegateModel {
|
|
|
|
|
id: labelsModel
|
|
|
|
|
|
|
|
|
|
// As we cannot retrieve items by visible index we keep an array of row counts here,
|
|
|
|
|
// for the time marks to draw the row backgrounds in the right colors.
|
|
|
|
|
property var rowCounts: new Array(qmlProfilerModelProxy.models.length)
|
|
|
|
|
|
|
|
|
|
function updateRowCount(visualIndex, rowCount) {
|
|
|
|
|
if (rowCounts[visualIndex] !== rowCount) {
|
|
|
|
|
rowCounts[visualIndex] = rowCount;
|
|
|
|
|
// Array don't "change" if entries change. We have to signal manually.
|
|
|
|
|
rowCountsChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model: qmlProfilerModelProxy.models
|
|
|
|
|
delegate: Rectangle {
|
|
|
|
|
color: root.color
|
|
|
|
|
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
property int visualIndex: DelegateModel.itemsIndex
|
|
|
|
|
height: label.visible ? label.height : 0
|
|
|
|
|
|
|
|
|
|
CategoryLabel {
|
|
|
|
|
id: label
|
2014-10-30 14:57:49 +01:00
|
|
|
model: modelData
|
2014-11-07 18:13:31 +01:00
|
|
|
mockup: qmlProfilerModelProxy.height === 0
|
|
|
|
|
visualIndex: parent.visualIndex
|
|
|
|
|
dragging: categories.dragging
|
2014-06-23 15:46:40 +02:00
|
|
|
reverseSelect: root.shiftPressed
|
2014-11-07 18:13:31 +01:00
|
|
|
onDragStarted: categories.dragging = true
|
|
|
|
|
onDragStopped: categories.dragging = false
|
|
|
|
|
draggerParent: categories
|
|
|
|
|
width: 150
|
|
|
|
|
dragOffset: parent.y
|
2014-10-30 14:57:49 +01:00
|
|
|
|
|
|
|
|
onDropped: {
|
|
|
|
|
timelineModel.items.move(sourceIndex, targetIndex);
|
|
|
|
|
labelsModel.items.move(sourceIndex, targetIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onSelectById: {
|
|
|
|
|
timelineView.select(index, eventId)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onSelectNextBySelectionId: {
|
|
|
|
|
timelineView.select(index, modelData.nextItemBySelectionId(selectionId,
|
|
|
|
|
zoomControl.rangeStart,
|
|
|
|
|
root.selectedModel === index ? root.selectedItem : -1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onSelectPrevBySelectionId: {
|
|
|
|
|
timelineView.select(index, modelData.prevItemBySelectionId(selectionId,
|
|
|
|
|
zoomControl.rangeStart,
|
|
|
|
|
root.selectedModel === index ? root.selectedItem : -1));
|
|
|
|
|
}
|
2014-11-07 18:13:31 +01:00
|
|
|
}
|
2014-10-30 14:57:49 +01:00
|
|
|
|
2014-11-07 18:13:31 +01:00
|
|
|
TimeMarks {
|
|
|
|
|
id: timeMarks
|
|
|
|
|
model: modelData
|
|
|
|
|
mockup: qmlProfilerModelProxy.height === 0
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.left: label.right
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
property int visualIndex: parent.visualIndex
|
|
|
|
|
|
|
|
|
|
// Quite a mouthful, but works fine: Add up all the row counts up to the one
|
|
|
|
|
// for this visual index and check if the result is even or odd.
|
|
|
|
|
startOdd: (labelsModel.rowCounts.slice(0, visualIndex).reduce(
|
|
|
|
|
function(prev, rows) {return prev + rows}, 0) % 2) === 0
|
2014-10-30 14:57:49 +01:00
|
|
|
|
2014-11-07 18:13:31 +01:00
|
|
|
onRowCountChanged: labelsModel.updateRowCount(visualIndex, rowCount)
|
|
|
|
|
onVisualIndexChanged: labelsModel.updateRowCount(visualIndex, rowCount)
|
2014-06-23 15:46:40 +02:00
|
|
|
}
|
2014-10-30 14:57:49 +01:00
|
|
|
|
2014-11-07 18:13:31 +01:00
|
|
|
Rectangle {
|
|
|
|
|
visible: label.visible
|
|
|
|
|
opacity: parent.y == 0 ? 0 : 1
|
|
|
|
|
color: "#B0B0B0"
|
|
|
|
|
height: 1
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
}
|
2014-10-30 14:57:49 +01:00
|
|
|
}
|
2014-02-27 12:14:45 +01:00
|
|
|
}
|
2014-11-07 18:13:31 +01:00
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
|
model: labelsModel
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.top: categoryContent.bottom
|
|
|
|
|
height: 1
|
|
|
|
|
color: "#B0B0B0"
|
2014-02-27 12:14:45 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-07 18:13:31 +01:00
|
|
|
TimeDisplay {
|
|
|
|
|
id: timeDisplay
|
2014-02-27 12:14:45 +01:00
|
|
|
anchors.top: parent.top
|
2014-11-07 18:13:31 +01:00
|
|
|
anchors.left: buttonsBar.right
|
|
|
|
|
anchors.right: parent.right
|
2014-06-04 18:23:07 +02:00
|
|
|
anchors.bottom: overview.top
|
2014-11-07 18:13:31 +01:00
|
|
|
zoomer: zoomControl
|
|
|
|
|
contentX: flick.contentX
|
|
|
|
|
clip: true
|
2014-02-27 12:14:45 +01:00
|
|
|
}
|
|
|
|
|
|
2014-06-04 18:23:07 +02:00
|
|
|
ButtonsBar {
|
|
|
|
|
id: buttonsBar
|
|
|
|
|
enabled: false
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
width: 150
|
|
|
|
|
height: 24
|
|
|
|
|
onZoomControlChanged: zoomSliderToolBar.visible = !zoomSliderToolBar.visible
|
2014-09-11 11:44:27 +02:00
|
|
|
onFilterMenuChanged: filterMenu.visible = !filterMenu.visible
|
2014-11-04 12:54:27 +01:00
|
|
|
onJumpToNext: {
|
2014-10-30 14:57:49 +01:00
|
|
|
var next = qmlProfilerModelProxy.nextItem(root.selectedModel, root.selectedItem,
|
2014-11-04 12:54:27 +01:00
|
|
|
zoomControl.rangeStart);
|
2014-10-30 14:57:49 +01:00
|
|
|
timelineView.select(next.model, next.item);
|
2014-11-04 12:54:27 +01:00
|
|
|
}
|
|
|
|
|
onJumpToPrev: {
|
2014-10-30 14:57:49 +01:00
|
|
|
var prev = qmlProfilerModelProxy.prevItem(root.selectedModel, root.selectedItem,
|
2014-11-04 12:54:27 +01:00
|
|
|
zoomControl.rangeEnd);
|
2014-10-30 14:57:49 +01:00
|
|
|
timelineView.select(prev.model, prev.item);
|
2014-11-04 12:54:27 +01:00
|
|
|
}
|
2014-10-30 14:57:49 +01:00
|
|
|
|
2014-06-04 18:23:07 +02:00
|
|
|
onRangeSelectChanged: selectionRangeMode = rangeButtonChecked();
|
|
|
|
|
onLockChanged: selectionLocked = !lockButtonChecked();
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-27 12:14:45 +01:00
|
|
|
Flickable {
|
|
|
|
|
id: flick
|
2014-11-07 18:13:31 +01:00
|
|
|
contentHeight: categoryContent.height
|
2014-02-27 12:14:45 +01:00
|
|
|
flickableDirection: Flickable.HorizontalAndVerticalFlick
|
2013-11-14 13:06:44 +01:00
|
|
|
boundsBehavior: Flickable.StopAtBounds
|
2014-11-26 16:53:42 +01:00
|
|
|
pixelAligned: 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-10-30 14:57:49 +01:00
|
|
|
property bool recursionGuard: false
|
2014-11-26 16:53:42 +01:00
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
|
2014-10-30 14:57:49 +01:00
|
|
|
// Update the zoom control on srolling.
|
2014-11-26 16:53:42 +01:00
|
|
|
onContentXChanged: {
|
2014-10-30 14:57:49 +01:00
|
|
|
if (recursionGuard)
|
|
|
|
|
return;
|
2011-09-23 15:58:41 +02:00
|
|
|
|
2014-10-30 14:57:49 +01:00
|
|
|
recursionGuard = true;
|
2011-06-24 18:19:08 +02:00
|
|
|
|
2014-11-26 16:53:42 +01:00
|
|
|
var newStartTime = contentX * zoomControl.rangeDuration / scroller.width +
|
2014-10-30 14:57:49 +01:00
|
|
|
zoomControl.windowStart;
|
2014-11-26 16:53:42 +01:00
|
|
|
if (isFinite(newStartTime) && Math.abs(newStartTime - zoomControl.rangeStart) >= 1) {
|
|
|
|
|
var newEndTime = (contentX + scroller.width) * zoomControl.rangeDuration /
|
|
|
|
|
scroller.width + zoomControl.windowStart;
|
|
|
|
|
if (isFinite(newEndTime))
|
|
|
|
|
zoomControl.setRange(newStartTime, newEndTime);
|
2014-10-30 14:57:49 +01:00
|
|
|
}
|
|
|
|
|
recursionGuard = false;
|
|
|
|
|
}
|
2011-06-24 18:19:08 +02:00
|
|
|
|
2014-10-30 14:57:49 +01:00
|
|
|
// Scroll when the zoom control is updated
|
|
|
|
|
function updateWindow() {
|
|
|
|
|
if (recursionGuard || zoomControl.rangeDuration <= 0)
|
|
|
|
|
return;
|
|
|
|
|
recursionGuard = true;
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2014-11-26 16:53:42 +01:00
|
|
|
var newWidth = zoomControl.windowDuration * scroller.width /
|
2014-10-30 14:57:49 +01:00
|
|
|
zoomControl.rangeDuration;
|
2014-11-26 16:53:42 +01:00
|
|
|
if (isFinite(newWidth) && Math.abs(newWidth - contentWidth) >= 1)
|
|
|
|
|
contentWidth = newWidth;
|
2011-10-19 14:28:21 +02:00
|
|
|
|
2014-11-26 16:53:42 +01:00
|
|
|
var newStartX = (zoomControl.rangeStart - zoomControl.windowStart) * scroller.width /
|
2014-10-30 14:57:49 +01:00
|
|
|
zoomControl.rangeDuration;
|
2014-11-26 16:53:42 +01:00
|
|
|
if (isFinite(newStartX) && Math.abs(newStartX - contentX) >= 1)
|
|
|
|
|
contentX = newStartX;
|
2014-10-14 16:44:45 +02:00
|
|
|
|
2014-10-30 14:57:49 +01:00
|
|
|
recursionGuard = false;
|
|
|
|
|
}
|
2014-03-03 14:04:50 +01:00
|
|
|
|
2014-10-30 14:57:49 +01:00
|
|
|
// ***** child items
|
|
|
|
|
SelectionRange {
|
|
|
|
|
id: selectionRange
|
|
|
|
|
visible: root.selectionRangeMode && creationState !== 0
|
|
|
|
|
z: 2
|
|
|
|
|
}
|
2014-10-14 16:44:45 +02:00
|
|
|
|
2014-10-30 14:57:49 +01:00
|
|
|
Column {
|
|
|
|
|
id: timelineView
|
|
|
|
|
|
|
|
|
|
signal clearChildren
|
|
|
|
|
signal select(int modelIndex, int eventIndex)
|
|
|
|
|
|
|
|
|
|
DelegateModel {
|
|
|
|
|
id: timelineModel
|
|
|
|
|
model: qmlProfilerModelProxy.models
|
2014-11-18 18:32:43 +01:00
|
|
|
delegate: TimelineRenderer {
|
|
|
|
|
id: renderer
|
|
|
|
|
model: modelData
|
|
|
|
|
notes: qmlProfilerModelProxy.notes
|
|
|
|
|
zoomer: zoomControl
|
|
|
|
|
selectionLocked: root.selectionLocked
|
|
|
|
|
x: 0
|
|
|
|
|
|
2014-10-30 14:57:49 +01:00
|
|
|
height: modelData.height
|
|
|
|
|
property int visualIndex: DelegateModel.itemsIndex
|
|
|
|
|
|
2014-11-18 18:32:43 +01:00
|
|
|
// paint "under" the vertical scrollbar, so that it always matches with the
|
|
|
|
|
// timemarks
|
|
|
|
|
width: flick.contentWidth
|
2014-10-30 14:57:49 +01:00
|
|
|
|
2014-11-18 18:32:43 +01:00
|
|
|
Connections {
|
|
|
|
|
target: timelineView
|
|
|
|
|
onClearChildren: renderer.clearData()
|
|
|
|
|
onSelect: {
|
|
|
|
|
if (modelIndex === index || modelIndex === -1) {
|
|
|
|
|
renderer.selectedItem = eventIndex;
|
|
|
|
|
if (eventIndex !== -1)
|
|
|
|
|
renderer.recenter();
|
2014-10-30 14:57:49 +01:00
|
|
|
}
|
|
|
|
|
}
|
2014-11-18 18:32:43 +01:00
|
|
|
}
|
2014-10-30 14:57:49 +01:00
|
|
|
|
2014-11-18 18:32:43 +01:00
|
|
|
Connections {
|
|
|
|
|
target: root
|
2014-10-30 14:57:49 +01:00
|
|
|
onSelectionLockedChanged: {
|
2014-11-18 18:32:43 +01:00
|
|
|
renderer.selectionLocked = root.selectionLocked;
|
2014-10-30 14:57:49 +01:00
|
|
|
}
|
2014-11-18 18:32:43 +01:00
|
|
|
}
|
2014-10-30 14:57:49 +01:00
|
|
|
|
2014-11-18 18:32:43 +01:00
|
|
|
onSelectionLockedChanged: {
|
|
|
|
|
root.selectionLocked = renderer.selectionLocked;
|
|
|
|
|
}
|
2014-10-30 14:57:49 +01:00
|
|
|
|
2014-11-18 18:32:43 +01:00
|
|
|
function recenter() {
|
|
|
|
|
if (modelData.endTime(selectedItem) < zoomer.rangeStart ||
|
|
|
|
|
modelData.startTime(selectedItem) > zoomer.rangeEnd) {
|
2014-10-30 14:57:49 +01:00
|
|
|
|
2014-11-18 18:32:43 +01:00
|
|
|
var newStart = (modelData.startTime(selectedItem) +
|
|
|
|
|
modelData.endTime(selectedItem) -
|
|
|
|
|
zoomer.rangeDuration) / 2;
|
|
|
|
|
zoomer.setRange(Math.max(newStart, zoomer.traceStart),
|
|
|
|
|
Math.min(newStart + zoomer.rangeDuration,
|
|
|
|
|
zoomer.traceEnd));
|
2014-10-30 14:57:49 +01:00
|
|
|
}
|
|
|
|
|
|
2014-11-18 18:32:43 +01:00
|
|
|
var row = modelData.row(selectedItem);
|
|
|
|
|
var rowStart = modelData.rowOffset(row) + y;
|
|
|
|
|
var rowEnd = rowStart + modelData.rowHeight(row);
|
|
|
|
|
if (rowStart < flick.contentY || rowEnd - scroller.height > flick.contentY)
|
|
|
|
|
flick.contentY = (rowStart + rowEnd - scroller.height) / 2;
|
|
|
|
|
}
|
2014-10-30 14:57:49 +01:00
|
|
|
|
2014-11-18 18:32:43 +01:00
|
|
|
onSelectedItemChanged: {
|
|
|
|
|
root.propagateSelection(index, selectedItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onItemPressed: {
|
|
|
|
|
if (pressedItem === -1) {
|
|
|
|
|
// User clicked on empty space. Remove selection.
|
|
|
|
|
root.propagateSelection(-1, -1);
|
|
|
|
|
} else {
|
|
|
|
|
var location = model.location(pressedItem);
|
|
|
|
|
if (location.hasOwnProperty("file")) // not empty
|
|
|
|
|
root.gotoSourceLocation(location.file, location.line, location.column);
|
|
|
|
|
root.typeId = model.typeId(pressedItem);
|
|
|
|
|
root.updateCursorPosition();
|
2014-10-30 14:57:49 +01:00
|
|
|
}
|
2014-02-27 12:14:45 +01:00
|
|
|
}
|
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-10-30 14:57:49 +01:00
|
|
|
Repeater {
|
|
|
|
|
id: repeater
|
|
|
|
|
model: timelineModel
|
2014-02-27 12:14:45 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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
|
2014-11-07 18:13:31 +01:00
|
|
|
anchors.left: buttonsBar.right
|
|
|
|
|
anchors.top: categories.top
|
2014-06-04 18:23:07 +02:00
|
|
|
anchors.bottom: overview.top
|
2014-02-27 12:14:45 +01:00
|
|
|
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
|
2014-07-08 14:46:17 +02:00
|
|
|
showDuration: selectionRange.rangeWidth > 1
|
2013-11-08 12:05:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RangeDetails {
|
|
|
|
|
id: rangeDetails
|
2014-10-30 14:57:49 +01:00
|
|
|
property alias locked: root.selectionLocked
|
|
|
|
|
models: qmlProfilerModelProxy.models
|
|
|
|
|
notes: qmlProfilerModelProxy.notes
|
2013-11-08 12:05:18 +01:00
|
|
|
}
|
2011-11-16 16:08:05 +01:00
|
|
|
|
2014-11-07 18:13:31 +01:00
|
|
|
Rectangle {
|
|
|
|
|
anchors.left: buttonsBar.right
|
|
|
|
|
anchors.bottom: overview.top
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
width: 1
|
|
|
|
|
color: "#B0B0B0"
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-11 11:44:27 +02:00
|
|
|
Rectangle {
|
|
|
|
|
id: filterMenu
|
|
|
|
|
color: "#9b9b9b"
|
|
|
|
|
enabled: buttonsBar.enabled
|
|
|
|
|
visible: false
|
2014-11-07 18:13:31 +01:00
|
|
|
width: buttonsBar.width
|
2014-09-11 11:44:27 +02:00
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.top: buttonsBar.bottom
|
2014-10-30 14:57:49 +01:00
|
|
|
height: qmlProfilerModelProxy.models.length * buttonsBar.height
|
2014-09-11 11:44:27 +02:00
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
|
id: filterMenuInner
|
|
|
|
|
model: qmlProfilerModelProxy.models
|
|
|
|
|
CheckBox {
|
|
|
|
|
anchors.left: filterMenu.left
|
|
|
|
|
anchors.right: filterMenu.right
|
|
|
|
|
height: buttonsBar.height
|
|
|
|
|
y: index * height
|
2014-10-30 14:57:49 +01:00
|
|
|
text: modelData.displayName
|
|
|
|
|
enabled: !modelData.empty
|
|
|
|
|
checked: enabled && !modelData.hidden
|
|
|
|
|
onCheckedChanged: modelData.hidden = !checked
|
2014-09-11 11:44:27 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-12 12:44:54 +01:00
|
|
|
Rectangle {
|
2014-06-04 18:23:07 +02:00
|
|
|
id: zoomSliderToolBar
|
2013-11-12 12:44:54 +01:00
|
|
|
objectName: "zoomSliderToolBar"
|
|
|
|
|
color: "#9b9b9b"
|
2014-06-04 18:23:07 +02:00
|
|
|
enabled: buttonsBar.enabled
|
2013-11-12 12:44:54 +01:00
|
|
|
visible: false
|
2014-11-07 18:13:31 +01:00
|
|
|
width: categoryContent.width
|
2014-09-11 11:44:27 +02:00
|
|
|
height: buttonsBar.height
|
2014-06-04 18:23:07 +02:00
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.top: buttonsBar.bottom
|
2013-11-12 12:44:54 +01:00
|
|
|
|
2013-11-12 16:12:43 +01:00
|
|
|
function updateZoomLevel() {
|
|
|
|
|
zoomSlider.externalUpdate = true;
|
2014-10-14 16:44:45 +02:00
|
|
|
zoomSlider.value = Math.pow(zoomControl.rangeDuration /
|
|
|
|
|
Math.max(1, zoomControl.windowDuration),
|
2014-03-28 16:11:16 +01:00
|
|
|
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-10-14 16:44:45 +02: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-10-14 16:44:45 +02:00
|
|
|
Math.pow(value / maximumValue, exponent) * zoomControl.windowDuration,
|
2013-11-12 16:12:43 +01:00
|
|
|
minWindowLength);
|
|
|
|
|
|
2014-10-14 16:44:45 +02:00
|
|
|
var fixedPoint = (zoomControl.rangeStart + zoomControl.rangeEnd) / 2;
|
2014-10-30 14:57:49 +01:00
|
|
|
if (root.selectedItem !== -1) {
|
2013-11-12 16:12:43 +01:00
|
|
|
// center on selected item if it's inside the current screen
|
2014-10-30 14:57:49 +01:00
|
|
|
var model = qmlProfilerModelProxy.models[root.selectedModel]
|
|
|
|
|
var newFixedPoint = (model.startTime(root.selectedItem) +
|
|
|
|
|
model.endTime(root.selectedItem)) / 2;
|
2014-10-14 16:44:45 +02:00
|
|
|
if (newFixedPoint >= zoomControl.rangeStart &&
|
|
|
|
|
newFixedPoint < zoomControl.rangeEnd)
|
2013-11-12 16:12:43 +01:00
|
|
|
fixedPoint = newFixedPoint;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-14 16:44:45 +02: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
|
|
|
}
|
|
|
|
|
}
|
2014-06-04 18:23:07 +02:00
|
|
|
|
|
|
|
|
Overview {
|
|
|
|
|
id: overview
|
|
|
|
|
height: 50
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
}
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|