Commit 35fb4ccf authored by Nicolas Fella's avatar Nicolas Fella

Refactor LocationQueryPage to take a title and callback

parent e7bbf134
......@@ -29,15 +29,7 @@ Kirigami.Page
property string type
property bool showCached: true
title: {
if (type == "start") {
return i18n("Search for start location")
}
if (type == "destination") {
return i18n("Search for destination location")
}
return "deadbeef"
}
property var callback
header: TextField {
id: queryTextField
......@@ -58,12 +50,7 @@ Kirigami.Page
reserveSpaceForIcon: false
onClicked: {
_locationCache.addCachedLocation(modelData)
if (type == "start") {
_queryController.start = modelData
} else if (type == "destination") {
_queryController.destination = modelData
}
callback(modelData)
pageStack.pop()
}
}
......@@ -83,12 +70,7 @@ Kirigami.Page
reserveSpaceForIcon: false
onClicked: {
_locationCache.addCachedLocation(object)
if (type == "start") {
_queryController.start = object
} else if (type == "destination") {
_queryController.destination = object
}
callback(object)
pageStack.pop()
}
}
......
......@@ -36,6 +36,16 @@ Kirigami.Page
onTriggered: pageStack.push(Qt.resolvedUrl("ConnectionsPage.qml"))
}
function startPicked(data) {
console.log("Picked start: " + data.name)
_queryController.start = data
}
function destinationPicked(data) {
console.log("Picked destination" + data.name)
_queryController.destination = data
}
ColumnLayout {
width: parent.width
......@@ -46,15 +56,16 @@ Kirigami.Page
Button {
Layout.fillWidth: true
text: _queryController.start.name ? _queryController.start.name : i18n("Pick start")
onClicked: pageStack.push(Qt.resolvedUrl("LocationQueryPage.qml"), {type: "start"})
onClicked: pageStack.push(Qt.resolvedUrl("LocationQueryPage.qml"), {title: i18n("Search for start location"), callback: startPicked})
}
Label {
text: "To:"
}
Button {
Layout.fillWidth: true
text: _queryController.destination.name ? _queryController.destination.name : i18n("Pick destination")
onClicked: pageStack.push(Qt.resolvedUrl("LocationQueryPage.qml"), {type: "destination"})
onClicked: pageStack.push(Qt.resolvedUrl("LocationQueryPage.qml"), {title: i18n("Search for destination location"), callback: destinationPicked})
}
Label {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment