KPublicTransport

stopoverrequest.h
1/*
2 SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KPUBLICTRANSPORT_STOPOVERREQUEST_H
8#define KPUBLICTRANSPORT_STOPOVERREQUEST_H
9
10#include "kpublictransport_export.h"
11
12#include <KPublicTransport/Datatypes>
13#include <KPublicTransport/Line>
14
15#include <QMetaType>
16#include <QSharedDataPointer>
17
18#include <vector>
19
20class QDateTime;
21
22namespace KPublicTransport {
23
24class AbstractBackend;
25class Location;
26class RequestContext;
27class StopoverRequestPrivate;
28
29/** Describes an arrival or departure search.
30 * By default this search departures starting now, from the given Location.
31 */
32class KPUBLICTRANSPORT_EXPORT StopoverRequest
33{
34 KPUBLICTRANSPORT_GADGET(StopoverRequest)
35
36 /** The location at which to search for departures/arrivals. */
37 KPUBLICTRANSPORT_PROPERTY(KPublicTransport::Location, stop, setStop)
38 /** Date/time at which the search should start.
39 * Default: now
40 */
41 KPUBLICTRANSPORT_PROPERTY(QDateTime, dateTime, setDateTime)
42
43 /** Line modes. */
44 Q_PROPERTY(QVariantList lineModes READ lineModesVariant WRITE setLineModesVariant)
45
46public:
47 /** Query departures or arrivals? */
48 enum Mode {
49 QueryArrival, ///< Search for arrivals.
50 QueryDeparture ///< Search for departures.
51 };
52 Q_ENUM(Mode)
53
54 /** Controls whether to search for arrivals or departures.
55 * Default is QueryDeparture.
56 */
57 KPUBLICTRANSPORT_PROPERTY(Mode, mode, setMode)
58
59 Q_PROPERTY(QStringList backends READ backendIds WRITE setBackendIds)
60
61 /** Enable downloading of graphic assets such as line logos for the data requested here.
62 * Default: @c false
63 */
64 KPUBLICTRANSPORT_PROPERTY(bool, downloadAssets, setDownloadAssets)
65
66 /** The maximum amount of expected results.
67 * @note This is only an optimization hint for backends, not a guarantee
68 * that all results comply with this constraint.
69 */
70 KPUBLICTRANSPORT_PROPERTY(int, maximumResults, setMaximumResults)
71
72public:
73 /** Search for arrival/departures to/from @p stop. */
74 explicit StopoverRequest(const Location &stop);
75
76 /** Returns @c true if this is a valid request, ie. this is complete enough to perform a query. */
77 bool isValid() const;
78
79 /** Identifiers of the backends that should be queried.
80 * @see setBackendIds()
81 */
82 QStringList backendIds() const;
83 /** Set identifiers of backends that should be queried.
84 * Settings this is only needed when you want explicit control over this, leaving
85 * this empty picks suitable backends automatically.
86 */
87 void setBackendIds(const QStringList &backendIds);
88
89 /** Requested line modes.
90 * That is, the possible types of public transport lines to consider.
91 * Default: all
92 */
93 const std::vector<Line::Mode>& lineModes() const;
94 /** Sets the requested line modes.
95 * An empty list is considered as all modes being allowed.
96 * @note This relies on backends actually supporting this and is thus does not
97 * provide any guarantee that the results wont contain other modes as well.
98 */
99 void setLineModes(std::vector <Line::Mode> &&modes);
100
101 /** Unique string representation used for caching results. */
102 QString cacheKey() const;
103
104 ///@cond internal
105 static QJsonObject toJson(const StopoverRequest &req);
106 ///@endcond
107private:
108 friend class AbstractBackend;
109 friend class StopoverReply;
110 friend class StopoverReplyPrivate;
111 friend class Manager;
112
113 Q_DECL_HIDDEN QVariantList lineModesVariant() const;
114 Q_DECL_HIDDEN void setLineModesVariant(const QVariantList &modes);
115
116 Q_DECL_HIDDEN RequestContext context(const AbstractBackend *backend) const;
117 Q_DECL_HIDDEN const std::vector<RequestContext>& contexts() const;
118 Q_DECL_HIDDEN void setContext(const AbstractBackend *backend, RequestContext &&context);
119 Q_DECL_HIDDEN void purgeLoops(const StopoverRequest &baseRequest);
120};
121}
122
123Q_DECLARE_METATYPE(KPublicTransport::StopoverRequest)
124
125#endif // KPUBLICTRANSPORT_STOPOVERREQUEST_H
A public transport line.
Definition line.h:20
Entry point for starting public transport queries.
Definition manager.h:42
Departure or arrival query reply.
Describes an arrival or departure search.
Mode
Query departures or arrivals?
@ QueryArrival
Search for arrivals.
void stop(Ekos::AlignState mode)
Query operations and data types for accessing realtime public transport information from online servi...
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:06 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.