Removed GPSPosition destructor.
[situare] / src / gps / gpsposition.h
index 6d4481d..fdebef7 100644 (file)
 #ifndef GPSPOSITION_H
 #define GPSPOSITION_H
 
-#include <QGeoPositionInfoSource>
+#include <QObject>
 #include <QPointF>
 
-#include "gpspositioninterface.h"
-
-QTM_USE_NAMESPACE
+class GPSPositionPrivate;
 
 /**
-* @brief GPSPosition class use GPS to receive location information.
-*
-* @class GPSPosition gpsposition.h "gps/gpsposition.h"
+* @brief GPSPosition class is an interface for GPS.
 */
-class GPSPosition : public GPSPositionInterface
+class GPSPosition : public QObject
 {
     Q_OBJECT
 
 public:
     /**
-    * @brief Constructor creates GPS source.
+    * @brief Friend class for GPSPosition.
+    */
+    friend class GPSPositionPrivate;
+
+    /**
+    * @brief Constructor.
     *
     * @param parent QObject
     */
     GPSPosition(QObject *parent = 0);
 
     /**
-    * @brief Destructor stops GPS.
+    * @brief GPS position mode.
     */
-    ~GPSPosition();
+    enum Mode {Default, Simulation};
 
 /******************************************************************************
 * MEMBER FUNCTIONS AND SLOTS
@@ -63,9 +64,23 @@ public:
     bool isRunning();
 
     /**
+    * @brief Return last known position.
+    */
+    QPointF lastPosition();
+
+    /**
     * @brief Informs gps to emit last known position.
     */
-    void lastPosition();
+    void requestLastPosition();
+
+    /**
+    * @brief Set GPS mode.
+    *
+    * Modes: default and simulation.
+    * @param mode GPS mode
+    * @param filePath file path to NMEA file if simulation mode is used
+    */
+    void setMode(Mode mode, const QString &filePath = 0);
 
     /**
     * @brief Set GPS update interval
@@ -84,42 +99,35 @@ public:
     */
     void stop();
 
-private:
+/******************************************************************************
+* SIGNALS
+******************************************************************************/
+signals:
     /**
-    * @brief Return bigger accuracy value from latitude and longitude values.
+    * @brief Signal for error.
     *
-    * @param positionInfo geo position info
-    * @return bigger accuracy value, -1 if undefined
+    * @param message error message
     */
-    qreal biggerAccuracy(QGeoPositionInfo positionInfo);
-
-private slots:
+    void error(const QString &message);
 
     /**
-    * @brief Slot for received position update.
+    * @brief Signal for position information.
     *
-    * @param positionInfo Geo position info.
+    * @param latLonCoordinate latitude and longitude values
+    * @param accuracy accuracy in metres
     */
-    void positionUpdated(QGeoPositionInfo positionInfo);
+    void position(QPointF latLonCoordinate, qreal accuracy);
 
     /**
-    * @brief Slot for GPS update request.
+    * @brief Signal for timeout.
     */
-    void update();
-
-    /**
-    * @brief Slot for update timeout.
-    *
-    * Called when request timeout occurs.
-    */
-    void updateTimeout();
+    void timeout();
 
+/*******************************************************************************
+* DATA MEMBERS
+*******************************************************************************/
 private:
-    QGeoPositionInfoSource *m_gpsSource;        ///< GPS position info source
-    bool m_running;                             ///< GPS is running
-    int m_updateInterval;                       ///< GPS update interval
+    GPSPositionPrivate *m_gpsPositionPrivate;   ///< GPSPositionPrivate object
 };
 
-const int DEFAULT_UPDATE_INTERVAL = 5000;       ///< Default update interval
-
-#endif // GPSPOSITION_H
+#endif // GPSPOSITIONINTERFACE_H