Changed gpscontroller to just record the most recent gps coords, and give those when...
[ptas] / zouba / gpscontroller.cpp
1 #include "gpscontroller.h"
2
3 #include <QObject>
4 #include <QGeoPositionInfo>
5 #include <QGeoPositionInfoSource>
6 #include <QDebug>
7
8 QTM_USE_NAMESPACE
9
10 GpsController::GpsController() :
11   m_location( QGeoPositionInfoSource::createDefaultSource(this) ),
12   currentLocation(0)
13 {
14   connect( 
15       m_location, SIGNAL( positionUpdated( QGeoPositionInfo ) ),
16       this, SLOT( updateLocation( QGeoPositionInfo ) )
17   );
18
19   m_location->startUpdates();
20 }
21
22 GpsController::~GpsController()
23 {
24   delete m_location;
25   m_location = 0;
26   delete currentLocation;
27   currentLocation = 0;
28 }
29
30 void GpsController::updateLocation( QGeoPositionInfo positionInfo )
31 {
32   delete currentLocation;
33   currentLocation = new Location( positionInfo );
34 }
35
36 void GpsController::getGps()
37 {
38   if ( currentLocation != 0 ) {
39     emit locationChanged( currentLocation );
40   }
41 }