Added settings load and save methods to Engine and MainWindow.
[situare] / src / gps / gpsposition.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Jussi Laitinen - jussi.laitinen@ixonos.com
6
7    Situare is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License
9    version 2 as published by the Free Software Foundation.
10
11    Situare is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with Situare; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19    USA.
20 */
21
22 #ifndef GPSPOSITION_H
23 #define GPSPOSITION_H
24
25 #include <QGeoPositionInfoSource>
26 #include <QPointF>
27
28 #include "gpspositioninterface.h"
29
30 QTM_USE_NAMESPACE
31
32 /**
33 * @brief GPSPosition class use GPS to receive location information.
34 *
35 * @class GPSPosition gpsposition.h "gps/gpsposition.h"
36 */
37 class GPSPosition : public GPSPositionInterface
38 {
39     Q_OBJECT
40
41 public:
42     /**
43     * @brief Constructor creates GPS source.
44     *
45     * @param parent QObject
46     */
47     GPSPosition(QObject *parent = 0);
48
49     /**
50     * @brief Destructor stops GPS.
51     */
52     ~GPSPosition();
53
54 /******************************************************************************
55 * MEMBER FUNCTIONS AND SLOTS
56 ******************************************************************************/
57 public:
58     /**
59     * @brief Checks if GPS is running.
60     *
61     * @return true if GPS running, false otherwise
62     */
63     bool isRunning();
64
65     /**
66     * @brief Informs gps to emit last known position.
67     */
68     void lastPosition();
69
70     /**
71     * @brief Set GPS update interval
72     *
73     * @return interval interval in milliseconds
74     */
75     void setUpdateInterval(int interval);
76
77     /**
78     * @brief Start GPS.
79     */
80     void start();
81
82     /**
83     * @brief Stop GPS.
84     */
85     void stop();
86
87 private:
88     /**
89     * @brief Return bigger accuracy value from latitude and longitude values.
90     *
91     * @param positionInfo geo position info
92     * @return bigger accuracy value, -1 if undefined
93     */
94     qreal biggerAccuracy(QGeoPositionInfo positionInfo);
95
96 private slots:
97
98     /**
99     * @brief Slot for received position update.
100     *
101     * @param positionInfo Geo position info.
102     */
103     void positionUpdated(QGeoPositionInfo positionInfo);
104
105     /**
106     * @brief Slot for GPS update request.
107     */
108     void update();
109
110     /**
111     * @brief Slot for update timeout.
112     *
113     * Called when request timeout occurs.
114     */
115     void updateTimeout();
116
117 private:
118     QGeoPositionInfoSource *m_gpsSource;        ///< GPS position info source
119     bool m_running;                             ///< GPS is running
120     int m_updateInterval;                       ///< GPS update interval
121 };
122
123 const int DEFAULT_UPDATE_INTERVAL = 5000;       ///< Default update interval
124
125 #endif // GPSPOSITION_H