6#include "onboardstatus.h"
7#include "onboardstatusmanager_p.h"
9#include <KPublicTransport/Journey>
16class OnboardStatusPrivate
19 int positionUpdateInterval = -1;
20 int journeyUpdateInterval = -1;
24OnboardStatus::OnboardStatus(
QObject *parent)
26 , d(new OnboardStatusPrivate)
28 auto mgr = OnboardStatusManager::instance();
29 connect(mgr, &OnboardStatusManager::statusChanged,
this, &OnboardStatus::statusChanged);
30 connect(mgr, &OnboardStatusManager::positionChanged,
this, &OnboardStatus::positionChanged);
31 connect(mgr, &OnboardStatusManager::supportsPositionChanged,
this, &OnboardStatus::supportsPositionChanged);
32 connect(mgr, &OnboardStatusManager::journeyChanged,
this, &OnboardStatus::journeyChanged);
33 connect(mgr, &OnboardStatusManager::supportsJourneyChanged,
this, &OnboardStatus::supportsJourneyChanged);
34 OnboardStatusManager::instance()->registerFrontend(
this);
37OnboardStatus::~OnboardStatus()
39 OnboardStatusManager::instance()->unregisterFrontend(
this);
44 return OnboardStatusManager::instance()->status();
49 return OnboardStatusManager::instance()->currentPosition().latitude;
52float OnboardStatus::longitude()
const
54 return OnboardStatusManager::instance()->currentPosition().longitude;
59 return OnboardStatusManager::instance()->currentPosition().hasCoordinate();
64 return OnboardStatusManager::instance()->supportsPosition();
69 return OnboardStatusManager::instance()->currentPosition().speed;
72bool OnboardStatus::hasSpeed()
const
74 return !std::isnan(
speed());
79 return OnboardStatusManager::instance()->currentPosition().heading;
82bool OnboardStatus::hasHeading()
const
89 return OnboardStatusManager::instance()->currentPosition().altitude;
92bool OnboardStatus::hasAltitude()
const
99 return OnboardStatusManager::instance()->currentJourney();
104 return !OnboardStatusManager::instance()->currentJourney().sections().empty();
109 return OnboardStatusManager::instance()->supportsJourney();
114 return d->positionUpdateInterval;
117void OnboardStatus::setPositionUpdateInterval(
int interval)
119 if (d->positionUpdateInterval == interval) {
123 d->positionUpdateInterval = interval;
124 Q_EMIT updateIntervalChanged();
127int OnboardStatus::journeyUpdateInterval()
const
129 return d->journeyUpdateInterval;
132void OnboardStatus::setJourneyUpdateInterval(
int interval)
134 if (d->journeyUpdateInterval == interval) {
138 d->journeyUpdateInterval = interval;
139 Q_EMIT updateIntervalChanged();
144 OnboardStatusManager::instance()->requestPosition();
149 OnboardStatusManager::instance()->requestJourney();
154 OnboardStatusManager::instance()->requestPermissions();
157#include "moc_onboardstatus.cpp"
float altitude
Current altitude in meters, NAN if unknown.
bool supportsJourney
Whether the backend supports querying for the journey.
bool supportsPosition
Whether the backend supports querying for the geographic position.
Q_INVOKABLE void requestPermissions()
Request application permission needed for Wi-Fi montioring.
float speed
Current speed in km/h.
Q_INVOKABLE void requestPosition()
Request one time update of the position status.
bool hasPosition
Whether the geographic position is currently available.
float heading
Current heading in degree, NAN if unknown.
bool hasJourney
Whether there is journey information available.
int positionUpdateInterval
Update polling intervals in seconds.
KPublicTransport::Journey journey
The current journey.
float latitude
Current geographic position, NAN if not available.
Q_INVOKABLE void requestJourney()
Request one time journey data update, if available.
Query operations and data types for accessing realtime public transport information from online servi...
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)