Commit 94551396 authored by Volker Krause's avatar Volker Krause
Browse files

Make stopover query result limit configurable as well

This is now consistent with the other query types.
parent 07ac5da0
......@@ -118,7 +118,7 @@ bool EfaBackend::queryStopover(const StopoverRequest &request, StopoverReply *re
query.addQueryItem(QStringLiteral("itdDate"), dt.date().toString(QStringLiteral("yyyyMMdd")));
query.addQueryItem(QStringLiteral("itdTime"), dt.time().toString(QStringLiteral("hhmm")));
query.addQueryItem(QStringLiteral("useRealtime"), QStringLiteral("1"));
query.addQueryItem(QStringLiteral("limit"), QStringLiteral("12")); // TODO
query.addQueryItem(QStringLiteral("limit"), QString::number(request.maximumResults()));
// not exactly sure what these do, but without this the result is missing departure times
query.addQueryItem(QStringLiteral("mode"), QStringLiteral("direct"));
......
......@@ -168,7 +168,7 @@ bool HafasMgateBackend::queryStopover(const StopoverRequest &request, StopoverRe
QJsonObject req;
req.insert(QStringLiteral("date"), dt.toString(QStringLiteral("yyyyMMdd")));
req.insert(QStringLiteral("maxJny"), 12);
req.insert(QStringLiteral("maxJny"), request.maximumResults());
// stbFltrEquiv is no longer allowed above API version 1.20
if (QVersionNumber::fromString(m_version) < QVersionNumber(1, 20)) {
req.insert(QStringLiteral("stbFltrEquiv"), true);
......
......@@ -175,7 +175,7 @@ bool HafasQueryBackend::queryStopover(const StopoverRequest &request, StopoverRe
QUrlQuery query;
query.addQueryItem(QStringLiteral("boardType"), request.mode() == StopoverRequest::QueryDeparture ? QStringLiteral("dep") : QStringLiteral("arr"));
query.addQueryItem(QStringLiteral("disableEquivs"), QStringLiteral("0"));
query.addQueryItem(QStringLiteral("maxJourneys"), QStringLiteral("12"));
query.addQueryItem(QStringLiteral("maxJourneys"), QString::number(request.maximumResults()));
query.addQueryItem(QStringLiteral("input"), stationId);
query.addQueryItem(QStringLiteral("date"), request.dateTime().date().toString(QStringLiteral("dd.MM.yy")));
query.addQueryItem(QStringLiteral("time"), request.dateTime().time().toString(QStringLiteral("hh:mm")));
......
......@@ -88,7 +88,7 @@ bool IvvAssBackend::queryStopover(const StopoverRequest &req, StopoverReply *rep
} else {
query.addQueryItem(QStringLiteral("i"), req.stop().identifier(QStringLiteral("ifopt")));
}
// query.addQueryItem(QStringLiteral("c"), QString::number(req.maximumResults()));
query.addQueryItem(QStringLiteral("c"), QString::number(req.maximumResults()));
// TODO timezone conversion
query.addQueryItem(QStringLiteral("t"), req.dateTime().toString(Qt::ISODate));
......
......@@ -128,6 +128,7 @@ bool NavitiaBackend::queryStopover(const StopoverRequest &req, StopoverReply *re
query.addQueryItem(QStringLiteral("from_datetime"), req.dateTime().toString(QStringLiteral("yyyyMMddThhmmss")));
query.addQueryItem(QStringLiteral("disable_geojson"), QStringLiteral("true"));
query.addQueryItem(QStringLiteral("depth"), QStringLiteral("0"));
query.addQueryItem(QStringLiteral("count"), QString::number(std::max(1, req.maximumResults())));
url.setQuery(query);
QNetworkRequest netReq(url);
......
......@@ -28,6 +28,7 @@ public:
std::vector<RequestContext> contexts;
QStringList backendIds;
bool downloadAssets = false;
int maximumResults = 12;
};
}
......@@ -35,6 +36,7 @@ KPUBLICTRANSPORT_MAKE_GADGET(StopoverRequest)
KPUBLICTRANSPORT_MAKE_PROPERTY(StopoverRequest, Location, stop, setStop)
KPUBLICTRANSPORT_MAKE_PROPERTY(StopoverRequest, StopoverRequest::Mode, mode, setMode)
KPUBLICTRANSPORT_MAKE_PROPERTY(StopoverRequest, bool, downloadAssets, setDownloadAssets)
KPUBLICTRANSPORT_MAKE_PROPERTY(StopoverRequest, int, maximumResults, setMaximumResults)
StopoverRequest::StopoverRequest(const Location &stop)
: d(new StopoverRequestPrivate)
......
......@@ -59,6 +59,12 @@ public:
*/
KPUBLICTRANSPORT_PROPERTY(bool, downloadAssets, setDownloadAssets)
/** The maximum amount of expected results.
* @note This is only an optimization hint for backends, not a guarantee
* that all results comply with this constraint.
*/
KPUBLICTRANSPORT_PROPERTY(int, maximumResults, setMaximumResults)
public:
/** Search for arrival/departures to/from @p stop. */
explicit StopoverRequest(const Location &stop);
......
......@@ -218,6 +218,7 @@ Kirigami.ApplicationWindow {
property alias queryArrivals: arrivalBox.checked
property alias singleBackend: backendBox.checked
property alias backend: backendSelector.currentIndex
property alias maxResults: maxResults.text
}
ColumnLayout {
......@@ -249,6 +250,13 @@ Kirigami.ApplicationWindow {
enabled: backendBox.checked
}
}
RowLayout {
QQC2.Label { text: "Results:" }
QQC2.TextField {
id: maxResults
text: "10"
}
}
QQC2.ComboBox {
id: exampleSelector
......@@ -291,7 +299,8 @@ Kirigami.ApplicationWindow {
departureModel.request.stop = stop;
departureModel.request.mode = arrivalBox.checked ? StopoverRequest.QueryArrival : StopoverRequest.QueryDeparture;
departureModel.request.backends = backendBox.checked ? [ backendSelector.currentText ] : [];
departureModel.request.downloadAssets = true
departureModel.request.downloadAssets = true;
departureModel.request.maximumResults = maxResults.text;
}
}
QQC2.Button {
......@@ -304,7 +313,8 @@ Kirigami.ApplicationWindow {
departureModel.request.stop = stop;
departureModel.request.mode = arrivalBox.checked ? StopoverRequest.QueryArrival : StopoverRequest.QueryDeparture;
departureModel.request.backends = backendBox.checked ? [ backendSelector.currentText ] : [];
departureModel.request.downloadAssets = true
departureModel.request.downloadAssets = true;
departureModel.request.maximumResults = maxResults.text;
}
}
QQC2.Button {
......@@ -317,7 +327,8 @@ Kirigami.ApplicationWindow {
departureModel.request.stop = stop;
departureModel.request.mode = arrivalBox.checked ? StopoverRequest.QueryArrival : StopoverRequest.QueryDeparture;
departureModel.request.backends = backendBox.checked ? [ backendSelector.currentText ] : [];
departureModel.request.downloadAssets = true
departureModel.request.downloadAssets = true;
departureModel.request.maximumResults = maxResults.text;
}
}
QQC2.Button {
......
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