Added comments and debug prints.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Mon, 7 Jun 2010 07:50:34 +0000 (10:50 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Mon, 7 Jun 2010 07:50:34 +0000 (10:50 +0300)
src/gps/geocoordinate.cpp
src/gps/geopositioninfo.cpp
src/gps/gpscommon.h
src/gps/gpsposition.cpp
src/gps/gpspositionprivate.cpp
src/gps/gpspositionprivateliblocation.cpp
src/gps/gpspositionprivateliblocation.h
src/gps/liblocationwrapper.cpp
src/gps/liblocationwrapper.h
src/src.pro

index f0065c4..ec86517 100644 (file)
    USA.
 */
 
+#include <QDebug>
+
 #include "geocoordinate.h"
 #include "gpscommon.h"
 
 GeoCoordinate::GeoCoordinate()
+    : m_latitude(GPS_COORDINATE_UNDEFINED),
+      m_longitude(GPS_COORDINATE_UNDEFINED)
 {
+    qDebug() << __PRETTY_FUNCTION__;
 }
 
 GeoCoordinate::GeoCoordinate(double latitude, double longitude)
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     m_latitude = latitude;
     m_longitude = longitude;
 }
 
-void GeoCoordinate::setLatitude(double latitude)
+bool GeoCoordinate::isValid()
 {
-    m_latitude = latitude;
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if ((m_latitude >= GPS_MIN_LATITUDE) && (m_latitude < GPS_MAX_LATITUDE) &&
+        (m_longitude >= GPS_MIN_LONGITUDE) && (m_longitude < GPS_MAX_LONGITUDE))
+
+        return true;
+    else
+        return false;
 }
 
 double GeoCoordinate::latitude() const
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     return m_latitude;
 }
+
 void GeoCoordinate::setLongitude(double longitude)
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     m_longitude = longitude;
 }
 
-double GeoCoordinate::longitude() const
+void GeoCoordinate::setLatitude(double latitude)
 {
-    return m_longitude;
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_latitude = latitude;
 }
 
-bool GeoCoordinate::isValid()
+double GeoCoordinate::longitude() const
 {
-    if ((m_latitude >= GPS_MIN_LATITUDE) && (m_latitude < GPS_MAX_LATITUDE) &&
-        (m_longitude >= GPS_MIN_LONGITUDE) && (m_longitude < GPS_MAX_LONGITUDE))
+    qDebug() << __PRETTY_FUNCTION__;
 
-        return true;
-    else
-        return false;
+    return m_longitude;
 }
index 7709cf8..fd74615 100644 (file)
 */
 
 #include <QDateTime>
+#include <QDebug>
 
 #include "geopositioninfo.h"
 #include "gpscommon.h"
 #include "geocoordinate.h"
 
 GeoPositionInfo::GeoPositionInfo()
-    : m_isAccurate(false)
+    : m_timestamp(QDateTime()),
+      m_coordinate(GeoCoordinate()),
+      m_horizontalAccuracy(GPS_ACCURACY_UNDEFINED),
+      m_isAccurate(false)
 {
+    qDebug() << __PRETTY_FUNCTION__;
 }
 
 QDateTime GeoPositionInfo::timestamp() const
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     return m_timestamp;
 }
 
 void GeoPositionInfo::setTimestamp(qreal time)
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     m_timestamp = QDateTime::fromTime_t(time);
 }
 
 void GeoPositionInfo::setCoordinate(const GeoCoordinate &coordinate)
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     m_coordinate = coordinate;
 }
 
 GeoCoordinate GeoPositionInfo::coordinate() const
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     return m_coordinate;
 }
 
 bool GeoPositionInfo::isValid()
 {
-   return m_coordinate.isValid();
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return m_coordinate.isValid();
 }
 
 void GeoPositionInfo::setAccuracy(bool accurate, qreal accuracy)
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     if (accuracy < 0)
         m_horizontalAccuracy = GPS_ACCURACY_UNDEFINED;
     else
@@ -67,10 +84,14 @@ void GeoPositionInfo::setAccuracy(bool accurate, qreal accuracy)
 
 qreal GeoPositionInfo::accuracy() const
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     return m_horizontalAccuracy;
 }
 
 bool GeoPositionInfo::isAccurate() const
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     return m_isAccurate;
 }
index 80f76ba..f360eba 100644 (file)
@@ -26,6 +26,7 @@
 #include <QObject>
 
 const int GPS_ACCURACY_UNDEFINED = -1; ///< Value used when accuracy is undefined
+const int GPS_COORDINATE_UNDEFINED = -1000; ///< Value used when coordinate is undefined
 
 const qreal GPS_MAX_LATITUDE = 85.05112877980659237802;  ///< Maximum latitude value
 const qreal GPS_MIN_LATITUDE = -GPS_MAX_LATITUDE; ///< Minimum latitude value
index 3348ca4..5762ca3 100644 (file)
 
 #include "gpsposition.h"
 
-#if defined(Q_WS_MAEMO_5) | defined(Q_WS_SIMULATOR)
+#if defined(Q_WS_MAEMO_5) && !defined(Q_WS_SIMULATOR)
 #include "gpspositionprivateliblocation.h"
