KPublicTransport

onboardstatus.h
1/*
2 SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#ifndef KPUBLICTRANSPORT_ONBOARDSTATUS_H
7#define KPUBLICTRANSPORT_ONBOARDSTATUS_H
8
9#include "kpublictransportonboard_export.h"
10
11#include <QObject>
12
13#include <memory>
14
15namespace KPublicTransport {
16class Journey;
17class OnboardStatusPrivate;
18
19/** Access to public transport onboard API.
20 *
21 * Instances of this class act as a lightweight frontend to an internal
22 * singleton, for easy integration with QML.
23 */
24class KPUBLICTRANSPORTONBOARD_EXPORT OnboardStatus : public QObject
25{
26 Q_OBJECT
27 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
28
29 /** Current geographic position, @c NAN if not available. */
30 Q_PROPERTY(float latitude READ latitude NOTIFY positionChanged)
31 Q_PROPERTY(float longitude READ longitude NOTIFY positionChanged)
32 /** Whether the geographic position is currently available. */
33 Q_PROPERTY(bool hasPosition READ hasPosition NOTIFY positionChanged)
34 /** Whether the backend supports querying for the geographic position. */
35 Q_PROPERTY(bool supportsPosition READ supportsPosition NOTIFY supportsPositionChanged)
36
37 /** Current speed in km/h. */
38 Q_PROPERTY(float speed READ speed NOTIFY positionChanged)
39 Q_PROPERTY(bool hasSpeed READ hasSpeed NOTIFY positionChanged)
40
41 /** Current heading in degree, NAN if unknown. */
42 Q_PROPERTY(float heading READ heading NOTIFY positionChanged)
43 Q_PROPERTY(bool hasHeading READ hasHeading NOTIFY positionChanged)
44
45 /** Current altitude in meters, NAN if unknown. */
46 Q_PROPERTY(float altitude READ altitude NOTIFY positionChanged)
47 Q_PROPERTY(bool hasAltitude READ hasAltitude NOTIFY positionChanged)
48
49 /** The current journey. */
50 Q_PROPERTY(KPublicTransport::Journey journey READ journey NOTIFY journeyChanged)
51 /** Whether there is journey information available. */
52 Q_PROPERTY(bool hasJourney READ hasJourney NOTIFY journeyChanged)
53 /** Whether the backend supports querying for the journey. */
54 Q_PROPERTY(bool supportsJourney READ supportsJourney NOTIFY supportsJourneyChanged)
55
56 /** Update polling intervals in seconds. */
57 Q_PROPERTY(int positionUpdateInterval READ positionUpdateInterval WRITE setPositionUpdateInterval NOTIFY updateIntervalChanged)
58 Q_PROPERTY(int journeyUpdateInterval READ journeyUpdateInterval WRITE setJourneyUpdateInterval NOTIFY updateIntervalChanged)
59
60public:
61 explicit OnboardStatus(QObject *parent = nullptr);
63
64 enum Status {
65 NotConnected, ///< Wi-Fi monitoring functional, but currently not connected to an onboard Wi-Fi.
66 Onboard, ///< currently connected to a known onboard Wi-Fi system.
67 MissingPermissions, ///< Wi-Fi monitoring not functional due to missing application permissions.
68 WifiNotEnabled, ///< Wi-Fi monitoring is not possible due to Wi-Fi being disabled.
69 LocationServiceNotEnabled, ///< Wi-Fi monitoring is not possible due to the location service being disabled (Android only).
70 NotAvailable, ///< Wi-Fi monitoring is generally not available on this platform.
71 };
72 Q_ENUM(Status)
73 Status status() const;
74
75 float latitude() const;
76 float longitude() const;
77 bool hasPosition() const;
78 bool supportsPosition() const;
79
80 float speed() const;
81 bool hasSpeed() const;
82
83 float heading() const;
84 bool hasHeading() const;
85
86 float altitude() const;
87 bool hasAltitude() const;
88
89 KPublicTransport::Journey journey() const;
90 bool hasJourney() const;
91 bool supportsJourney() const;
92
93 int positionUpdateInterval() const;
94 void setPositionUpdateInterval(int interval);
95 int journeyUpdateInterval() const;
96 void setJourneyUpdateInterval(int interval);
97
98 /** Request one time update of the position status.
99 * For recurring updates, use the polling interval setting instead.
100 */
101 Q_INVOKABLE void requestPosition();
102 /** Request one time journey data update, if available.
103 * For recurring updates, use the polling interval setting instead.
104 */
105 Q_INVOKABLE void requestJourney();
106
107 /** Request application permission needed for Wi-Fi montioring.
108 * Only relevant on Android, does nothing on other platforms.
109 * @see Status::MissingPermissions
110 */
111 Q_INVOKABLE void requestPermissions();
112
113Q_SIGNALS:
114 void statusChanged();
115 void positionChanged();
116 void supportsPositionChanged();
117 void journeyChanged();
118 void supportsJourneyChanged();
119 void updateIntervalChanged();
120
121private:
122 std::unique_ptr<OnboardStatusPrivate> d;
123};
124
125}
126
127#endif // KPUBLICTRANSPORT_ONBOARDSTATUS_H
A journey plan.
Definition journey.h:272
Access to public transport onboard API.
@ LocationServiceNotEnabled
Wi-Fi monitoring is not possible due to the location service being disabled (Android only).
@ MissingPermissions
Wi-Fi monitoring not functional due to missing application permissions.
@ NotConnected
Wi-Fi monitoring functional, but currently not connected to an onboard Wi-Fi.
@ NotAvailable
Wi-Fi monitoring is generally not available on this platform.
@ WifiNotEnabled
Wi-Fi monitoring is not possible due to Wi-Fi being disabled.
@ Onboard
currently connected to a known onboard Wi-Fi system.
Q_SCRIPTABLE CaptureState status()
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 Fri Nov 22 2024 12:10:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.