Added dialogs to change home and work locations.
[ptas] / zouba / gpscontroller.cpp
index 61fbdbc..c8226ac 100644 (file)
@@ -8,37 +8,41 @@
 QTM_USE_NAMESPACE
 
 GpsController::GpsController() :
-  m_location( QGeoPositionInfoSource::createDefaultSource(this) )
+  m_location( QGeoPositionInfoSource::createDefaultSource(this) ),
+  currentLocation(0)
 {
-  qDebug() << __PRETTY_FUNCTION__;
   m_location->setUpdateInterval( 1*60*1000 );
 
   connect( 
       m_location, SIGNAL( positionUpdated( QGeoPositionInfo ) ),
       this, SLOT( updateLocation( QGeoPositionInfo ) )
-      );
+  );
 
-  m_location->stopUpdates();
+  m_location->startUpdates();
 }
 
 GpsController::~GpsController()
 {
-  qDebug() << __PRETTY_FUNCTION__;
   delete m_location;
   m_location = 0;
+  delete currentLocation;
+  currentLocation = 0;
 }
 
 void GpsController::updateLocation( QGeoPositionInfo positionInfo )
 {
-  qDebug() << __PRETTY_FUNCTION__;
-  Location newLocation( positionInfo );
+  qDebug() << "new GPS position";
+
+  delete currentLocation;
+  currentLocation = new Location( positionInfo );
 
-  emit locationChanged( newLocation );
-  m_location->stopUpdates();
+  qDebug() << "from location changed";
+  emit locationChanged( currentLocation );
 }
 
 void GpsController::startGps()
 {
-  qDebug() << __PRETTY_FUNCTION__;
-  m_location->startUpdates();
+  if ( currentLocation != 0 ) {
+    emit locationChanged( currentLocation );
+  }
 }