Added new settings button to set a fake current location ('work' in the first instance).
[ptas] / zouba / src / gpscontroller.cpp
index 33ba7e6..3ca8847 100644 (file)
@@ -9,7 +9,8 @@ QTM_USE_NAMESPACE
 
 GpsController::GpsController() :
   m_location( QGeoPositionInfoSource::createDefaultSource(this) ),
-  currentLocation(0)
+  m_currentLocation(0),
+  m_useFakeLocation(false)
 {
   connect( 
       m_location, SIGNAL( positionUpdated( QGeoPositionInfo ) ),
@@ -23,19 +24,35 @@ GpsController::~GpsController()
 {
   delete m_location;
   m_location = 0;
-  delete currentLocation;
-  currentLocation = 0;
+  delete m_currentLocation;
+  m_currentLocation = 0;
 }
 
 void GpsController::updateLocation( QGeoPositionInfo positionInfo )
 {
-  delete currentLocation;
-  currentLocation = new Location( positionInfo );
+  delete m_currentLocation;
+  m_currentLocation = new Location( positionInfo );
 }
 
 void GpsController::getGps()
 {
-  if ( currentLocation != 0 ) {
-    emit locationChanged( currentLocation );
+  if ( m_currentLocation != 0 ) {
+    emit locationChanged( m_currentLocation );
   }
 }
+
+void GpsController::useLiveGps()
+{
+  m_location->startUpdates();
+  m_useFakeLocation=false;
+  m_currentLocation=0;
+}
+
+void GpsController::useFakeGps( Location *fakeLocation )
+{
+  m_location->stopUpdates();
+  m_useFakeLocation=true;
+  delete m_currentLocation;
+  m_currentLocation = new Location( *fakeLocation );
+  emit locationChanged( m_currentLocation );
+}