1 #include "gpscontroller_p.h"
6 #include <QGeoPositionInfo>
7 #include <QGeoPositionInfoSource>
12 GpsControllerPrivate::GpsControllerPrivate() :
15 m_useFakeLocation(false)
19 GpsControllerPrivate::~GpsControllerPrivate()
23 delete m_currentLocation;
24 m_currentLocation = 0;
27 void GpsControllerPrivate::init()
29 m_gps = QGeoPositionInfoSource::createDefaultSource(this);
31 m_gps, SIGNAL( positionUpdated( QGeoPositionInfo ) ),
32 this, SLOT( updateLocation( QGeoPositionInfo ) )
36 void GpsControllerPrivate::startGps()
38 m_gps->startUpdates();
41 void GpsControllerPrivate::stopGps()
46 QGeoPositionInfoSource *GpsControllerPrivate::gps()
51 void GpsControllerPrivate::setGps( QGeoPositionInfoSource *gps )
56 Location *GpsControllerPrivate::currentLocation()
58 return m_currentLocation;
61 void GpsControllerPrivate::setCurrentLocation( Location *location )
63 if ( m_currentLocation && m_currentLocation->label() == "livegps" ) {
64 delete m_currentLocation;
67 m_currentLocation = location;
70 bool GpsControllerPrivate::useFakeLocation()
72 return m_useFakeLocation;
75 void GpsControllerPrivate::setUseFakeLocation( bool useFake )
77 // delete previous GPS if it was live and we're switching to fake
78 if ( m_currentLocation && m_currentLocation->label() == "livegps" ) {
79 delete m_currentLocation;
80 m_currentLocation = 0;
82 m_useFakeLocation = useFake;
85 void GpsControllerPrivate::updateLocation( QGeoPositionInfo positionInfo )
87 if ( m_currentLocation && m_currentLocation->label() == "livegps" ) {
88 delete m_currentLocation;
90 m_currentLocation = new Location( positionInfo, "livegps" );