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