Commit 410335fe authored by Volker Krause's avatar Volker Krause

Allow manual journey queries in the journey query example

parent 9a4c3cfe
...@@ -46,7 +46,7 @@ public: ...@@ -46,7 +46,7 @@ public:
ptMgr.setNetworkAccessManager(&nam); ptMgr.setNetworkAccessManager(&nam);
} }
Q_INVOKABLE void findJourney(double fromLat, double fromLon, double toLat, double toLon) Q_INVOKABLE void findJourney(const QString &fromName, double fromLat, double fromLon, const QString &toName, double toLat, double toLon)
{ {
engine->rootContext()->setContextProperty(QStringLiteral("_journeys"), QVariantList()); engine->rootContext()->setContextProperty(QStringLiteral("_journeys"), QVariantList());
m_loading = true; m_loading = true;
...@@ -55,8 +55,10 @@ public: ...@@ -55,8 +55,10 @@ public:
emit errorMessageChanged(); emit errorMessageChanged();
Location from; Location from;
from.setName(fromName);
from.setCoordinate(fromLat, fromLon); from.setCoordinate(fromLat, fromLon);
Location to; Location to;
to.setName(toName);
to.setCoordinate(toLat, toLon); to.setCoordinate(toLat, toLon);
auto reply = ptMgr.queryJourney({from, to}); auto reply = ptMgr.queryJourney({from, to});
......
...@@ -34,29 +34,37 @@ Kirigami.ApplicationWindow { ...@@ -34,29 +34,37 @@ Kirigami.ApplicationWindow {
id: exampleModel id: exampleModel
ListElement { ListElement {
name: "CDG -> Gare de Lyon" name: "CDG -> Gare de Lyon"
fromName: "Paris Charles de Gaulle"
fromLon: 2.57110 fromLon: 2.57110
fromLat: 49.00406 fromLat: 49.00406
toName: "Paris Gare de Lyon"
toLon: 2.37708 toLon: 2.37708
toLat: 48.84388 toLat: 48.84388
} }
ListElement { ListElement {
name: "ZRH -> Randa" name: "ZRH -> Randa"
fromName: "Zürich Flughafen"
fromLon: 8.56275 fromLon: 8.56275
fromLat: 47.45050 fromLat: 47.45050
toName: "Randa"
toLon: 7.78315 toLon: 7.78315
toLat: 46.09901 toLat: 46.09901
} }
ListElement { ListElement {
name: "Gare de Midi -> Fosdem" name: "Gare de Midi -> Fosdem"
fromName: "Brussels Gare du Midi"
fromLon: 4.33620 fromLon: 4.33620
fromLat: 50.83588 fromLat: 50.83588
toName: "ULB"
toLon: 4.38116 toLon: 4.38116
toLat: 50.81360 toLat: 50.81360
} }
ListElement { ListElement {
name: "VIE -> Akademy 2018 Accomodation" name: "VIE -> Akademy 2018 Accomodation"
fromName: "Wien Flughafen"
fromLon: 16.56312 fromLon: 16.56312
fromLat: 48.12083 fromLat: 48.12083
toName: "Wien Hauptbahnhof"
toLon: 16.37859 toLon: 16.37859
toLat: 48.18282 toLat: 48.18282
} }
...@@ -83,15 +91,19 @@ Kirigami.ApplicationWindow { ...@@ -83,15 +91,19 @@ Kirigami.ApplicationWindow {
} }
ListElement { ListElement {
name: "TXL -> Akademy 2016" name: "TXL -> Akademy 2016"
fromName: "Berlin Flughafen Tegel"
fromLon: 13.29281 fromLon: 13.29281
fromLat: 52.55420 fromLat: 52.55420
toName: "Berlin Alexanderplatz"
toLon: 13.41644 toLon: 13.41644
toLat: 52.52068 toLat: 52.52068
} }
ListElement { ListElement {
name: "SXF -> Akademy 2016" name: "SXF -> Akademy 2016"
fromName: "Berlin Flughafen Schönefeld"
fromLon: 13.51870 fromLon: 13.51870
fromLat: 52.38841 fromLat: 52.38841
toName: "Berlin Alexanderplatz"
toLon: 13.41644 toLon: 13.41644
toLat: 52.52068 toLat: 52.52068
} }
...@@ -241,9 +253,63 @@ Kirigami.ApplicationWindow { ...@@ -241,9 +253,63 @@ Kirigami.ApplicationWindow {
textRole: "name" textRole: "name"
onCurrentIndexChanged: { onCurrentIndexChanged: {
var obj = exampleModel.get(currentIndex); var obj = exampleModel.get(currentIndex);
_queryMgr.findJourney(obj.fromLat, obj.fromLon, obj.toLat, obj.toLon); fromName.text = obj.fromName
fromLon.text = obj.fromLon
fromLat.text = obj.fromLat
toName.text = obj.toName
toLon.text = obj.toLon
toLat.text = obj.toLat
} }
} }
RowLayout {
QQC2.TextField {
id: fromName
}
QQC2.TextField {
id: fromLon
}
QQC2.TextField {
id: fromLat
}
}
RowLayout {
QQC2.TextField {
id: toName
}
QQC2.TextField {
id: toLon
}
QQC2.TextField {
id: toLat
}
}
RowLayout {
QQC2.Button {
text: "Query"
onClicked: _queryMgr.findJourney(fromName.text, fromLat.text, fromLon.text, toName.text, toLat.text, toLon.text);
}
QQC2.Button {
text: "Query Name"
onClicked: _queryMgr.findJourney(fromName.text, NaN, NaN, toName.text, NaN, NaN);
}
QQC2.Button {
text: "Query Coord"
onClicked: _queryMgr.findJourney("", fromLat.text, fromLon.text, "", toLat.text, toLon.text);
}
QQC2.Button {
text: "Clear"
onClicked: {
fromName.text = "";
fromLon.text = "";
fromLat.text = "";
toName.text = "";
toLon.text = "";
toLat.text = "";
}
}
}
QQC2.ComboBox { QQC2.ComboBox {
id: journeySelector id: journeySelector
Layout.fillWidth: true Layout.fillWidth: true
......
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