Changed gpscontroller to just record the most recent gps coords, and give those when...
[ptas] / zouba / gpscontroller.cpp
index 618746a..33ba7e6 100644 (file)
@@ -7,38 +7,35 @@
 
 QTM_USE_NAMESPACE
 
-GpsController::~GpsController()
-{
-  qDebug() << __PRETTY_FUNCTION__;
-  delete m_location;
-  m_location = 0;
-}
-
 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->startUpdates();
+}
 
-  m_location->stopUpdates();
+GpsController::~GpsController()
+{
+  delete m_location;
+  m_location = 0;
+  delete currentLocation;
+  currentLocation = 0;
 }
 
 void GpsController::updateLocation( QGeoPositionInfo positionInfo )
 {
-  qDebug() << __PRETTY_FUNCTION__;
-  Location newLocation( positionInfo );
-
-  emit locationChanged( newLocation );
-  m_location->stopUpdates();
+  delete currentLocation;
+  currentLocation = new Location( positionInfo );
 }
 
-void GpsController::startGps()
+void GpsController::getGps()
 {
-  qDebug() << __PRETTY_FUNCTION__;
-  m_location->startUpdates();
+  if ( currentLocation != 0 ) {
+    emit locationChanged( currentLocation );
+  }
 }