1 #include "gpscontroller_p.h"
7 #include <QGeoPositionInfo>
8 #include <QGeoPositionInfoSource>
13 GpsControllerPrivate::GpsControllerPrivate() :
15 m_liveLocation(new Location("livegps")),
16 m_fakeLocationLabel(),
17 m_useFakeLocation(false)
21 GpsControllerPrivate::~GpsControllerPrivate()
25 delete m_liveLocation;
29 void GpsControllerPrivate::init()
31 m_gps = QGeoPositionInfoSource::createDefaultSource(this);
33 m_gps, SIGNAL(positionUpdated(QGeoPositionInfo)),
34 this, SLOT(updateLocation(QGeoPositionInfo))
38 void GpsControllerPrivate::startGps()
40 m_gps->startUpdates();
43 void GpsControllerPrivate::stopGps()
48 QGeoPositionInfoSource *GpsControllerPrivate::gps()
53 void GpsControllerPrivate::setGps(QGeoPositionInfoSource *gps)
58 Location *GpsControllerPrivate::liveLocation()
60 m_mostRecentlyReportedLocation = m_liveLocation;
61 return m_liveLocation;
64 Location *GpsControllerPrivate::fakeLocation()
67 Location *location = locations.location(fakeLocationLabel());
68 m_mostRecentlyReportedLocation = location;
72 QString GpsControllerPrivate::fakeLocationLabel()
74 return m_fakeLocationLabel;
77 void GpsControllerPrivate::setFakeLocationLabel(const QString &label)
79 m_fakeLocationLabel = label;
82 bool GpsControllerPrivate::useFakeLocation()
84 return m_useFakeLocation;
87 void GpsControllerPrivate::setUseFakeLocation(bool useFake)
89 m_useFakeLocation = useFake;
92 void GpsControllerPrivate::updateLocation(QGeoPositionInfo positionInfo)
94 qDebug() << Q_FUNC_INFO;
95 bool wasInvalid = !m_liveLocation->isValid();
96 qDebug() << "wasInvalid/" << wasInvalid;
98 m_liveLocation->setLocation(positionInfo);
100 emit locationChanged(m_liveLocation);
104 Location *GpsControllerPrivate::mostRecentlyReportedLocation()
106 return m_mostRecentlyReportedLocation;