Bump version to 0.2.2
[harbour-pedalo.git] / qml / pages / JourneyInfo.qml
1 import QtQuick 2.0
2 import Sailfish.Silica 1.0
3 import "../components"
4
5 Page {
6     id: journeyInfoPage
7     property string title: "Journey info"
8     property var start: new Date()
9     property int duration: 0
10     property int overtook: -1
11     property int overtakenby: -1
12     property int index: -1
13
14     property real shortlineRatio: 0.6
15     property real shortlineMin: Theme.fontSizeSmall * 10
16     property real shortlineMax: width
17
18     property real widelineRatio: 0.6
19     property real widelineMin: Theme.fontSizeSmall * 10
20     property real widelineMax: width
21
22     onDurationChanged: {
23         var structured = new Date(0, 0, 0, 0, parseInt(duration / 60))
24         durationTime.value = Qt.formatTime(structured, 'hh:mm')
25         endTime.time = new Date(0, 0, 0, start.getHours() + structured.getHours(), start.getMinutes() + structured.getMinutes())
26     }
27
28     onStartChanged: {
29         startDate.value = Qt.formatDate(start, 'd MMM yyyy')
30         startTime.value = Qt.formatTime(start, 'hh:mm')
31
32         var structured = new Date(0, 0, 0, 0, parseInt(duration / 60))
33         endTime.time = new Date(0, 0, 0, start.getHours() + structured.getHours(), start.getMinutes() + structured.getMinutes())
34     }
35
36     // The effective value will be restricted by ApplicationWindow.allowedOrientations
37     allowedOrientations: Orientation.All
38
39     SilicaFlickable {
40         id: journeyEditView
41         anchors.fill: parent
42         contentHeight: journeyEditColumn.implicitHeight + headerItem.height
43
44         VerticalScrollDecorator {}
45
46         PageHeader {
47             id: headerItem
48             title: journeyInfoPage.title
49         }
50
51         Column {
52             id: journeyEditColumn
53             spacing: Theme.paddingLarge
54             width: isPortrait ? parent.width : parent.width * 0.5
55             y: headerItem.height
56
57             InfoRow {
58                 id: startDate
59                 label: "Date"
60                 value: Qt.formatDate(start, 'd MMM yyyy')
61                 width: parent.width
62                 labelTextBold: true
63                 midlineRatio: shortlineRatio
64                 midlineMin: shortlineMin
65                 midlineMax: shortlineMax
66                 horizontalAlignment: Text.AlignRight
67             }
68
69             InfoRow {
70                 id: startTime
71                 label: qsTr("Start time")
72                 value: Qt.formatTime(start, 'hh:mm')
73                 width: parent.width
74                 labelTextBold: true
75                 midlineRatio: shortlineRatio
76                 midlineMin: shortlineMin
77                 midlineMax: shortlineMax
78                 horizontalAlignment: Text.AlignRight
79             }
80
81             InfoRow {
82                 id: endTime
83                 property date time: new Date()
84                 label: qsTr("End time")
85                 value: Qt.formatTime(time, 'hh:mm')
86                 width: parent.width
87                 enabled: false
88                 onTimeChanged: {
89                     value = Qt.formatTime(time, 'hh:mm')
90                 }
91                 labelTextBold: true
92                 midlineRatio: shortlineRatio
93                 midlineMin: shortlineMin
94                 midlineMax: shortlineMax
95                 horizontalAlignment: Text.AlignRight
96             }
97
98             InfoRow {
99                 id: durationTime
100                 label: qsTr("Duration")
101                 value: Qt.formatTime(new Date(0, 0, 0, 0, parseInt(duration / 60)), 'hh:mm')
102                 width: parent.width
103                 enabled: false
104                 labelTextBold: true
105                 midlineRatio: shortlineRatio
106                 midlineMin: shortlineMin
107                 midlineMax: shortlineMax
108                 horizontalAlignment: Text.AlignRight
109             }
110
111             InfoRow {
112                 id: faster
113                 width: parent.width
114                 label: qsTr("Cycles which you overtook")
115                 value: "" + overtook
116                 labelTextBold: true
117                 midlineRatio: widelineRatio
118                 midlineMin: widelineMin
119                 midlineMax: widelineMax
120                 horizontalAlignment: Text.AlignRight
121             }
122
123             InfoRow {
124                 id: slower
125                 width: parent.width
126                 label: qsTr("Cycles which overtook you")
127                 value: "" + overtakenby
128                 labelTextBold: true
129                 midlineRatio: widelineRatio
130                 midlineMin: widelineMin
131                 midlineMax: widelineMax
132                 horizontalAlignment: Text.AlignRight
133             }
134         }
135     }
136 }