Rename AddJourney to JourneyEdit
authorDavid Llewellyn-Jones <david@flypig.co.uk>
Sat, 14 Jul 2018 19:13:44 +0000 (20:13 +0100)
committerDavid Llewellyn-Jones <david@flypig.co.uk>
Sat, 14 Jul 2018 19:13:44 +0000 (20:13 +0100)
This fits better with the overall naming scheme and makes sense
given the dialog is used more often for editing than for adding.

harbour-pedalo.pro
qml/pages/AddJourney.qml [deleted file]
qml/pages/JourneyEdit.qml [new file with mode: 0644]
qml/pages/JourneyList.qml
qml/pages/MainPage.qml
translations/harbour-pedalo-de.ts
translations/harbour-pedalo.ts

index 1ec2ced..647d3bb 100644 (file)
@@ -41,12 +41,12 @@ DISTFILES += qml/harbour-pedalo.qml \
     translations/*.ts \
     harbour-pedalo.desktop \
     qml/pages/MainPage.qml \
     translations/*.ts \
     harbour-pedalo.desktop \
     qml/pages/MainPage.qml \
-    qml/pages/AddJourney.qml \
     qml/pages/Stats.qml \
     qml/pages/JourneyList.qml \
     qml/pages/About.qml \
     qml/pages/DurationEditDialog.qml \
     qml/pages/Stats.qml \
     qml/pages/JourneyList.qml \
     qml/pages/About.qml \
     qml/pages/DurationEditDialog.qml \
-    qml/components/InfoRow.qml
+    qml/components/InfoRow.qml \
+    qml/pages/JourneyEdit.qml
 
 SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172
 
 
 SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172
 
diff --git a/qml/pages/AddJourney.qml b/qml/pages/AddJourney.qml
deleted file mode 100644 (file)
index a9124ae..0000000
+++ /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)
-        }
-    }
-}
diff --git a/qml/pages/JourneyEdit.qml b/qml/pages/JourneyEdit.qml
new file mode 100644 (file)
index 0000000..1f61b39
--- /dev/null
@@ -0,0 +1,141 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Dialog {
+    id: journeyEditDialog
+    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: journeyEditView
+        anchors.fill: parent
+        contentHeight: journeyEditColumn.implicitHeight
+
+        VerticalScrollDecorator {}
+
+        Column {
+            id: journeyEditColumn
+            spacing: Theme.paddingMedium
+            width: parent.width
+
+            DialogHeader {
+                title: journeyEditDialog.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: journeyEditDialog.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)
+        }
+    }
+}
index 8831f40..8ecc9b8 100644 (file)
@@ -39,14 +39,14 @@ Page {
                     color: delegate.highlighted ? Theme.highlightColor : Theme.primaryColor
                 }
             }
                     color: delegate.highlighted ? Theme.highlightColor : Theme.primaryColor
                 }
             }
-            onClicked: pageStack.push(Qt.resolvedUrl("AddJourney.qml"), {title: "Edit journey", index: index, start: journeymodel.epochToDateTime(start), duration: duration, overtook: overtook, overtakenby: overtakenby})
+            onClicked: pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"), {title: "Edit journey", index: index, start: journeymodel.epochToDateTime(start), duration: duration, overtook: overtook, overtakenby: overtakenby})
 
             Component {
                 id: journeyMenuComponent
                 ContextMenu {
                     MenuItem {
                         text: qsTr("Edit")
 
             Component {
                 id: journeyMenuComponent
                 ContextMenu {
                     MenuItem {
                         text: qsTr("Edit")
-                        onClicked: pageStack.push(Qt.resolvedUrl("AddJourney.qml"), {title: "Edit journey", index: index, start: journeymodel.epochToDateTime(start), duration: duration, overtook: overtook, overtakenby: overtakenby})
+                        onClicked: pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"), {title: "Edit journey", index: index, start: journeymodel.epochToDateTime(start), duration: duration, overtook: overtook, overtakenby: overtakenby})
                     }
                     MenuItem {
                         text: qsTr("Delete")
                     }
                     MenuItem {
                         text: qsTr("Delete")
index 03d86a2..0de4dc4 100644 (file)
@@ -42,7 +42,7 @@ Page {
                 text: currentStatus.cycling ? qsTr("Finish") : qsTr("Start a journey")
                 onClicked: {
                     if (currentStatus.cycling) {
                 text: currentStatus.cycling ? qsTr("Finish") : qsTr("Start a journey")
                 onClicked: {
                     if (currentStatus.cycling) {
-                        var dialog = pageStack.push(Qt.resolvedUrl("AddJourney.qml"), {title: "Finish journey", start: journeymodel.epochToDateTime(currentStatus.startTime), duration: currentStatus.getDuration()})
+                        var dialog = pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"), {title: "Finish journey", start: journeymodel.epochToDateTime(currentStatus.startTime), duration: currentStatus.getDuration()})
 
                         dialog.accepted.connect(function() {
                             currentStatus.cycling = false
 
                         dialog.accepted.connect(function() {
                             currentStatus.cycling = false
@@ -61,7 +61,7 @@ Page {
             Button {
                 anchors.horizontalCenter: parent.horizontalCenter
                 text: qsTr("Enter journey")
             Button {
                 anchors.horizontalCenter: parent.horizontalCenter
                 text: qsTr("Enter journey")
-                onClicked: pageStack.push(Qt.resolvedUrl("AddJourney.qml"))
+                onClicked: pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"))
             }
 
             SectionHeader {
             }
 
             SectionHeader {
index bb23457..3ea663f 100644 (file)
     </message>
 </context>
 <context>
     </message>
 </context>
 <context>
-    <name>AddJourney</name>
+    <name>CoverPage</name>
     <message>
     <message>
-        <source>Start time</source>
-        <translation type="unfinished"></translation>
+        <source>My Cover</source>
+        <translation>Mein Cover</translation>
     </message>
     </message>
+</context>
+<context>
+    <name>DurationEditDialog</name>
     <message>
     <message>
-        <source>End time</source>
+        <source>LTR</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <source>Duration</source>
+        <source>h</source>
+        <extracomment>&quot;Hour abbrevation. Should be short form if possible.&quot;</extracomment>
         <translation type="unfinished"></translation>
     </message>
     <message>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <source>Cycles which you overtook</source>
+        <source>min</source>
+        <extracomment>&quot;Minute abbrevation. Should be short form if possible.&quot;</extracomment>
         <translation type="unfinished"></translation>
     </message>
         <translation type="unfinished"></translation>
     </message>
+</context>
+<context>
+    <name>JourneyEdit</name>
     <message>
     <message>
-        <source>Cycles which overtook you</source>
+        <source>Start time</source>
         <translation type="unfinished"></translation>
     </message>
         <translation type="unfinished"></translation>
     </message>
-</context>
-<context>
-    <name>CoverPage</name>
     <message>
     <message>
-        <source>My Cover</source>
-        <translation>Mein Cover</translation>
+        <source>End time</source>
+        <translation type="unfinished"></translation>
     </message>
     </message>
-</context>
-<context>
-    <name>DurationEditDialog</name>
     <message>
     <message>
-        <source>LTR</source>
+        <source>Duration</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <source>h</source>
-        <extracomment>&quot;Hour abbrevation. Should be short form if possible.&quot;</extracomment>
+        <source>Cycles which you overtook</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <source>min</source>
-        <extracomment>&quot;Minute abbrevation. Should be short form if possible.&quot;</extracomment>
+        <source>Cycles which overtook you</source>
         <translation type="unfinished"></translation>
     </message>
 </context>
         <translation type="unfinished"></translation>
     </message>
 </context>
index e580051..42cc67b 100644 (file)
     </message>
 </context>
 <context>
     </message>
 </context>
 <context>
-    <name>AddJourney</name>
+    <name>CoverPage</name>
     <message>
     <message>
-        <source>Start time</source>
+        <source>My Cover</source>
         <translation type="unfinished"></translation>
     </message>
         <translation type="unfinished"></translation>
     </message>
+</context>
+<context>
+    <name>DurationEditDialog</name>
     <message>
     <message>
-        <source>End time</source>
+        <source>LTR</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <source>Duration</source>
+        <source>h</source>
+        <extracomment>&quot;Hour abbrevation. Should be short form if possible.&quot;</extracomment>
         <translation type="unfinished"></translation>
     </message>
     <message>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <source>Cycles which you overtook</source>
+        <source>min</source>
+        <extracomment>&quot;Minute abbrevation. Should be short form if possible.&quot;</extracomment>
         <translation type="unfinished"></translation>
     </message>
         <translation type="unfinished"></translation>
     </message>
+</context>
+<context>
+    <name>JourneyEdit</name>
     <message>
     <message>
-        <source>Cycles which overtook you</source>
+        <source>Start time</source>
         <translation type="unfinished"></translation>
     </message>
         <translation type="unfinished"></translation>
     </message>
-</context>
-<context>
-    <name>CoverPage</name>
     <message>
     <message>
-        <source>My Cover</source>
+        <source>End time</source>
         <translation type="unfinished"></translation>
     </message>
         <translation type="unfinished"></translation>
     </message>
-</context>
-<context>
-    <name>DurationEditDialog</name>
     <message>
     <message>
-        <source>LTR</source>
+        <source>Duration</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <source>h</source>
-        <extracomment>&quot;Hour abbrevation. Should be short form if possible.&quot;</extracomment>
+        <source>Cycles which you overtook</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <source>min</source>
-        <extracomment>&quot;Minute abbrevation. Should be short form if possible.&quot;</extracomment>
+        <source>Cycles which overtook you</source>
         <translation type="unfinished"></translation>
     </message>
 </context>
         <translation type="unfinished"></translation>
     </message>
 </context>