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()
66 Locations *locations = Locations::instance();
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 m_liveLocation->setLocation( positionInfo );
97 Location *GpsControllerPrivate::mostRecentlyReportedLocation()
99 return m_mostRecentlyReportedLocation;