Changes: added ut_gpscontroller
[ptas] / zouba / src / gpscontroller.cpp
index 3ca8847..e924da5 100644 (file)
@@ -1,58 +1,48 @@
 #include "gpscontroller.h"
+#include "gpscontroller_p.h"
 
 #include <QObject>
 #include <QGeoPositionInfo>
 #include <QGeoPositionInfoSource>
 #include <QDebug>
 
-QTM_USE_NAMESPACE
-
 GpsController::GpsController() :
-  m_location( QGeoPositionInfoSource::createDefaultSource(this) ),
-  m_currentLocation(0),
-  m_useFakeLocation(false)
+  q( new GpsControllerPrivate() )
 {
-  connect( 
-      m_location, SIGNAL( positionUpdated( QGeoPositionInfo ) ),
-      this, SLOT( updateLocation( QGeoPositionInfo ) )
-  );
-
-  m_location->startUpdates();
+  q->init();
+  q->startGps();
 }
 
-GpsController::~GpsController()
+GpsController::GpsController( GpsControllerPrivate *gpsControllerPrivate ) :
+  q( gpsControllerPrivate )
 {
-  delete m_location;
-  m_location = 0;
-  delete m_currentLocation;
-  m_currentLocation = 0;
+  q->init();
+  q->startGps();
 }
 
-void GpsController::updateLocation( QGeoPositionInfo positionInfo )
+GpsController::~GpsController()
 {
-  delete m_currentLocation;
-  m_currentLocation = new Location( positionInfo );
+  delete q;
 }
 
 void GpsController::getGps()
 {
-  if ( m_currentLocation != 0 ) {
-    emit locationChanged( m_currentLocation );
+  if ( q->currentLocation() != 0 ) {
+    emit locationChanged( q->currentLocation() );
   }
 }
 
 void GpsController::useLiveGps()
 {
-  m_location->startUpdates();
-  m_useFakeLocation=false;
-  m_currentLocation=0;
+  q->setUseFakeLocation( false );
+  q->setCurrentLocation(0);
+  q->startGps();
 }
 
 void GpsController::useFakeGps( Location *fakeLocation )
 {
-  m_location->stopUpdates();
-  m_useFakeLocation=true;
-  delete m_currentLocation;
-  m_currentLocation = new Location( *fakeLocation );
-  emit locationChanged( m_currentLocation );
+  q->stopGps();
+  q->setUseFakeLocation( true );
+  q->setCurrentLocation( fakeLocation );
+  emit locationChanged( q->currentLocation() );
 }