8#include "assetrepository_p.h"
9#include "backends/srbijavozbackend.h"
10#include "journeyreply.h"
11#include "journeyrequest.h"
12#include "requestcontext_p.h"
13#include "locationreply.h"
14#include "locationrequest.h"
16#include "stopoverreply.h"
17#include "stopoverrequest.h"
18#include "vehiclelayoutrequest.h"
19#include "vehiclelayoutreply.h"
20#include "datatypes/attributionutil_p.h"
21#include "datatypes/backend.h"
22#include "datatypes/backend_p.h"
23#include "datatypes/disruption.h"
24#include "datatypes/json_p.h"
25#include "geo/geojson_p.h"
27#include <KPublicTransport/Journey>
28#include <KPublicTransport/Location>
29#include <KPublicTransport/Stopover>
31#include "backends/accessibilitycloudbackend.h"
32#include "backends/cache.h"
33#include "backends/deutschebahnbackend.h"
34#include "backends/efabackend.h"
35#include "backends/hafasmgatebackend.h"
36#include "backends/hafasquerybackend.h"
37#include "backends/ivvassbackend.h"
38#include "backends/motisbackend.h"
39#include "backends/motis2backend.h"
40#include "backends/navitiabackend.h"
41#include "backends/oebbbackend.h"
42#include "backends/openjourneyplannerbackend.h"
43#include "backends/opentripplannergraphqlbackend.h"
44#include "backends/opentripplannerrestbackend.h"
45#include "backends/ltglinkbackend.h"
46#include "gbfs/gbfsbackend.h"
48#include <QCoreApplication>
49#include <QDirIterator>
51#include <QJsonDocument>
53#include <QMetaProperty>
54#include <QNetworkAccessManager>
55#include <QStandardPaths>
64static inline void initResources() {
65 Q_INIT_RESOURCE(asset_attributions);
66 Q_INIT_RESOURCE(gbfs);
67 Q_INIT_RESOURCE(geometry);
68 Q_INIT_RESOURCE(images);
69 Q_INIT_RESOURCE(networks);
70 Q_INIT_RESOURCE(network_certs);
72 Q_INIT_RESOURCE(stations);
78 [[nodiscard]] QNetworkAccessManager* nam();
80 [[nodiscard]] std::unique_ptr<AbstractBackend> loadNetwork(
const QJsonObject &obj);
81 template <
typename Backend,
typename Backend2,
typename ...Backends>
82 [[nodiscard]]
static std::unique_ptr<AbstractBackend> loadNetwork(
const QJsonObject &backendType,
const QJsonObject &obj);
83 template <
typename Backend>
84 [[nodiscard]]
static std::unique_ptr<AbstractBackend> loadNetwork(
const QJsonObject &backendType,
const QJsonObject &obj);
86 [[nodiscard]]
static std::unique_ptr<AbstractBackend> loadNetwork(
const QJsonObject &obj);
88 template <
typename RequestT>
89 [[nodiscard]]
bool shouldSkipBackend(
const Backend &backend,
const RequestT &req)
const;
91 void resolveLocation(LocationRequest &&locReq,
const AbstractBackend *backend,
const std::function<
void(
const Location &loc)> &callback);
92 [[nodiscard]]
bool queryJourney(
const AbstractBackend *backend,
const JourneyRequest &req, JourneyReply *reply);
93 [[nodiscard]]
bool queryStopover(
const AbstractBackend *backend,
const StopoverRequest &req, StopoverReply *reply);
95 template <
typename RepT,
typename ReqT>
96 [[nodiscard]] RepT* makeReply(
const ReqT &request);
98 void readCachedAttributions();
100 [[nodiscard]]
int queryLocationOnBackend(
const LocationRequest &req, LocationReply *reply,
const Backend &backend);
102 Manager *q =
nullptr;
103 QNetworkAccessManager *m_nam =
nullptr;
104 std::vector<Backend> m_backends;
105 std::vector<Attribution> m_attributions;
108 QStringList m_enabledBackends;
109 QStringList m_disabledBackends;
111 bool m_allowInsecure =
false;
112 bool m_hasReadCachedAttributions =
false;
113 bool m_backendsEnabledByDefault =
true;
116 [[nodiscard]]
bool shouldSkipBackend(
const Backend &backend)
const;
123 m_nam =
new QNetworkAccessManager(q);
125 m_nam->setStrictTransportSecurityEnabled(
true);
132void ManagerPrivate::loadNetworks()
134 if (!m_backends.empty()) {
138 QStringList searchDirs;
144 std::vector<Attribution> attributions;
145 for (
const auto &searchDir : searchDirs) {
146 QDirIterator it(searchDir +
"/org.kde.kpublictransport/networks"_L1, {u
"*.json"_s},
QDir::Files);
147 while (it.hasNext()) {
149 const auto id = it.fileInfo().baseName();
150 if (std::any_of(m_backends.begin(), m_backends.end(), [&
id](
const auto &backend) { return backend.identifier() == id; })) {
155 QFile f(it.filePath());
157 qCWarning(Log) <<
"Failed to open public transport network configuration:" << f.errorString();
161 QJsonParseError
error;
164 qCWarning(Log) <<
"Failed to parse public transport network configuration:" <<
error.errorString() << it.fileName();
168 auto net = loadNetwork(doc.object());
170 net->setBackendId(
id);
172 if (!net->attribution().isEmpty()) {
173 attributions.push_back(net->attribution());
176 auto b = BackendPrivate::fromJson(doc.object());
177 BackendPrivate::setImpl(b, std::move(net));
178 m_backends.push_back(std::move(b));
180 qCWarning(Log) <<
"Failed to load public transport network configuration config:" << it.fileName();
185 std::stable_sort(m_backends.begin(), m_backends.end(), [](
const auto &lhs,
const auto &rhs) {
186 return lhs.identifier() < rhs.identifier();
189 AttributionUtil::sort(attributions);
190 if (m_attributions.empty()) {
192 m_attributions = std::move(attributions);
195 AttributionUtil::merge(m_attributions, attributions);
198 qCDebug(Log) << m_backends.size() <<
"public transport network configurations loaded";
201std::unique_ptr<AbstractBackend> ManagerPrivate::loadNetwork(
const QJsonObject &obj)
207 OpenTripPlannerGraphQLBackend,
208 OpenTripPlannerRestBackend,
215 OpenJourneyPlannerBackend,
219 AccessibilityCloudBackend,
225template <
typename Backend,
typename Backend2,
typename ...Backends>
226std::unique_ptr<AbstractBackend> ManagerPrivate::loadNetwork(
const QJsonObject &backendType,
const QJsonObject &obj)
228 if (backendType.
value(QLatin1String(Backend::type())).toBool()) {
229 return loadNetwork<Backend>(obj);
231 return loadNetwork<Backend2, Backends...>(backendType, obj);
234template <
typename Backend>
235std::unique_ptr<AbstractBackend> ManagerPrivate::loadNetwork(
const QJsonObject &backendType,
const QJsonObject &obj)
237 if (backendType.
value(QLatin1String(Backend::type())).toBool()) {
238 return ManagerPrivate::loadNetwork<Backend>(obj);
240 qCWarning(Log) <<
"Unknown backend type:" << backendType;
244static void applyBackendOptions(AbstractBackend *backend,
const QMetaObject *mo,
const QJsonObject &obj)
247 for (
auto it = opts.begin(); it != opts.end(); ++it) {
250 qCWarning(Log) <<
"Unknown backend setting:" << it.key();
254 if (it.value().isObject()) {
255 mp.writeOnGadget(backend, it.value().toObject());
256 }
else if (it.value().isArray()) {
257 const auto a = it.value().toArray();
261 std::transform(a.begin(), a.end(), std::back_inserter(l), [](
const auto &v) { return v.toString(); });
262 mp.writeOnGadget(backend, l);
264 mp.writeOnGadget(backend, it.value().toArray());
267 mp.writeOnGadget(backend, it.value().toVariant());
273 backend->setAttribution(attr);
276 if (!tzId.isEmpty()) {
277 QTimeZone tz(tzId.toUtf8());
279 backend->setTimeZone(tz);
281 qCWarning(Log) <<
"Invalid timezone:" << tzId;
285 const auto langArray = obj.
value(
"supportedLanguages"_L1).
toArray();
287 langs.
reserve(langArray.size());
288 std::transform(langArray.begin(), langArray.end(), std::back_inserter(langs), [](
const auto &v) { return v.toString(); });
289 backend->setSupportedLanguages(langs);
292template<
typename T> std::unique_ptr<AbstractBackend> ManagerPrivate::loadNetwork(
const QJsonObject &obj)
294 std::unique_ptr<AbstractBackend> backend(
new T);
295 applyBackendOptions(backend.get(), &T::staticMetaObject, obj);
299bool ManagerPrivate::shouldSkipBackend(
const Backend &backend)
const
301 if (!backend.
isSecure() && !m_allowInsecure) {
302 qCDebug(Log) <<
"Skipping insecure backend:" << backend.
identifier();
305 return !q->isBackendEnabled(backend.
identifier());
308template <
typename RequestT>
309bool ManagerPrivate::shouldSkipBackend(
const Backend &backend,
const RequestT &req)
const
311 if (!req.backendIds().isEmpty() && !req.backendIds().contains(backend.
identifier())) {
315 return shouldSkipBackend(backend);
320void ManagerPrivate::resolveLocation(
LocationRequest &&locReq,
const AbstractBackend *backend,
const std::function<
void(
const Location&)> &callback)
323 locReq.setMaximumResults(1);
326 const auto cacheEntry = Cache::lookupLocation(backend->backendId(), locReq.cacheKey());
327 switch (cacheEntry.type) {
328 case CacheHitType::Negative:
331 case CacheHitType::Positive:
332 if (!cacheEntry.data.empty()) {
333 const auto loc = cacheEntry.data[0];
338 case CacheHitType::Miss:
343 auto locReply =
new LocationReply(locReq, q);
344 if (backend->queryLocation(locReq, locReply, nam())) {
345 locReply->setPendingOps(1);
347 locReply->setPendingOps(0);
350 locReply->deleteLater();
351 if (locReply->result().empty()) {
354 callback(locReply->result()[0]);
359static Location::Types locationTypesForJourneyRequest(
const JourneyRequest &req)
362 if (req.
modes() & JourneySection::PublicTransport) {
373 auto cache = Cache::lookupJourney(backend->backendId(), req.
cacheKey());
374 switch (cache.type) {
375 case CacheHitType::Negative:
376 qCDebug(Log) <<
"Negative cache hit for backend" << backend->backendId();
378 case CacheHitType::Positive:
379 qCDebug(Log) <<
"Positive cache hit for backend" << backend->backendId();
380 reply->addAttributions(std::move(cache.attributions));
381 reply->addResult(backend, std::move(cache.data));
383 case CacheHitType::Miss:
384 qCDebug(Log) <<
"Cache miss for backend" << backend->backendId();
389 if (backend->needsLocationQuery(req.
from(), AbstractBackend::QueryType::Journey)) {
390 LocationRequest fromReq(req.
from());
391 fromReq.setTypes(locationTypesForJourneyRequest(req));
392 resolveLocation(std::move(fromReq), backend, [reply, backend, req,
this](
const Location &loc) {
393 auto jnyRequest = req;
395 jnyRequest.setFrom(fromLoc);
397 if (backend->needsLocationQuery(jnyRequest.to(), AbstractBackend::QueryType::Journey)) {
398 LocationRequest toReq(jnyRequest.to());
399 toReq.setTypes(locationTypesForJourneyRequest(req));
400 resolveLocation(std::move(toReq), backend, [jnyRequest, reply, backend,
this](
const Location &loc) {
401 auto jnyReq = jnyRequest;
404 if (!backend->queryJourney(jnyReq, reply, nam())) {
412 if (!backend->queryJourney(jnyRequest, reply, nam())) {
420 if (backend->needsLocationQuery(req.
to(), AbstractBackend::QueryType::Journey)) {
421 LocationRequest toReq(req.
to());
422 toReq.setTypes(locationTypesForJourneyRequest(req));
423 resolveLocation(std::move(toReq), backend, [req, toReq, reply, backend,
this](
const Location &loc) {
425 auto jnyRequest = req;
426 jnyRequest.setTo(toLoc);
427 if (!backend->queryJourney(jnyRequest, reply, nam())) {
434 return backend->queryJourney(req, reply, nam());
439 auto cache = Cache::lookupStopover(backend->backendId(), req.
cacheKey());
440 switch (cache.type) {
441 case CacheHitType::Negative:
442 qCDebug(Log) <<
"Negative cache hit for backend" << backend->backendId();
444 case CacheHitType::Positive:
445 qCDebug(Log) <<
"Positive cache hit for backend" << backend->backendId();
446 reply->addAttributions(std::move(cache.attributions));
447 reply->addResult(backend, std::move(cache.data));
449 case CacheHitType::Miss:
450 qCDebug(Log) <<
"Cache miss for backend" << backend->backendId();
455 if (backend->needsLocationQuery(req.
stop(), AbstractBackend::QueryType::Departure)) {
456 qCDebug(Log) <<
"Backend needs location query first:" << backend->backendId();
457 LocationRequest locReq(req.
stop());
459 locReq.setMaximumDistance(250);
460 resolveLocation(std::move(locReq), backend, [reply, req, backend,
this](
const Location &loc) {
462 auto depRequest = req;
463 depRequest.setStop(depLoc);
464 if (!backend->queryStopover(depRequest, reply, nam())) {
471 return backend->queryStopover(req, reply, nam());
474void ManagerPrivate::readCachedAttributions()
476 if (m_hasReadCachedAttributions) {
480 Cache::allCachedAttributions(m_attributions);
481 m_hasReadCachedAttributions =
true;
484template<
typename RepT,
typename ReqT>
485RepT* ManagerPrivate::makeReply(
const ReqT &request)
487 auto reply =
new RepT(request, q);
489 AttributionUtil::merge(m_attributions, reply->
attributions());
496Manager::Manager(QObject *parent)
498 , d(new ManagerPrivate)
501 qRegisterMetaType<Disruption::Effect>();
504 if (!AssetRepository::instance()) {
505 auto assetRepo =
new AssetRepository(
this);
506 assetRepo->setNetworkAccessManagerProvider(std::bind(&ManagerPrivate::nam, d.get()));
514Manager::~Manager() =
default;
518 if (d->m_nam == nam) {
522 if (d->m_nam && d->m_nam->parent() ==
this) {
531 return d->m_allowInsecure;
536 if (d->m_allowInsecure == insecure) {
539 d->m_allowInsecure = insecure;
540 Q_EMIT configurationChanged();
552 reply->setPendingOps(pendingOps);
559 if (req.contexts().empty()) {
561 bool foundNonGlobalCoverage =
false;
562 for (
const auto coverageType : { CoverageArea::Realtime, CoverageArea::Regular, CoverageArea::Any }) {
563 const auto checkBackend = [&](
const Backend &backend,
bool bothLocationMatch) {
564 if (triedBackends.
contains(backend.
identifier()) || d->shouldSkipBackend(backend, req)) {
567 const auto coverage = backend.coverageArea(coverageType);
568 if (coverage.isEmpty()) {
572 if (bothLocationMatch) {
573 if (!coverage.coversLocation(req.
from()) || !coverage.coversLocation(req.
to())) {
577 if (!coverage.coversLocation(req.
from()) && !coverage.coversLocation(req.
to())) {
583 foundNonGlobalCoverage |= !coverage.isGlobal();
585 if (d->queryJourney(BackendPrivate::impl(backend), req, reply)) {
591 for (
const auto &backend: d->m_backends) {
592 checkBackend(backend,
true);
594 if (pendingOps && foundNonGlobalCoverage) {
599 for (
const auto &backend: d->m_backends) {
600 checkBackend(backend,
false);
602 if (pendingOps && foundNonGlobalCoverage) {
609 for (
const auto &context : req.contexts()) {
611 if ((context.type == RequestContext::Next && context.backend->hasCapability(AbstractBackend::CanQueryNextJourney))
612 ||(context.type == RequestContext::Previous && context.backend->hasCapability(AbstractBackend::CanQueryPreviousJourney)))
614 if (d->queryJourney(context.backend, req, reply)) {
624 if (d->queryJourney(context.backend, r, reply)) {
631 if (d->queryJourney(context.backend, r, reply)) {
640 reply->addAttributions(AssetRepository::instance()->
attributions());
643 if (pendingOps == 0) {
646 reply->setPendingOps(pendingOps);
658 reply->setPendingOps(pendingOps);
665 if (req.contexts().empty()) {
667 bool foundNonGlobalCoverage =
false;
668 for (
const auto coverageType : { CoverageArea::Realtime, CoverageArea::Regular, CoverageArea::Any }) {
669 for (
const auto &backend: d->m_backends) {
670 if (triedBackends.
contains(backend.identifier()) || d->shouldSkipBackend(backend, req)) {
674 qCDebug(
Log) <<
"Skipping backend due to not supporting arrival queries:" << backend.identifier();
677 const auto coverage = backend.coverageArea(coverageType);
678 if (coverage.isEmpty() || !coverage.coversLocation(req.
stop())) {
681 triedBackends.
insert(backend.identifier());
682 foundNonGlobalCoverage |= !coverage.isGlobal();
684 if (d->queryStopover(BackendPrivate::impl(backend), req, reply)) {
689 if (pendingOps && foundNonGlobalCoverage) {
696 for (
const auto &context : req.contexts()) {
698 if ((context.type == RequestContext::Next && context.backend->hasCapability(AbstractBackend::CanQueryNextDeparture))
699 ||(context.type == RequestContext::Previous && context.backend->hasCapability(AbstractBackend::CanQueryPreviousDeparture)))
701 if (d->queryStopover(context.backend, req, reply)) {
708 if (context.type == RequestContext::Next) {
710 r.setDateTime(context.dateTime);
711 if (d->queryStopover(context.backend, r, reply)) {
720 reply->addAttributions(AssetRepository::instance()->
attributions());
723 if (pendingOps == 0) {
726 reply->setPendingOps(pendingOps);
733 switch (cache.type) {
734 case CacheHitType::Negative:
735 qCDebug(
Log) <<
"Negative cache hit for backend" << backend.
identifier();
737 case CacheHitType::Positive:
738 qCDebug(
Log) <<
"Positive cache hit for backend" << backend.
identifier();
739 reply->addAttributions(std::move(cache.attributions));
740 reply->addResult(std::move(cache.data));
742 case CacheHitType::Miss:
743 qCDebug(
Log) <<
"Cache miss for backend" << backend.
identifier();
744 reply->addAttribution(BackendPrivate::impl(backend)->attribution());
745 if (BackendPrivate::impl(backend)->queryLocation(req, reply, nam())) {
762 reply->setPendingOps(pendingOps);
769 bool foundNonGlobalCoverage =
false;
772 for (
const auto coverageType : { CoverageArea::Realtime, CoverageArea::Regular, CoverageArea::Any }) {
774 for (
const auto &backend : d->m_backends) {
775 if (triedBackends.
contains(backend.
identifier()) || d->shouldSkipBackend(backend, req)) {
778 const auto coverage = backend.coverageArea(coverageType);
779 if (coverage.isEmpty() || !coverage.coversLocation(loc)) {
782 if (isCountryOnly && !coverage.hasNationWideCoverage(loc.
country())) {
787 foundNonGlobalCoverage |= !coverage.isGlobal();
788 pendingOps += d->queryLocationOnBackend(req, reply, backend);
790 if (pendingOps && foundNonGlobalCoverage) {
795 for (
const auto &backend : d->m_backends) {
796 if (triedBackends.
contains(backend.
identifier()) || d->shouldSkipBackend(backend, req)) {
799 const auto coverage = backend.coverageArea(coverageType);
800 if (coverage.isEmpty() || !coverage.coversLocation(loc)) {
805 foundNonGlobalCoverage |= !coverage.isGlobal();
806 pendingOps += d->queryLocationOnBackend(req, reply, backend);
808 if (pendingOps && foundNonGlobalCoverage) {
813 if (pendingOps == 0) {
816 reply->setPendingOps(pendingOps);
828 reply->setPendingOps(pendingOps);
834 for (
const auto coverageType : { CoverageArea::Realtime, CoverageArea::Regular }) {
835 for (
const auto &backend : d->m_backends) {
836 if (d->shouldSkipBackend(backend, req)) {
839 const auto coverage = backend.coverageArea(coverageType);
840 if (coverage.isEmpty() || !coverage.coversLocation(req.
stopover().
stopPoint())) {
843 reply->addAttribution(BackendPrivate::impl(backend)->attribution());
846 switch (cache.type) {
847 case CacheHitType::Negative:
848 qCDebug(
Log) <<
"Negative cache hit for backend" << backend.
identifier();
850 case CacheHitType::Positive:
851 qCDebug(
Log) <<
"Positive cache hit for backend" << backend.
identifier();
852 if (cache.data.size() == 1) {
853 reply->addAttributions(std::move(cache.attributions));
854 reply->addResult(cache.data[0]);
858 case CacheHitType::Miss:
859 qCDebug(
Log) <<
"Cache miss for backend" << backend.
identifier();
871 if (pendingOps == 0) {
874 reply->setPendingOps(pendingOps);
880 if (d->m_backends.empty()) {
883 d->m_backends.clear();
891 d->readCachedAttributions();
892 return d->m_attributions;
895QVariantList Manager::attributionsVariant()
const
898 d->readCachedAttributions();
900 l.
reserve(d->m_attributions.size());
901 std::transform(d->m_attributions.begin(), d->m_attributions.end(), std::back_inserter(l), [](
const auto &attr) { return QVariant::fromValue(attr); });
908 return d->m_backends;
913 if (std::binary_search(d->m_disabledBackends.cbegin(), d->m_disabledBackends.cend(), backendId)) {
916 if (std::binary_search(d->m_enabledBackends.cbegin(), d->m_enabledBackends.cend(), backendId)) {
920 return d->m_backendsEnabledByDefault;
925 const auto it = std::lower_bound(l.
begin(), l.
end(), value);
926 if (it == l.
end() || (*it) != value) {
931static void sortedRemove(QStringList &l,
const QString &value)
933 const auto it = std::lower_bound(l.
begin(), l.
end(), value);
934 if (it != l.
end() && (*it) == value) {
942 sortedInsert(d->m_enabledBackends, backendId);
943 sortedRemove(d->m_disabledBackends, backendId);
945 sortedRemove(d->m_enabledBackends, backendId);
946 sortedInsert(d->m_disabledBackends, backendId);
948 Q_EMIT configurationChanged();
953 return d->m_enabledBackends;
959 for (
const auto &backendId : backendIds) {
966 return d->m_disabledBackends;
972 for (
const auto &backendId : backendIds) {
979 return d->m_backendsEnabledByDefault;
984 d->m_backendsEnabledByDefault = byDefault;
986 Q_EMIT configurationChanged();
989QVariantList Manager::backendsVariant()
const
993 l.
reserve(d->m_backends.size());
994 std::transform(d->m_backends.begin(), d->m_backends.end(), std::back_inserter(l), [](
const auto &b) { return QVariant::fromValue(b); });
1007#include "moc_manager.cpp"
static Attribution fromJson(const QJsonObject &obj)
Deserialize an Attribution object from JSON.
Information about a backend service queried for location/departure/journey data.
bool isSecure
Supports secrure network access.
QString identifier
Internal identifier of this backend.
Describes a journey search.
KPublicTransport::Location to
The journey destination.
void setArrivalTime(const QDateTime &dt)
Sets the desired arrival time.
void setDepartureTime(const QDateTime &dt)
Set the desired departure time.
bool downloadAssets
Download graphic assets such as line logos for the data requested here.
@ Departure
dateTime() represents the desired departure time.
bool isValid() const
Returns true if this is a valid request, that is, it has enough parameters set to perform a query.
QString cacheKey() const
Unique string representation used for caching results.
KPublicTransport::Location from
The starting point of the journey search.
KPublicTransport::JourneySection::Modes modes
Modes of transportation that should be considered for this query.
DateTimeMode dateTimeMode
Controls whether to search for journeys starting or ending at the given time.
@ RentedVehicle
free floating or dock-based rental bike service, electric scooters, car sharing services,...
Describes a location search.
bool isValid() const
Returns true if this is a valid request, that is it has enough parameters set to perform a query.
QString cacheKey() const
Unique string representation used for caching results.
KPublicTransport::Location location
Location object containing the search parameters.
QString region
Region (as in ISO 3166-2) of the location, if known.
@ RentedVehicleStation
a pick-up/drop-off point for dock-based rental bike/scooter systems
@ Place
a location that isn't of any specific type
@ Stop
a public transport stop (train station, bus stop, etc)
static Location merge(const Location &lhs, const Location &rhs)
Merge two departure instances.
QString country
Country of the location as ISO 3166-1 alpha 2 code, if known.
LocationReply * queryLocation(const LocationRequest &req) const
Query location information based on coordinates or (parts of) the name.
JourneyReply * queryJourney(const JourneyRequest &req) const
Query a journey.
void setBackendsEnabledByDefault(bool byDefault)
Set wheter backends are enabled by default.
void setEnabledBackends(const QStringList &backendIds)
Sets the explicitly enabled backends.
bool backendsEnabledByDefault
void setBackendEnabled(const QString &backendId, bool enabled)
Sets whether the backend with the given identifier should be used.
void reload()
Reload backend configuration.
StopoverReply * queryStopover(const StopoverRequest &req) const
Query arrivals or departures from a specific station.
QStringList disabledBackends
Q_INVOKABLE bool isBackendEnabled(const QString &backendId) const
Returns whether the use of the backend with a given identifier is enabled.
void setDisabledBackends(const QStringList &backendIds)
Sets the explicitly disabled backends.
VehicleLayoutReply * queryVehicleLayout(const VehicleLayoutRequest &req) const
Query vehicle and platform layout information.
QVariantList backends
QML-compatible access to backends().
bool allowInsecureBackends
Allow usage of insecure backends (default: off).
void setNetworkAccessManager(QNetworkAccessManager *nam)
Set the network access manager to use for network operations.
void setAllowInsecureBackends(bool insecure)
Allow usage of insecure backends, that is services not using transport encryption.
QStringList enabledBackends
QVariantList attributions
QML-compatible access to attributions().
void finished()
Emitted whenever the corresponding search has been completed.
const std::vector< Attribution > & attributions() const
Returns the attributions for the provided data.
@ InvalidRequest
Incomplete or otherwise invalid request.
@ NoBackend
No backend was found to satisfy this request, e.g. due to no backend covering the requested area.
@ NotFoundError
The requested journey/departure/place could not be found.
Departure or arrival query reply.
Describes an arrival or departure search.
@ QueryArrival
Search for arrivals.
bool downloadAssets
Enable downloading of graphic assets such as line logos for the data requested here.
bool isValid() const
Returns true if this is a valid request, ie.
QString cacheKey() const
Unique string representation used for caching results.
KPublicTransport::Location stop
The location at which to search for departures/arrivals.
Mode mode
Controls whether to search for arrivals or departures.
KPublicTransport::Location stopPoint
The stop point of this departure.
Reply to a vehicle layout query.
Describes a query for vehicle layout information.
QString cacheKey() const
Unique string representation used for caching results.
bool isValid() const
Returns true if this is a valid request, that is it has enough parameters set to perform a query.
KPublicTransport::Stopover stopover
The stopover vehicle and platform layout information are requested for.
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
Query operations and data types for accessing realtime public transport information from online servi...
QCoreApplication * instance()
QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error)
QJsonValue value(QLatin1StringView key) const const
QJsonArray toArray() const const
QJsonObject toObject() const const
QString toString() const const
iterator erase(const_iterator begin, const_iterator end)
iterator insert(const_iterator before, parameter_type value)
void push_back(parameter_type value)
void reserve(qsizetype size)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
virtual bool event(QEvent *e)
virtual bool eventFilter(QObject *watched, QEvent *event)
void installEventFilter(QObject *filterObj)
bool contains(const QSet< T > &other) const const
iterator insert(const T &value)
QStringList standardLocations(StandardLocation type)
QString writableLocation(StandardLocation type)
bool isEmpty() const const