X-Git-Url: https://www.flypig.org.uk/git/?p=harbour-pedalo.git;a=blobdiff_plain;f=qml%2Fpages%2FAddJourney.qml;fp=qml%2Fpages%2FAddJourney.qml;h=0000000000000000000000000000000000000000;hp=a9124ae1acad638c6c98e203acf3135dbfa8e150;hb=cc1952786f991bf5d584bbbffb554b0c40cec401;hpb=4248fa25458b2d282d4e0ed4447e4bc7570046eb diff --git a/qml/pages/AddJourney.qml b/qml/pages/AddJourney.qml deleted file mode 100644 index a9124ae..0000000 --- a/qml/pages/AddJourney.qml +++ /dev/null @@ -1,141 +0,0 @@ -import QtQuick 2.0 -import Sailfish.Silica 1.0 - -Dialog { - id: addJourneyDialog - canAccept: true - property string title: "Add journey" - property var start: new Date() - property int duration: 0 - property int overtook: -1 - property int overtakenby: -1 - property int index: -1 - - onDurationChanged: { - var structured = new Date(0, 0, 0, 0, parseInt(duration / 60)) - durationTime.value = Qt.formatTime(structured, 'hh:mm') - endTime.time = new Date(0, 0, 0, start.getHours() + structured.getHours(), start.getMinutes() + structured.getMinutes()) - } - - onStartChanged: { - startDate.value = Qt.formatDate(start, 'd MMM yyyy') - startTime.value = Qt.formatTime(start, 'hh:mm') - - var structured = new Date(0, 0, 0, 0, parseInt(duration / 60)) - endTime.time = new Date(0, 0, 0, start.getHours() + structured.getHours(), start.getMinutes() + structured.getMinutes()) - } - - // The effective value will be restricted by ApplicationWindow.allowedOrientations - allowedOrientations: Orientation.All - - SilicaFlickable { - id: addJourneyView - anchors.fill: parent - contentHeight: addJourneyColumn.implicitHeight - - VerticalScrollDecorator {} - - Column { - id: addJourneyColumn - spacing: Theme.paddingMedium - width: parent.width - - DialogHeader { - title: addJourneyDialog.title - } - - ValueButton { - id: startDate - label: "Date" - value: Qt.formatDate(start, 'd MMM yyyy') - width: parent.width - onClicked: { - var dialog = pageStack.push("Sailfish.Silica.DatePickerDialog", { date: start }) - dialog.accepted.connect(function() { - start = new Date(dialog.year, dialog.month - 1, dialog.day, start.getHours(), start.getMinutes()) - }) - } - } - - ValueButton { - id: startTime - label: qsTr("Start time") - value: Qt.formatTime(start, 'hh:mm') - width: parent.width - onClicked: { - var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", { hour: start.getHours(), minute: start.getMinutes()}) - dialog.accepted.connect(function() { - start = new Date(start.getFullYear(), start.getMonth(), start.getDate(), dialog.hour, dialog.minute) - }) - } - } - - ValueButton { - id: endTime - property date time: new Date() - label: qsTr("End time") - value: Qt.formatTime(time, 'hh:mm') - width: parent.width - onClicked: { - var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", { hour: time.getHours(), minute: time.getMinutes()}) - dialog.accepted.connect(function() { - // We have to hack around the fact that % in Javascript is 'remainder' and not 'mod' (hence will happpily return negative numbers) - duration = ((((((dialog.hour - start.getHours()) * 60) + (dialog.minute - start.getMinutes())) * 60) % 86400) + 86400) % 86400 - // Updating the duration will automatically trigger the end time to be udpated - }) - } - onTimeChanged: { - value = Qt.formatTime(time, 'hh:mm') - } - } - - ValueButton { - id: durationTime - label: qsTr("Duration") - value: Qt.formatTime(new Date(0, 0, 0, 0, parseInt(duration / 60)), 'hh:mm') - width: parent.width - onClicked: { - var dialog = pageStack.push("DurationEditDialog.qml", { hour: parseInt(duration / (60 * 60)), minute: parseInt(duration / 60) % 60}) - dialog.accepted.connect(function() { - duration = ((dialog.hour * 60) + dialog.minute) * 60 - }) - } - } - - TextField { - id: faster - width: parent.width - inputMethodHints: Qt.ImhDigitsOnly - label: qsTr("Cycles which you overtook") - placeholderText: label - text: overtook >= 0 ? "" + overtook : "" - horizontalAlignment: TextInput.AlignLeft - EnterKey.iconSource: "image://theme/icon-m-enter-next" - EnterKey.onClicked: slower.focus = true - } - - TextField { - id: slower - width: parent.width - inputMethodHints: Qt.ImhDigitsOnly - label: qsTr("Cycles which overtook you") - placeholderText: label - text: overtakenby >= 0 ? "" + overtakenby : "" - horizontalAlignment: TextInput.AlignLeft - EnterKey.iconSource: "image://theme/icon-m-enter-next" - EnterKey.onClicked: addJourneyDialog.accept() - } - } - } - - onAccepted: { - var overtook = parseInt(faster.text) - var overtakenby = parseInt(slower.text) - if (index < 0) { - journeymodel.addJourney(start, duration, overtook, overtakenby) - } - else { - journeymodel.editJourney(index, start, duration, overtook, overtakenby) - } - } -}