Changes: fixed buttons and table
[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 {
13   qDebug() << __PRETTY_FUNCTION__;
14   m_location->setUpdateInterval( 1*60*1000 );
15
16   connect( 
17       m_location, SIGNAL( positionUpdated( QGeoPositionInfo ) ),
18       this, SLOT( updateLocation( QGeoPositionInfo ) )
19       );
20
21   m_location->stopUpdates();
22 }
23
24 GpsController::~GpsController()
25 {
26   qDebug() << __PRETTY_FUNCTION__;
27   delete m_location;
28   m_location = 0;
29 }
30
31 void GpsController::updateLocation( QGeoPositionInfo positionInfo )
32 {
33   qDebug() << __PRETTY_FUNCTION__;
34   Location newLocation( positionInfo );
35
36   emit locationChanged( newLocation );
37   m_location->stopUpdates();
38 }
39
40 void GpsController::startGps()
41 {
42   qDebug() << __PRETTY_FUNCTION__;
43   m_location->startUpdates();
44 }