1 #include "gpscontroller.h"
4 #include <QGeoPositionInfo>
5 #include <QGeoPositionInfoSource>
10 GpsController::GpsController() :
11 m_location( QGeoPositionInfoSource::createDefaultSource(this) ),
13 m_useFakeLocation(false)
16 m_location, SIGNAL( positionUpdated( QGeoPositionInfo ) ),
17 this, SLOT( updateLocation( QGeoPositionInfo ) )
20 m_location->startUpdates();
23 GpsController::~GpsController()
27 delete m_currentLocation;
28 m_currentLocation = 0;
31 void GpsController::updateLocation( QGeoPositionInfo positionInfo )
33 delete m_currentLocation;
34 m_currentLocation = new Location( positionInfo );
37 void GpsController::getGps()
39 if ( m_currentLocation != 0 ) {
40 emit locationChanged( m_currentLocation );
44 void GpsController::useLiveGps()
46 m_location->startUpdates();
47 m_useFakeLocation=false;
51 void GpsController::useFakeGps( Location *fakeLocation )
53 m_location->stopUpdates();
54 m_useFakeLocation=true;
55 delete m_currentLocation;
56 m_currentLocation = new Location( *fakeLocation );
57 emit locationChanged( m_currentLocation );