Add About page
[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
43
44         VerticalScrollDecorator {}
45
46         Column {
47             id: journeyEditColumn
48             spacing: Theme.paddingLarge
49             width: parent.width
50
51             PageHeader {
52                 title: journeyInfoPage.title
53             }
54
55             InfoRow {
56                 id: startDate
57                 label: "Date"
58                 value: Qt.formatDate(start, 'd MMM yyyy')
59                 width: parent.width
60                 labelTextBold: true
61                 midlineRatio: shortlineRatio
62                 midlineMin: shortlineMin
63                 midlineMax: shortlineMax
64                 horizontalAlignment: Text.AlignRight
65             }
66
67             InfoRow {
68                 id: startTime
69                 label: qsTr("Start time")
70                 value: Qt.formatTime(start, 'hh:mm')
71                 width: parent.width
72                 labelTextBold: true
73                 midlineRatio: shortlineRatio
74                 midlineMin: shortlineMin
75                 midlineMax: shortlineMax
76                 horizontalAlignment: Text.AlignRight
77             }
78
79             InfoRow {
80                 id: endTime
81                 property date time: new Date()
82                 label: qsTr("End time")
83                 value: Qt.formatTime(time, 'hh:mm')
84                 width: parent.width
85                 enabled: false
86                 onTimeChanged: {
87                     value = Qt.formatTime(time, 'hh:mm')
88                 }
89                 labelTextBold: true
90                 midlineRatio: shortlineRatio
91                 midlineMin: shortlineMin
92                 midlineMax: shortlineMax
93                 horizontalAlignment: Text.AlignRight
94             }
95
96             InfoRow {
97                 id: durationTime
98                 label: qsTr("Duration")
99                 value: Qt.formatTime(new Date(0, 0, 0, 0, parseInt(duration / 60)), 'hh:mm')
100                 width: parent.width
101                 enabled: false
102                 labelTextBold: true
103                 midlineRatio: shortlineRatio
104                 midlineMin: shortlineMin
105                 midlineMax: shortlineMax
106                 horizontalAlignment: Text.AlignRight
107             }
108
109             InfoRow {
110                 id: faster
111                 width: parent.width
112                 label: qsTr("Cycles which you overtook")
113                 value: "" + overtook
114                 labelTextBold: true
115                 midlineRatio: widelineRatio
116                 midlineMin: widelineMin
117                 midlineMax: widelineMax
118                 horizontalAlignment: Text.AlignRight
119             }
120
121             InfoRow {
122                 id: slower
123                 width: parent.width
124                 label: qsTr("Cycles which overtook you")
125                 value: "" + overtakenby
126                 labelTextBold: true
127                 midlineRatio: widelineRatio
128                 midlineMin: widelineMin
129                 midlineMax: widelineMax
130                 horizontalAlignment: Text.AlignRight
131             }
132         }
133     }
134 }