6b0377dce1cd6e58fbf537e8603f72fce70b6b99
[harbour-pedalo.git] / qml / pages / JourneyInfo.qml
1 import QtQuick 2.0
2 import Sailfish.Silica 1.0
3
4 Page {
5     id: journeyInfoPage
6     property string title: "Journey info"
7     property var start: new Date()
8     property int duration: 0
9     property int overtook: -1
10     property int overtakenby: -1
11     property int index: -1
12
13     onDurationChanged: {
14         var structured = new Date(0, 0, 0, 0, parseInt(duration / 60))
15         durationTime.value = Qt.formatTime(structured, 'hh:mm')
16         endTime.time = new Date(0, 0, 0, start.getHours() + structured.getHours(), start.getMinutes() + structured.getMinutes())
17     }
18
19     onStartChanged: {
20         startDate.value = Qt.formatDate(start, 'd MMM yyyy')
21         startTime.value = Qt.formatTime(start, 'hh:mm')
22
23         var structured = new Date(0, 0, 0, 0, parseInt(duration / 60))
24         endTime.time = new Date(0, 0, 0, start.getHours() + structured.getHours(), start.getMinutes() + structured.getMinutes())
25     }
26
27     // The effective value will be restricted by ApplicationWindow.allowedOrientations
28     allowedOrientations: Orientation.All
29
30     SilicaFlickable {
31         id: journeyEditView
32         anchors.fill: parent
33         contentHeight: journeyEditColumn.implicitHeight
34
35         VerticalScrollDecorator {}
36
37         Column {
38             id: journeyEditColumn
39             spacing: Theme.paddingMedium
40             width: parent.width
41
42             PageHeader {
43                 title: journeyInfoPage.title
44             }
45
46             ValueButton {
47                 id: startDate
48                 label: "Date"
49                 value: Qt.formatDate(start, 'd MMM yyyy')
50                 width: parent.width
51                 enabled: false
52             }
53
54             ValueButton {
55                 id: startTime
56                 label: qsTr("Start time")
57                 value: Qt.formatTime(start, 'hh:mm')
58                 width: parent.width
59                 enabled: false
60             }
61
62             ValueButton {
63                 id: endTime
64                 property date time: new Date()
65                 label: qsTr("End time")
66                 value: Qt.formatTime(time, 'hh:mm')
67                 width: parent.width
68                 enabled: false
69                 onTimeChanged: {
70                     value = Qt.formatTime(time, 'hh:mm')
71                 }
72             }
73
74             ValueButton {
75                 id: durationTime
76                 label: qsTr("Duration")
77                 value: Qt.formatTime(new Date(0, 0, 0, 0, parseInt(duration / 60)), 'hh:mm')
78                 width: parent.width
79                 enabled: false
80             }
81
82             TextField {
83                 id: faster
84                 width: parent.width
85                 inputMethodHints: Qt.ImhDigitsOnly
86                 label: qsTr("Cycles which you overtook")
87                 placeholderText: label
88                 text: overtook >= 0 ? "" + overtook : ""
89                 horizontalAlignment: TextInput.AlignLeft
90                 EnterKey.iconSource: "image://theme/icon-m-enter-next"
91                 enabled: false
92             }
93
94             TextField {
95                 id: slower
96                 width: parent.width
97                 inputMethodHints: Qt.ImhDigitsOnly
98                 label: qsTr("Cycles which overtook you")
99                 placeholderText: label
100                 text: overtakenby >= 0 ? "" + overtakenby : ""
101                 horizontalAlignment: TextInput.AlignLeft
102                 EnterKey.iconSource: "image://theme/icon-m-enter-next"
103                 enabled: false
104             }
105         }
106     }
107 }