2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-10-19 14:28:21 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-10-19 14:28:21 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-10-19 14:28:21 +02: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
|
2016-01-15 14:58:39 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-10-19 14:28:21 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-10-19 14:28:21 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-10-19 14:28:21 +02:00
|
|
|
|
2013-09-03 12:53:48 +02:00
|
|
|
import QtQuick 2.1
|
2011-10-19 14:28:21 +02:00
|
|
|
|
2011-11-16 16:08:05 +01:00
|
|
|
Item {
|
2011-10-19 14:28:21 +02:00
|
|
|
id: selectionRangeDetails
|
|
|
|
|
|
2014-12-05 16:00:03 +01:00
|
|
|
signal recenter
|
|
|
|
|
signal close
|
|
|
|
|
|
2011-10-19 14:28:21 +02:00
|
|
|
property string startTime
|
|
|
|
|
property string endTime
|
|
|
|
|
property string duration
|
|
|
|
|
property bool showDuration
|
2015-08-31 15:53:22 +02:00
|
|
|
property bool hasContents
|
2011-10-19 14:28:21 +02:00
|
|
|
|
2013-12-06 17:45:35 +01:00
|
|
|
width: Math.max(150, col.width + 25)
|
2015-08-31 15:53:22 +02:00
|
|
|
height: hasContents ? col.height + 30 : 0
|
2011-10-19 14:28:21 +02:00
|
|
|
|
2012-10-17 15:51:28 +02:00
|
|
|
// keep inside view
|
|
|
|
|
Connections {
|
2014-12-05 16:00:03 +01:00
|
|
|
target: selectionRangeDetails.parent
|
2012-10-17 15:51:28 +02:00
|
|
|
onWidthChanged: fitInView();
|
2013-10-30 13:49:01 +01:00
|
|
|
onHeightChanged: fitInView();
|
2012-10-17 15:51:28 +02:00
|
|
|
}
|
|
|
|
|
|
2014-12-05 16:00:03 +01:00
|
|
|
function detailedPrintTime( t )
|
|
|
|
|
{
|
|
|
|
|
if (t <= 0) return "0";
|
|
|
|
|
if (t<1000) return t+" ns";
|
|
|
|
|
t = Math.floor(t/1000);
|
|
|
|
|
if (t<1000) return t+" μs";
|
|
|
|
|
if (t<1e6) return (t/1000) + " ms";
|
|
|
|
|
return (t/1e6) + " s";
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-17 15:51:28 +02:00
|
|
|
function fitInView() {
|
|
|
|
|
// don't reposition if it does not fit
|
2014-12-05 16:00:03 +01:00
|
|
|
if (parent.width < width || parent.height < height)
|
2012-10-17 15:51:28 +02:00
|
|
|
return;
|
|
|
|
|
|
2014-12-05 16:00:03 +01:00
|
|
|
if (x + width > parent.width)
|
|
|
|
|
x = parent.width - width;
|
2012-10-17 15:51:28 +02:00
|
|
|
if (x < 0)
|
|
|
|
|
x = 0;
|
2014-12-05 16:00:03 +01:00
|
|
|
if (y + height > parent.height)
|
|
|
|
|
y = parent.height - height;
|
2013-11-08 18:32:02 +01:00
|
|
|
if (y < 0)
|
|
|
|
|
y = 0;
|
2012-10-17 15:51:28 +02:00
|
|
|
}
|
|
|
|
|
|
2011-11-16 16:08:05 +01:00
|
|
|
// title bar
|
|
|
|
|
Rectangle {
|
|
|
|
|
width: parent.width
|
|
|
|
|
height: 20
|
|
|
|
|
color: "#4a64b8"
|
|
|
|
|
border.width: 1
|
|
|
|
|
border.color: "#a0a0a0"
|
|
|
|
|
}
|
|
|
|
|
Item {
|
|
|
|
|
width: parent.width+1
|
|
|
|
|
height: 11
|
|
|
|
|
y: 10
|
|
|
|
|
clip: true
|
|
|
|
|
Rectangle {
|
|
|
|
|
width: parent.width-1
|
|
|
|
|
height: 15
|
|
|
|
|
y: -5
|
|
|
|
|
color: "#4a64b8"
|
|
|
|
|
border.width: 1
|
|
|
|
|
border.color: "#a0a0a0"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-19 14:28:21 +02:00
|
|
|
//title
|
2015-09-11 17:44:12 +02:00
|
|
|
TimelineText {
|
2011-10-19 14:28:21 +02:00
|
|
|
id: typeTitle
|
2011-11-16 16:08:05 +01:00
|
|
|
text: " "+qsTr("Selection")
|
2011-10-19 14:28:21 +02:00
|
|
|
font.bold: true
|
2011-11-16 16:08:05 +01:00
|
|
|
height: 18
|
|
|
|
|
y: 2
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
width: parent.width
|
|
|
|
|
color: "white"
|
2011-10-19 14:28:21 +02:00
|
|
|
}
|
|
|
|
|
|
2011-11-16 16:08:05 +01:00
|
|
|
// Details area
|
|
|
|
|
Rectangle {
|
|
|
|
|
color: "white"
|
|
|
|
|
width: parent.width
|
|
|
|
|
height: col.height + 10
|
|
|
|
|
y: 20
|
|
|
|
|
border.width: 1
|
|
|
|
|
border.color: "#a0a0a0"
|
2013-12-06 17:45:35 +01:00
|
|
|
Grid {
|
2011-11-16 16:08:05 +01:00
|
|
|
id: col
|
|
|
|
|
x: 10
|
|
|
|
|
y: 5
|
2013-12-06 17:45:35 +01:00
|
|
|
spacing: 5
|
|
|
|
|
columns: 2
|
|
|
|
|
|
|
|
|
|
Repeater {
|
2015-08-31 13:43:38 +02:00
|
|
|
id: details
|
|
|
|
|
property var contents: [
|
2014-07-07 14:03:33 +02:00
|
|
|
qsTr("Start") + ":",
|
2014-12-05 16:00:03 +01:00
|
|
|
detailedPrintTime(startTime),
|
2015-08-31 13:43:38 +02:00
|
|
|
(qsTr("End") + ":"),
|
|
|
|
|
detailedPrintTime(endTime),
|
|
|
|
|
(qsTr("Duration") + ":"),
|
|
|
|
|
detailedPrintTime(duration)
|
2013-12-06 17:45:35 +01:00
|
|
|
]
|
2015-08-31 13:43:38 +02:00
|
|
|
|
|
|
|
|
model: showDuration ? 6 : 2
|
2013-12-06 17:45:35 +01:00
|
|
|
Detail {
|
2014-07-07 14:03:33 +02:00
|
|
|
isLabel: index % 2 === 0
|
2015-08-31 13:43:38 +02:00
|
|
|
text: details.contents[index]
|
2013-12-06 17:45:35 +01:00
|
|
|
}
|
2011-11-16 16:08:05 +01:00
|
|
|
}
|
2011-10-19 14:28:21 +02:00
|
|
|
}
|
2011-11-16 16:08:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MouseArea {
|
2013-12-17 11:46:50 +01:00
|
|
|
anchors.fill: parent
|
2011-11-16 16:08:05 +01:00
|
|
|
drag.target: parent
|
2012-10-17 15:51:28 +02:00
|
|
|
drag.minimumX: 0
|
2014-12-05 16:00:03 +01:00
|
|
|
drag.maximumX: selectionRangeDetails.parent.width - width
|
2013-11-08 18:32:02 +01:00
|
|
|
drag.minimumY: 0
|
2014-12-05 16:00:03 +01:00
|
|
|
drag.maximumY: selectionRangeDetails.parent.height - height
|
|
|
|
|
onClicked: selectionRangeDetails.recenter()
|
2011-10-19 14:28:21 +02:00
|
|
|
}
|
|
|
|
|
|
2015-09-11 17:44:12 +02:00
|
|
|
TimelineText {
|
2011-10-19 14:28:21 +02:00
|
|
|
id: closeIcon
|
2011-11-16 16:08:05 +01:00
|
|
|
x: selectionRangeDetails.width - 14
|
|
|
|
|
y: 4
|
2011-10-19 14:28:21 +02:00
|
|
|
text:"X"
|
2011-11-16 16:08:05 +01:00
|
|
|
color: "white"
|
2011-10-19 14:28:21 +02:00
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
anchors.leftMargin: -8
|
2014-12-05 16:00:03 +01:00
|
|
|
onClicked: selectionRangeDetails.close()
|
2011-10-19 14:28:21 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|