+#elif defined(Q_WS_SIMULATOR)
+#include "gpspositionprivate.h"
 #else
 #include "gpspositionprivatestub.h"
 #endif
index e16d34c..76cf330 100644 (file)
@@ -152,9 +152,7 @@ qreal GPSPositionPrivate::accuracy(const QGeoPositionInfo &positionInfo)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    QDateTime timestamp;
-
-    if (!positionInfo.dateTime().isValid())
+    if (!positionInfo.timestamp().isValid())
         return GPS_ACCURACY_UNDEFINED;
 
     if (positionInfo.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
index 74057cb..d328555 100644 (file)
@@ -100,6 +100,8 @@ bool GPSPositionPrivate::isRunning()
 
 QPointF GPSPositionPrivate::lastPosition()
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     GeoPositionInfo positionInfo =  m_liblocationWrapper->lastKnownPosition();
 
     return QPointF(positionInfo.coordinate().longitude(), positionInfo.coordinate().latitude());
index e14f5fe..89dfa2e 100644 (file)
@@ -92,6 +92,13 @@ public:
     void stop();
 
 private:
+    /**
+    * @brief Returns horizontal accuracy.
+    *
+    * @param positionInfo geo position info
+    * @return accuracy value, -1 if undefined. Returns -1 also is timestamp is not valid
+    *         (when using network positioning)
+    */
     qreal accuracy(const GeoPositionInfo &positionInfo);
 
 private slots:
index 2f9fec4..5997ea5 100644 (file)
@@ -38,6 +38,7 @@ LiblocationWrapper::LiblocationWrapper(QObject *parent)
     : QObject(parent),
       m_control(0),
       m_device(0),
+      m_lastKnownPosition(GeoPositionInfo()),
       m_state(LiblocationWrapper::Undefined)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -87,7 +88,7 @@ void LiblocationWrapper::changed(LocationGPSDevice *device, gpointer data)
             }    
         }
         wrapper->setLastKnownPosition(positionInfo);
-        wrapper->locationChanged();
+        emit wrapper->locationChanged(positionInfo);
     }
 }
 
@@ -108,10 +109,7 @@ bool LiblocationWrapper::isRunning()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if (state() == LiblocationWrapper::Running)
-        return true;
-    else
-        return false;
+    return (state() == LiblocationWrapper::Running);
 }
 
 GeoPositionInfo LiblocationWrapper::lastKnownPosition() const
@@ -121,13 +119,6 @@ GeoPositionInfo LiblocationWrapper::lastKnownPosition() const
     return m_lastKnownPosition;
 }
 
-void LiblocationWrapper::locationChanged()
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    emit locationChanged(lastKnownPosition());
-}
-
 void LiblocationWrapper::setLastKnownPosition(const GeoPositionInfo &positionInfo)
 {
     qDebug() << __PRETTY_FUNCTION__;
index 0a81a6a..dbcae05 100644 (file)
@@ -99,7 +99,7 @@ public:
 
 private:
     /**
-    * @brief Called when GPS location changes.
+    * @brief Called from liblocation when GPS location changes.
     *
     * @param device LocationGPSDevice
     * @param data qpointer
@@ -107,19 +107,13 @@ private:
     static void changed(LocationGPSDevice *device, gpointer data);
 
     /**
-    * @brief Called when there is an error on GPS.
+    * @brief Called from liblocation when there is an error on GPS.
     *
     * @param device LocationGPSDevice
     * @param data qpointer
     */
     static void error(LocationGPSDevice *device, gpointer data);
 
-
-    /**
-    * @brief Emits locationChanged signal.
-    */
-    void locationChanged();
-
     /**
     * @brief Sets state.
     *
@@ -145,6 +139,11 @@ signals:
     */
     void locationChanged(const GeoPositionInfo &positionInfo);
 
+    /**
+    * @brief Signal for error.
+    *
+    * @param messgage error message
+    */
     void errorMessage(const QString &message);
 
 
index 87f6238..ff4965b 100644 (file)
@@ -92,16 +92,21 @@ HEADERS += ui/mainwindow.h \
     network/networkaccessmanager.h \
     network/networkhandler.h \
     network/networkcookiejar.h \
-    network/networkreply.h \
-    gps/liblocationwrapper.h \
-    gps/geopositioninfo.h \
-    gps/geocoordinate.h
+    network/networkreply.h
 QT += network \
     webkit
 
 DEFINES += QT_NO_DEBUG_OUTPUT
 
-maemo5 | simulator {
+simulator {
+    SOURCES += network/networkhandlerprivatestub.cpp \
+               gps/gpspositionprivate.cpp
+    HEADERS += network/networkhandlerprivatestub.h \
+               gps/gpspositionprivate.h
+    QT += maemo5
+    CONFIG += mobility
+    MOBILITY += location
+} else:maemo5 {
     armel {
         DEFINES += ARMEL
         INCLUDEPATH += /usr/include/glib-2.0 /usr/lib/glib-2.0/include