KPublicTransport

stopoverrequest.h
1 /*
2  SPDX-FileCopyrightText: 2018 Volker Krause <[email protected]>
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 
14 #include <QMetaType>
15 #include <QSharedDataPointer>
16 
17 #include <vector>
18 
19 class QDateTime;
20 
21 namespace KPublicTransport {
22 
23 class AbstractBackend;
24 class Location;
25 class RequestContext;
26 class StopoverRequestPrivate;
27 
28 /** Describes an arrival or departure search.
29  * By default this search departures starting now, from the given Location.
30  */
31 class KPUBLICTRANSPORT_EXPORT StopoverRequest
32 {
33  KPUBLICTRANSPORT_GADGET(StopoverRequest)
34 
35  /** The location at which to search for departures/arrivals. */
36  KPUBLICTRANSPORT_PROPERTY(KPublicTransport::Location, stop, setStop)
37  /** Date/time at which the search should start.
38  * Default: now
39  */
40  KPUBLICTRANSPORT_PROPERTY(QDateTime, dateTime, setDateTime)
41 
42 public:
43  /** Query departures or arrivals? */
44  enum Mode {
45  QueryArrival, ///< Search for arrivals.
46  QueryDeparture ///< Search for departures.
47  };
48  Q_ENUM(Mode)
49 
50  /** Controls whether to search for arrivals or departures.
51  * Default is QueryDeparture.
52  */
53  KPUBLICTRANSPORT_PROPERTY(Mode, mode, setMode)
54 
55  Q_PROPERTY(QStringList backends READ backendIds WRITE setBackendIds)
56 
57  /** Enable downloading of graphic assets such as line logos for the data requested here.
58  * Default: @c false
59  */
60  KPUBLICTRANSPORT_PROPERTY(bool, downloadAssets, setDownloadAssets)
61 
62  /** The maximum amount of expected results.
63  * @note This is only an optimization hint for backends, not a guarantee
64  * that all results comply with this constraint.
65  */
66  KPUBLICTRANSPORT_PROPERTY(int, maximumResults, setMaximumResults)
67 
68 public:
69  /** Search for arrival/departures to/from @p stop. */
70  explicit StopoverRequest(const Location &stop);
71 
72  /** Returns @c true if this is a valid request, ie. this is complete enough to perform a query. */
73  bool isValid() const;
74 
75  /** Identifiers of the backends that should be queried.
76  * @see setBackendIds()
77  */
78  QStringList backendIds() const;
79  /** Set identifiers of backends that should be queried.
80  * Settings this is only needed when you want explicit control over this, leaving
81  * this empty picks suitable backends automatically.
82  */
83  void setBackendIds(const QStringList &backendIds);
84 
85  /** Unique string representation used for caching results. */
86  QString cacheKey() const;
87 
88  ///@cond internal
89  static QJsonObject toJson(const StopoverRequest &req);
90  ///@endcond
91 private:
92  friend class AbstractBackend;
93  friend class StopoverReply;
94  friend class StopoverReplyPrivate;
95  friend class Manager;
96  Q_DECL_HIDDEN RequestContext context(const AbstractBackend *backend) const;
97  Q_DECL_HIDDEN const std::vector<RequestContext>& contexts() const;
98  Q_DECL_HIDDEN void setContext(const AbstractBackend *backend, RequestContext &&context);
99  Q_DECL_HIDDEN void purgeLoops(const StopoverRequest &baseRequest);
100 };
101 }
102 
103 Q_DECLARE_METATYPE(KPublicTransport::StopoverRequest)
104 
105 #endif // KPUBLICTRANSPORT_STOPOVERREQUEST_H
Departure or arrival query reply.
Definition: stopoverreply.h:22
Query operations and data types for accessing realtime public transport information from online servi...
Definition: attribution.cpp:16
Describes an arrival or departure search.
Mode
Query departures or arrivals?
Entry point for starting public transport queries.
Definition: manager.h:41
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Oct 15 2021 23:07:28 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.