Minor fixes to gps classes. Added support to QtSimulator.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Thu, 20 May 2010 07:12:00 +0000 (10:12 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Thu, 20 May 2010 07:12:00 +0000 (10:12 +0300)
src/gps/gpsposition.cpp
src/gps/gpsposition.h
src/gps/gpspositionprivate.cpp
src/gps/gpspositionprivate.h
src/gps/gpspositionprivatestub.cpp
src/gps/gpspositionprivatestub.h
src/src.pro

index a7970bd..4d1f12d 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "gpsposition.h"
 
-#ifdef Q_WS_MAEMO_5
+#if defined(Q_WS_MAEMO_5) | defined(Q_WS_SIMULATOR)
 #include "gps/gpspositionprivate.h"
 #else
 #include "gps/gpspositionprivatestub.h"
@@ -73,8 +73,3 @@ void GPSPosition::stop()
 {
     m_gpsPositionPrivate->stop();
 }
-
-void GPSPosition::update()
-{
-    m_gpsPositionPrivate->update();
-}
index b93e1a3..61dae22 100644 (file)
@@ -106,12 +106,6 @@ public:
     */
     void stop();
 
-private slots:
-    /**
-    * @brief Slot for GPS update request.
-    */
-    virtual void update();
-
 /******************************************************************************
 * SIGNALS
 ******************************************************************************/
index 92e61d5..db7efb4 100644 (file)
@@ -61,8 +61,8 @@ void GPSPositionPrivate::setMode(GPSPosition::Mode mode, const QString &filePath
     }
 
     if (m_gpsSource) {
-        connect(m_gpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)),
-                this, SLOT(positionUpdated(QGeoPositionInfo)));
+        connect(m_gpsSource, SIGNAL(positionUpdated(const QGeoPositionInfo &)),
+                this, SLOT(positionUpdated(const QGeoPositionInfo &)));
         connect(m_gpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
 
         m_gpsSource->setUpdateInterval(m_updateInterval);
@@ -96,13 +96,6 @@ bool GPSPositionPrivate::isRunning()
     return m_running;
 }
 
-void GPSPositionPrivate::update()
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    emit m_gpsSource->requestUpdate(DEFAULT_UPDATE_INTERVAL);
-}
-
 QPointF GPSPositionPrivate::lastPosition()
 {
     QGeoCoordinate coordinate = m_gpsSource->lastKnownPosition().coordinate();
@@ -121,7 +114,7 @@ void GPSPositionPrivate::requestLastPosition()
     }
 }
 
-void GPSPositionPrivate::positionUpdated(QGeoPositionInfo positionInfo)
+void GPSPositionPrivate::positionUpdated(const QGeoPositionInfo &positionInfo)
 {
     qDebug() << __PRETTY_FUNCTION__ << positionInfo;
 
@@ -149,11 +142,19 @@ void GPSPositionPrivate::setUpdateInterval(int interval)
     }
 }
 
-qreal GPSPositionPrivate::accuracy(QGeoPositionInfo positionInfo)
+qreal GPSPositionPrivate::accuracy(const QGeoPositionInfo &positionInfo)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if (!positionInfo.dateTime().isValid())
+    QDateTime timestamp;
+
+#ifdef Q_WS_MAEMO_5
+    timestamp = positionInfo.dateTime();
+#else
+    timestamp = positionInfo.timestamp();
+#endif
+
+    if (!timestamp.isValid())
         return GPS_ACCURACY_UNDEFINED;
 
     if (positionInfo.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
index a3b83fd..b946b3f 100644 (file)
@@ -44,7 +44,7 @@ public:
     *
     * @param parent QObject
     */
-    GPSPositionPrivate(QObject *parent = 0);
+    GPSPositionPrivate(QObject *parent);
 
 /******************************************************************************
 * MEMBER FUNCTIONS AND SLOTS
@@ -93,11 +93,6 @@ public:
     */
     void stop();
 
-    /**
-    * @brief GPS update request.
-    */
-    void update();
-
 private:
     /**
     * @brief Return horizontal accuracy
@@ -106,7 +101,7 @@ private:
     * @return accuracy value, -1 if undefined. Returns -1 also is timestamp is not valid
     *         (when using network positioning)
     */
-    qreal accuracy(QGeoPositionInfo positionInfo);
+    qreal accuracy(const QGeoPositionInfo &positionInfo);
 
 private slots:
 
@@ -115,7 +110,7 @@ private slots:
     *
     * @param positionInfo Geo position info.
     */
-    void positionUpdated(QGeoPositionInfo positionInfo);
+    void positionUpdated(const QGeoPositionInfo &positionInfo);
 
     /**
     * @brief Slot for update timeout.
index 799835e..bbd4555 100644 (file)
@@ -27,7 +27,6 @@
 GPSPositionPrivate::GPSPositionPrivate(QObject *parent)
     : QObject(parent)
 {
-    m_parent = static_cast<GPSPosition*>(parent);
 }
 
 bool GPSPositionPrivate::isRunning()
@@ -62,11 +61,6 @@ void GPSPositionPrivate::stop()
     qDebug() << __PRETTY_FUNCTION__;
 }
 
-void GPSPositionPrivate::update()
-{
-    qDebug() << __PRETTY_FUNCTION__;
-}
-
 QPointF GPSPositionPrivate::lastPosition()
 {
     qDebug() << __PRETTY_FUNCTION__;
index 8f77f74..97aff93 100644 (file)
@@ -44,7 +44,7 @@ public:
     *
     * @param parent QObject
     */
-    GPSPositionPrivate(QObject *parent = 0);
+    GPSPositionPrivate(QObject *parent);
 
 /******************************************************************************
 * MEMBER FUNCTIONS AND SLOTS
@@ -98,19 +98,6 @@ public:
     * DOES NOTHING.
     */
     void stop();
-
-    /**
-    * @brief GPS update request.
-    *
-    * DOES NOTHING.
-    */
-    void update();
-
-/*******************************************************************************
- * DATA MEMBERS
- ******************************************************************************/
-private:
-    GPSPosition *m_parent;                      ///< Parent object
 };
 
 #endif // GPSPOSITIONMOCKUP_H
index 132c441..81d3bae 100644 (file)
@@ -88,14 +88,7 @@ QT += network \
 
 DEFINES += QT_NO_DEBUG_OUTPUT
 
-!maemo5 {
-    SOURCES += gps/gpspositionprivatestub.cpp
-    HEADERS += gps/gpspositionprivatestub.h
-    message(QJson built in)
-    message(Make sure you have QJson development headers installed)
-    message(install headers with: sudo apt-get install libqjson-dev)
-}
-maemo5 {
+maemo5 | simulator {
     SOURCES += gps/gpspositionprivate.cpp
     HEADERS += gps/gpspositionprivate.h
     QT += maemo5
@@ -111,6 +104,13 @@ maemo5 {
     message(Make sure you have QtMobility development headers installed)
     message(install headers with: apt-get install libqtm-dev)
 }
+else {
+    SOURCES += gps/gpspositionprivatestub.cpp
+    HEADERS += gps/gpspositionprivatestub.h
+    message(QJson built in)
+    message(Make sure you have QJson development headers installed)
+    message(install headers with: sudo apt-get install libqjson-dev)
+}
 
 
 # -----------------------------------------------------------------