Changes: added GPS class and made app get from location from GPS
[ptas] / zouba / gpscontroller.cpp
diff --git a/zouba/gpscontroller.cpp b/zouba/gpscontroller.cpp
new file mode 100644 (file)
index 0000000..932c0cf
--- /dev/null
@@ -0,0 +1,43 @@
+#include "gpscontroller.h"
+
+#include <QObject>
+#include <QGeoPositionInfo>
+#include <QGeoPositionInfoSource>
+#include <QDebug>
+
+QTM_USE_NAMESPACE
+
+GpsController::~GpsController()
+{
+  qDebug() << __PRETTY_FUNCTION__;
+  delete m_location;
+  m_location = 0;
+}
+
+GpsController::GpsController() :
+  m_location( QGeoPositionInfoSource::createDefaultSource(this) )
+{
+  qDebug() << __PRETTY_FUNCTION__;
+  m_location->setUpdateInterval( 1*60*1000 );
+
+  connect( 
+      m_location, SIGNAL( positionUpdated( QGeoPositionInfo ) ),
+      this, SLOT( updateLocation( QGeoPositionInfo ) )
+      );
+
+  m_location->stopUpdates();
+}
+
+void GpsController::updateLocation( QGeoPositionInfo positionInfo )
+{
+  qDebug() << __PRETTY_FUNCTION__;
+  Location newLocation( positionInfo );
+
+  emit locationChanged( newLocation );
+}
+
+void GpsController::startGps()
+{
+  qDebug() << __PRETTY_FUNCTION__;
+  m_location->startUpdates();
+}