1 #include "gpscontroller.h"
2 #include "gpscontroller_p.h"
5 #include <QGeoPositionInfo>
6 #include <QGeoPositionInfoSource>
9 GpsController::GpsController() :
10 q(new GpsControllerPrivate())
15 connect(q, SIGNAL(locationChanged(Location*)), SIGNAL(locationChanged(Location*)));
18 GpsController::GpsController(GpsControllerPrivate *gpsControllerPrivate) :
19 q(gpsControllerPrivate)
24 connect(q, SIGNAL(locationChanged(Location*)), SIGNAL(locationChanged(Location*)));
27 GpsController::~GpsController()
32 void GpsController::getGps()
34 qDebug() << Q_FUNC_INFO;
37 if (q->useFakeLocation()) {
38 location = q->fakeLocation();
40 location = q->liveLocation();
43 if (location->isValid()) {
44 emit locationChanged(location);
48 void GpsController::useLiveGps()
50 q->setUseFakeLocation(false);
52 emit locationChanged(q->liveLocation());
55 void GpsController::useFakeGps(const QString &fakeLocationLabel)
57 qDebug() << "using fake gps (" << fakeLocationLabel << ")";
59 q->setFakeLocationLabel(fakeLocationLabel);
60 Location *fakeLocation = q->fakeLocation();
62 if (fakeLocation == 0) {
63 qDebug() << "invalid fake location label; cannot use fake location";
66 q->setUseFakeLocation(true);
67 emit locationChanged(fakeLocation);