2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-07-06 15:48:52 +00:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-07-06 15:48:52 +00:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-07-06 15:48:52 +00: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-07-06 15:48:52 +00: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-07-06 15:48:52 +00:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-07-06 15:48:52 +00:00
|
|
|
|
2013-09-03 12:53:48 +02:00
|
|
|
import QtQuick 2.1
|
2016-12-13 11:44:49 +01:00
|
|
|
import TimelineTheme 1.0
|
2016-12-19 11:29:40 +01:00
|
|
|
import TimelineTimeFormatter 1.0
|
2011-06-20 18:11:17 +02:00
|
|
|
|
2014-11-07 18:13:31 +01:00
|
|
|
Item {
|
2011-06-20 18:11:17 +02:00
|
|
|
id: timeDisplay
|
|
|
|
|
|
2014-12-10 11:21:53 +01:00
|
|
|
property double windowStart
|
|
|
|
|
property double rangeDuration
|
|
|
|
|
|
|
|
|
|
property int textMargin: 5
|
|
|
|
|
property int labelsHeight: 24
|
|
|
|
|
property int fontSize: 8
|
|
|
|
|
property int initialBlockLength: 120
|
2014-11-07 18:13:31 +01:00
|
|
|
property double spacing: width / rangeDuration
|
2011-06-20 18:11:17 +02:00
|
|
|
|
2014-11-07 18:13:31 +01:00
|
|
|
property double timePerBlock: Math.pow(2, Math.floor(Math.log(initialBlockLength / spacing) /
|
|
|
|
|
Math.LN2))
|
2011-11-16 16:08:05 +01:00
|
|
|
|
2014-12-10 11:21:53 +01:00
|
|
|
property double alignedWindowStart: Math.round(windowStart - (windowStart % timePerBlock))
|
2014-11-07 18:13:31 +01:00
|
|
|
property double pixelsPerBlock: timeDisplay.timePerBlock * timeDisplay.spacing
|
|
|
|
|
property double pixelsPerSection: pixelsPerBlock / 5
|
2011-06-20 18:11:17 +02:00
|
|
|
|
2014-11-07 18:13:31 +01:00
|
|
|
property int contentX
|
2014-12-10 11:21:53 +01:00
|
|
|
property int offsetX: contentX + Math.round((windowStart % timePerBlock) * spacing)
|
2014-03-25 17:10:25 +01:00
|
|
|
|
2016-07-28 12:30:32 +02:00
|
|
|
Rectangle {
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
height: timeDisplay.labelsHeight
|
2016-12-13 11:44:49 +01:00
|
|
|
color: Theme.color(Theme.PanelStatusBarBackgroundColor)
|
2016-07-28 12:30:32 +02:00
|
|
|
}
|
|
|
|
|
|
2014-11-07 18:13:31 +01:00
|
|
|
Item {
|
2016-10-31 13:13:03 +01:00
|
|
|
x: -(timeDisplay.offsetX % timeDisplay.pixelsPerBlock)
|
2014-11-07 18:13:31 +01:00
|
|
|
y: 0
|
2018-11-14 14:34:36 +01:00
|
|
|
id: timeDisplayArea
|
2014-11-07 18:13:31 +01:00
|
|
|
|
|
|
|
|
property int firstBlock: timeDisplay.offsetX / timeDisplay.pixelsPerBlock
|
2017-12-18 21:18:38 +01:00
|
|
|
property int offset: repeater.model > 0 ? repeater.model - (firstBlock % repeater.model) : 0;
|
2014-11-07 18:13:31 +01:00
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
|
id: repeater
|
2018-09-25 09:44:03 +02:00
|
|
|
model: Math.max(0, Math.floor(timeDisplay.width / timeDisplay.initialBlockLength * 2
|
|
|
|
|
+ 2))
|
2014-11-07 18:13:31 +01:00
|
|
|
|
|
|
|
|
Item {
|
2018-11-14 14:34:36 +01:00
|
|
|
id: timeDisplayItem
|
2014-11-07 18:13:31 +01:00
|
|
|
|
|
|
|
|
// Changing the text in text nodes is expensive. We minimize the number of changes
|
|
|
|
|
// by rotating the nodes during scrolling.
|
2018-11-14 14:34:36 +01:00
|
|
|
property int stableIndex: (index + timeDisplayArea.offset) % repeater.model
|
2016-10-31 13:13:03 +01:00
|
|
|
|
2014-11-07 18:13:31 +01:00
|
|
|
height: timeDisplay.height
|
|
|
|
|
y: 0
|
|
|
|
|
x: width * stableIndex
|
|
|
|
|
width: timeDisplay.pixelsPerBlock
|
|
|
|
|
|
2018-11-14 14:34:36 +01:00
|
|
|
property double blockStartTime: (timeDisplayArea.firstBlock + stableIndex)
|
2016-10-31 13:13:03 +01:00
|
|
|
* timeDisplay.timePerBlock
|
|
|
|
|
+ timeDisplay.alignedWindowStart
|
2014-11-07 18:13:31 +01:00
|
|
|
|
2016-07-28 12:30:32 +02:00
|
|
|
TimelineText {
|
2014-11-07 18:13:31 +01:00
|
|
|
id: timeLabel
|
|
|
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
height: timeDisplay.labelsHeight
|
|
|
|
|
|
2016-07-28 12:30:32 +02:00
|
|
|
font.pixelSize: timeDisplay.fontSize
|
2017-01-02 19:12:32 +01:00
|
|
|
anchors.rightMargin: timeDisplay.textMargin
|
2016-07-28 12:30:32 +02:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
2018-11-14 14:34:36 +01:00
|
|
|
text: TimeFormatter.format(timeDisplayItem.blockStartTime,
|
|
|
|
|
timeDisplay.rangeDuration)
|
2016-07-28 12:30:32 +02:00
|
|
|
visible: width > 0
|
2016-12-13 11:44:49 +01:00
|
|
|
color: Theme.color(Theme.PanelTextColorLight)
|
2017-01-02 19:12:32 +01:00
|
|
|
elide: Text.ElideLeft
|
2014-11-07 18:13:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Row {
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.top: timeLabel.bottom
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
|
model: 4
|
|
|
|
|
Item {
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
width: timeDisplay.pixelsPerSection
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
2018-11-14 14:34:36 +01:00
|
|
|
visible: timeDisplayItem.stableIndex !== 0
|
|
|
|
|
|| (-timeDisplayArea.x < parent.x + x)
|
2016-12-13 11:44:49 +01:00
|
|
|
color: Theme.color(Theme.Timeline_DividerColor)
|
2014-11-07 18:13:31 +01:00
|
|
|
width: 1
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
2016-12-13 11:44:49 +01:00
|
|
|
color: Theme.color(Theme.Timeline_DividerColor)
|
2014-11-07 18:13:31 +01:00
|
|
|
width: 1
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-20 18:11:17 +02:00
|
|
|
}
|