X-Git-Url: https://www.flypig.org.uk/git/?p=harbour-pedalo.git;a=blobdiff_plain;f=qml%2Fpages%2FJourneyList.qml;h=1708d2021a7c0054876ba59384ae83219a09efcf;hp=9d84129e10a2630c0e8e979286aef01f30a1ac48;hb=41bb8de4779e59d272f753bc53033bd467bff811;hpb=0108947ead4cc9e0ff23fee82db2fb1fd7cb2dad diff --git a/qml/pages/JourneyList.qml b/qml/pages/JourneyList.qml index 9d84129..1708d20 100644 --- a/qml/pages/JourneyList.qml +++ b/qml/pages/JourneyList.qml @@ -10,13 +10,14 @@ Page { SilicaListView { id: listView - model: 20 + model: journeymodel anchors.fill: parent header: PageHeader { title: qsTr("Journey list") } - delegate: BackgroundItem { + delegate: ListItem { id: delegate + menu: journeyMenuComponent Row { spacing: Theme.paddingLarge @@ -24,21 +25,41 @@ Page { Label { width: columnwidth / 3.0 - text: qsTr("Item") + " " + index + text: Qt.formatDate(journeymodel.epochToDate(start), "d MMM yyyy") color: delegate.highlighted ? Theme.highlightColor : Theme.primaryColor } Label { width: columnwidth / 3.0 - text: qsTr("1 May 2018") + text: Qt.formatTime(journeymodel.epochToTime(start), "hh:mm") color: delegate.highlighted ? Theme.highlightColor : Theme.primaryColor } Label { width: columnwidth / 3.0 - text: qsTr("20 mins") + text: Qt.formatTime(new Date(0, 0, 0, 0, 0, duration), 'hh:mm') color: delegate.highlighted ? Theme.highlightColor : Theme.primaryColor } } - onClicked: pageStack.push(Qt.resolvedUrl("AddJourney.qml"), {title: "Edit journey"}) + 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 + ContextMenu { + MenuItem { + text: qsTr("Edit") + 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") + onClicked: remove(index) + } + } + } + + function remove(index) { + remorseAction(qsTr("Deleting journey"), function() { + onClicked: journeymodel.deleteJourney(index) + }) + } } VerticalScrollDecorator {} }