Add journey info page
authorDavid Llewellyn-Jones <david@flypig.co.uk>
Sat, 14 Jul 2018 19:40:29 +0000 (20:40 +0100)
committerDavid Llewellyn-Jones <david@flypig.co.uk>
Sat, 14 Jul 2018 19:40:29 +0000 (20:40 +0100)
When items are clicked in the journey list, default behaviour is
now to show an info page that can't be edited.

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

index 647d3bb..e50d930 100644 (file)
@@ -46,7 +46,8 @@ DISTFILES += qml/harbour-pedalo.qml \
     qml/pages/About.qml \
     qml/pages/DurationEditDialog.qml \
     qml/components/InfoRow.qml \
-    qml/pages/JourneyEdit.qml
+    qml/pages/JourneyEdit.qml \
+    qml/pages/JourneyInfo.qml
 
 SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172
 
diff --git a/qml/pages/JourneyInfo.qml b/qml/pages/JourneyInfo.qml
new file mode 100644 (file)
index 0000000..6b0377d
--- /dev/null
@@ -0,0 +1,107 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Page {
+    id: journeyInfoPage
+    property string title: "Journey info"
+    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
+
+            PageHeader {
+                title: journeyInfoPage.title
+            }
+
+            ValueButton {
+                id: startDate
+                label: "Date"
+                value: Qt.formatDate(start, 'd MMM yyyy')
+                width: parent.width
+                enabled: false
+            }
+
+            ValueButton {
+                id: startTime
+                label: qsTr("Start time")
+                value: Qt.formatTime(start, 'hh:mm')
+                width: parent.width
+                enabled: false
+            }
+
+            ValueButton {
+                id: endTime
+                property date time: new Date()
+                label: qsTr("End time")
+                value: Qt.formatTime(time, 'hh:mm')
+                width: parent.width
+                enabled: false
+                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
+                enabled: false
+            }
+
+            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"
+                enabled: false
+            }
+
+            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"
+                enabled: false
+            }
+        }
+    }
+}
index 8ecc9b8..1708d20 100644 (file)
@@ -39,7 +39,7 @@ Page {
                     color: delegate.highlighted ? Theme.highlightColor : Theme.primaryColor
                 }
             }
-            onClicked: pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"), {title: "Edit journey", index: index, start: journeymodel.epochToDateTime(start), duration: duration, overtook: overtook, overtakenby: overtakenby})
+            onClicked: pageStack.push(Qt.resolvedUrl("JourneyInfo.qml"), {title: "Journey info", index: index, start: journeymodel.epochToDateTime(start), duration: duration, overtook: overtook, overtakenby: overtakenby})
 
             Component {
                 id: journeyMenuComponent
index 3ea663f..9bff26f 100644 (file)
     </message>
 </context>
 <context>
+    <name>JourneyInfo</name>
+    <message>
+        <source>Start time</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>End time</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Duration</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Cycles which you overtook</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Cycles which overtook you</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
     <name>JourneyList</name>
     <message>
         <source>Journey list</source>
index 42cc67b..79a127d 100644 (file)
     </message>
 </context>
 <context>
+    <name>JourneyInfo</name>
+    <message>
+        <source>Start time</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>End time</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Duration</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Cycles which you overtook</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Cycles which overtook you</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
     <name>JourneyList</name>
     <message>
         <source>Journey list</source>