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 );
+ }
}