Changes: gps controller uses labels for fake gps
[ptas] / zouba / src / gpscontroller_p.cpp
1 #include "gpscontroller_p.h"
2
3 #include "location.h"
4
5 #include <QObject>
6 #include <QGeoPositionInfo>
7 #include <QGeoPositionInfoSource>
8 #include <QDebug>
9
10 QTM_USE_NAMESPACE
11
12 GpsControllerPrivate::GpsControllerPrivate() :
13   m_gps(0),
14   m_liveLocation( new Location( "livegps" ) ),
15   m_fakeLocationLabel(),
16   m_useFakeLocation(false)
17 {
18 }
19
20 GpsControllerPrivate::~GpsControllerPrivate()
21 {
22   delete m_gps;
23   m_gps = 0;
24   delete m_liveLocation;
25   m_liveLocation = 0;
26 }
27
28 void GpsControllerPrivate::init()
29 {
30   m_gps = QGeoPositionInfoSource::createDefaultSource(this);
31   connect(
32       m_gps, SIGNAL( positionUpdated( QGeoPositionInfo ) ),
33       this, SLOT( updateLocation( QGeoPositionInfo ) )
34   );
35 }
36
37 void GpsControllerPrivate::startGps()
38 {
39   m_gps->startUpdates();
40 }
41
42 void GpsControllerPrivate::stopGps()
43 {
44   m_gps->stopUpdates();
45 }
46
47 QGeoPositionInfoSource *GpsControllerPrivate::gps()
48 {
49   return m_gps;
50 }
51
52 void GpsControllerPrivate::setGps( QGeoPositionInfoSource *gps )
53 {
54   m_gps = gps;
55 }
56
57 Location *GpsControllerPrivate::liveLocation()
58 {
59   return m_liveLocation;
60 }
61
62 QString GpsControllerPrivate::fakeLocationLabel()
63 {
64   return m_fakeLocationLabel;
65 }
66
67 void GpsControllerPrivate::setFakeLocationLabel( const QString &label )
68 {
69   m_fakeLocationLabel = label;
70 }
71
72 bool GpsControllerPrivate::useFakeLocation()
73 {
74   return m_useFakeLocation;
75 }
76
77 void GpsControllerPrivate::setUseFakeLocation( bool useFake )
78 {
79   m_useFakeLocation = useFake;
80 }
81
82 void GpsControllerPrivate::updateLocation( QGeoPositionInfo positionInfo )
83 {
84   m_liveLocation->setLocation( positionInfo );
85 }
86