2 import Sailfish.Silica 1.0
7 property string title: "Add journey"
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
15 var structured = new Date(0, 0, 0, 0, parseInt(duration / 60))
16 durationTime.value = Qt.formatTime(structured, 'hh:mm')
17 endTime.time = new Date(0, 0, 0, start.getHours() + structured.getHours(), start.getMinutes() + structured.getMinutes())
21 startDate.value = Qt.formatDate(start, 'd MMM yyyy')
22 startTime.value = Qt.formatTime(start, 'hh:mm')
24 var structured = new Date(0, 0, 0, 0, parseInt(duration / 60))
25 endTime.time = new Date(0, 0, 0, start.getHours() + structured.getHours(), start.getMinutes() + structured.getMinutes())
28 // The effective value will be restricted by ApplicationWindow.allowedOrientations
29 allowedOrientations: Orientation.All
34 contentHeight: addJourneyColumn.implicitHeight
36 VerticalScrollDecorator {}
40 spacing: Theme.paddingMedium
44 title: addJourneyDialog.title
50 value: Qt.formatDate(start, 'd MMM yyyy')
53 var dialog = pageStack.push("Sailfish.Silica.DatePickerDialog", { date: start })
54 dialog.accepted.connect(function() {
55 start = new Date(dialog.year, dialog.month - 1, dialog.day, start.getHours(), start.getMinutes())
62 label: qsTr("Start time")
63 value: Qt.formatTime(start, 'hh:mm')
66 var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", { hour: start.getHours(), minute: start.getMinutes()})
67 dialog.accepted.connect(function() {
68 start = new Date(start.getFullYear(), start.getMonth(), start.getDate(), dialog.hour, dialog.minute)
75 property date time: new Date()
76 label: qsTr("End time")
77 value: Qt.formatTime(time, 'hh:mm')
80 var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", { hour: time.getHours(), minute: time.getMinutes()})
81 dialog.accepted.connect(function() {
82 time = new Date(0, 0, 0, dialog.hour, dialog.minute)
83 duration = ((endTime.time.getHours() - start.getHours()) * 60) + (endTime.time.getMinutes() - start.getMinutes()) * 60
87 value = Qt.formatTime(time, 'hh:mm')
93 label: qsTr("Duration")
94 value: Qt.formatTime(new Date(0, 0, 0, 0, parseInt(duration / 60)), 'hh:mm')
97 var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", { hour: parseInt(duration / (60 * 60)), minute: parseInt(duration / 60) % 60})
98 dialog.accepted.connect(function() {
99 duration = ((dialog.hour * 60) + dialog.minute) * 60
107 inputMethodHints: Qt.ImhDigitsOnly
108 label: qsTr("Cycles which you overtook")
109 placeholderText: label
110 text: overtook >= 0 ? "" + overtook : ""
111 horizontalAlignment: TextInput.AlignLeft
112 EnterKey.iconSource: "image://theme/icon-m-enter-next"
113 EnterKey.onClicked: slower.focus = true
119 inputMethodHints: Qt.ImhDigitsOnly
120 label: qsTr("Cycles which overtook you")
121 placeholderText: label
122 text: overtakenby >= 0 ? "" + overtakenby : ""
123 horizontalAlignment: TextInput.AlignLeft
124 EnterKey.iconSource: "image://theme/icon-m-enter-next"
125 EnterKey.onClicked: addJourneyDialog.accept()
131 var overtook = parseInt(faster.text)
132 var overtakenby = parseInt(slower.text)
134 journeymodel.addJourney(start, duration, overtook, overtakenby)
137 journeymodel.editJourney(index, start, duration, overtook, overtakenby)