Merge branch 'master' into cookies_refactored
authorlampehe-local <henri.lampela@ixonos.com>
Fri, 28 May 2010 05:20:20 +0000 (08:20 +0300)
committerlampehe-local <henri.lampela@ixonos.com>
Fri, 28 May 2010 05:20:20 +0000 (08:20 +0300)
Conflicts:
src/common.h
src/src.pro

62 files changed:
doc/test_cases/functionality-tests.doc
images.qrc
res/images/user_info_item_bottom.png [new file with mode: 0755]
res/images/user_info_item_middle.png [new file with mode: 0755]
res/images/user_info_item_top.png [new file with mode: 0755]
res/images/zoom_in.png [changed mode: 0755->0644]
res/images/zoom_out.png [changed mode: 0755->0644]
scripts/run_unit_tests.sh
src/engine/engine.cpp
src/engine/engine.h
src/gps/gpspositionprivate.cpp
src/map/mapengine.cpp
src/map/mapengine.h
src/map/mapfetcher.cpp
src/map/mapfetcher.h
src/network/networkaccessmanager.cpp [new file with mode: 0644]
src/network/networkaccessmanager.h [new file with mode: 0644]
src/network/networkhandler.cpp [new file with mode: 0644]
src/network/networkhandler.h [new file with mode: 0644]
src/network/networkhandlerprivate.cpp [new file with mode: 0644]
src/network/networkhandlerprivate.h [new file with mode: 0644]
src/network/networkhandlerprivatestub.cpp [new file with mode: 0644]
src/network/networkhandlerprivatestub.h [new file with mode: 0644]
src/network/networkreply.cpp [new file with mode: 0644]
src/network/networkreply.h [new file with mode: 0644]
src/situareservice/imagefetcher.cpp
src/situareservice/imagefetcher.h
src/situareservice/situareservice.cpp
src/situareservice/situareservice.h
src/src.pro
src/ui/friendlistitem.cpp
src/ui/imagebutton.cpp
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/panelcommon.h
src/ui/userinfo.cpp
src/ui/userinfo.h
src/ui/userinfopanel.cpp
src/ui/userinfopanel.h
src/ui/zoombutton.cpp
src/ui/zoombutton.h
src/ui/zoombuttonpanel.cpp
src/ui/zoombuttonpanel.h
tests/map/friendgroupitem/friendgroupitem.pro
tests/map/friendlocationitem/friendlocationitem.pro
tests/map/gpslocationitem/gpslocationitem.pro
tests/map/mapengine/mapengine.pro
tests/map/mapengine/testmapengine.cpp
tests/map/mapscene/mapscene.pro
tests/map/maptile/maptile.pro
tests/map/mapview/mapview.pro
tests/map/ownlocationitem/ownlocationitem.pro
tests/map/uselastlocation/testuselastlocation.cpp [deleted file]
tests/map/uselastlocation/uselastlocation.pro [deleted file]
tests/tests.pro
tests/ui/friendlist/friendlist.pro
tests/ui/friendlist/situare_user.gif [new file with mode: 0644]
tests/ui/friendlist/testfriendlist.cpp
tests/ui/sidepanel/sidepanel.pro [new file with mode: 0644]
tests/ui/sidepanel/testsidepanel.pro [deleted file]
tests/ui/zoombuttonpanel/testzoombuttonpanel.cpp [deleted file]
tests/ui/zoombuttonpanel/zoombuttonpanel.pro [deleted file]

index 99b595b..c471008 100644 (file)
Binary files a/doc/test_cases/functionality-tests.doc and b/doc/test_cases/functionality-tests.doc differ
index 5a835e7..5d39858 100644 (file)
@@ -23,6 +23,9 @@
         <file>res/images/list_item_bottom.png</file>
         <file>res/images/list_item_middle.png</file>
         <file>res/images/list_item_top.png</file>
+           <file>res/images/user_info_item_bottom.png</file>
+        <file>res/images/user_info_item_middle.png</file>
+        <file>res/images/user_info_item_top.png</file>
         <file>res/images/sliding_bar_left_test.png</file>
         <file>res/images/userpanel_mask.png</file>
         <file>res/images/sliding_bar_right_test.png</file>
diff --git a/res/images/user_info_item_bottom.png b/res/images/user_info_item_bottom.png
new file mode 100755 (executable)
index 0000000..7a935bc
Binary files /dev/null and b/res/images/user_info_item_bottom.png differ
diff --git a/res/images/user_info_item_middle.png b/res/images/user_info_item_middle.png
new file mode 100755 (executable)
index 0000000..10098a3
Binary files /dev/null and b/res/images/user_info_item_middle.png differ
diff --git a/res/images/user_info_item_top.png b/res/images/user_info_item_top.png
new file mode 100755 (executable)
index 0000000..96e6b70
Binary files /dev/null and b/res/images/user_info_item_top.png differ
old mode 100755 (executable)
new mode 100644 (file)
index 0c8fd51..cc159de
Binary files a/res/images/zoom_in.png and b/res/images/zoom_in.png differ
old mode 100755 (executable)
new mode 100644 (file)
index 8b45cb5..8946b29
Binary files a/res/images/zoom_out.png and b/res/images/zoom_out.png differ
index 7af810e..06fb597 100755 (executable)
@@ -29,7 +29,7 @@ if [[ -d $REPORT_PATH && -d $UNIT_TESTS_ROOT_DIR ]]; then
     echo "" >> $REPORT
 
     # find all test .pro files pahts, cut .pro extension
-    UNIT_TEST_PROJECTS=(`find $UNIT_TESTS_ROOT_DIR_ABSOLUTE | egrep .pro$ | sed -e s/.pro//g`)
+    UNIT_TEST_PROJECTS=(`find $UNIT_TESTS_ROOT_DIR_ABSOLUTE | egrep \.pro$ | sed -e s,[^/]pro,,g`)
 
     echo "###################################################"
     echo "All unit test executables will be deleted"
@@ -114,6 +114,15 @@ if [[ -d $REPORT_PATH && -d $UNIT_TESTS_ROOT_DIR ]]; then
     # remove temporary files
     rm $REPORT_PATH_ABSOLUTE/temp_*.txt
 
+    # remove all unit test binaries so they doesn't accidentally get into repository
+    for BINARY in "${UNIT_TEST_PROJECTS[@]}"
+    do
+        # remove only if file really exists
+        if [ -a $BINARY ]; then
+            rm $BINARY
+        fi
+    done
+
     # tell that script reached the end
     echo "" >> $REPORT
     echo "All done!" >> $REPORT
index 16a42a7..4700c20 100644 (file)
@@ -4,7 +4,7 @@
 
         Kaj Wallin - kaj.wallin@ixonos.com
         Henri Lampela - henri.lampela@ixonos.com
-        Jussi Laitinen jussi.laitinen@ixonos.com
+        Jussi Laitinen - jussi.laitinen@ixonos.com
         Sami Rämö - sami.ramo@ixonos.com
 
     Situare is free software; you can redistribute it and/or
@@ -34,6 +34,7 @@
 
 const QString SETTINGS_GPS_ENABLED = "GPS_ENABLED";
 const QString SETTINGS_AUTO_CENTERING_ENABLED = "AUTO_CENTERING_ENABLED";
+const int DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE = 12;
 
 SituareEngine::SituareEngine(QMainWindow *parent)
     : QObject(parent),
@@ -77,25 +78,13 @@ SituareEngine::SituareEngine(QMainWindow *parent)
     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
             m_mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
 
+    initializeGpsAndAutocentering();
+
     // signals connected, now it's time to show the main window
     // but init the MapEngine before so starting location is set
     m_mapEngine->init();
     m_ui->show();
 
-    QSettings settings(DIRECTORY_NAME, FILE_NAME);
-    QVariant gpsEnabled = settings.value(SETTINGS_GPS_ENABLED);
-    QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);
-
-    // set features on / off based on settings
-    changeAutoCenteringSetting(autoCenteringEnabled.toBool());
-    enableGPS(gpsEnabled.toBool());
-
-    // show messages at startup if features are enabled automatically
-    if (gpsEnabled.toBool())
-        m_ui->showMaemoInformationBox(tr("GPS enabled"));
-    if (gpsEnabled.toBool() && autoCenteringEnabled.toBool())
-        m_ui->showMaemoInformationBox(tr("Auto centering enabled"));
-
     m_facebookAuthenticator->start();
 }
 
@@ -119,6 +108,7 @@ void SituareEngine::changeAutoCenteringSetting(bool enabled)
     enableAutoCentering(enabled);
 }
 
+
 void SituareEngine::disableAutoCentering()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -166,9 +156,40 @@ void SituareEngine::error(const QString &error)
 void SituareEngine::fetchUsernameFromSettings()
 {
     qDebug() << __PRETTY_FUNCTION__;
+
     m_ui->setUsername(m_facebookAuthenticator->loadUsername());
 }
 
+void SituareEngine::initializeGpsAndAutocentering()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    QSettings settings(DIRECTORY_NAME, FILE_NAME);
+    QVariant gpsEnabled = settings.value(SETTINGS_GPS_ENABLED);
+    QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);     
+
+    if (gpsEnabled.toString().isEmpty()) { // First start. Situare.conf file does not exists
+
+        connect(m_gps, SIGNAL(position(QPointF,qreal)),
+                this, SLOT(setFirstStartZoomLevel(QPointF,qreal)));
+
+        changeAutoCenteringSetting(true);
+        enableGPS(true);
+
+        m_ui->showMaemoInformationBox(tr("GPS enabled"));
+        m_ui->showMaemoInformationBox(tr("Auto centering enabled"));
+    } else { // Normal start
+        changeAutoCenteringSetting(autoCenteringEnabled.toBool());
+        enableGPS(gpsEnabled.toBool());
+
+        if (gpsEnabled.toBool())
+            m_ui->showMaemoInformationBox(tr("GPS enabled"));
+
+        if (gpsEnabled.toBool() && autoCenteringEnabled.toBool())
+            m_ui->showMaemoInformationBox(tr("Auto centering enabled"));        
+    } 
+}
+
 void SituareEngine::invalidCredentials()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -253,6 +274,20 @@ void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
         m_situareService->updateLocation(m_mapEngine->centerGeoCoordinate(), status, publish);
 }
 
+void SituareEngine::setFirstStartZoomLevel(QPointF latLonCoordinate, qreal accuracy)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    Q_UNUSED(latLonCoordinate);
+    Q_UNUSED(accuracy);
+
+    if (m_autoCenteringEnabled) // autocentering is disabled when map is scrolled        
+        m_mapEngine->setZoomLevel(DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE);
+
+    disconnect(m_gps, SIGNAL(position(QPointF,qreal)),
+               this, SLOT(setFirstStartZoomLevel(QPointF,qreal)));
+}
+
 void SituareEngine::signalsFromFacebookAuthenticator()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -341,6 +376,9 @@ void SituareEngine::signalsFromMainWindow()
     connect(m_ui, SIGNAL(refreshUserData()),
             this, SLOT(refreshUserData()));
 
+    connect(m_ui, SIGNAL(findUser(QPointF)),
+            m_mapEngine, SLOT(setViewLocation(QPointF)));
+
     // signals from friend list tab
     connect(m_ui, SIGNAL(findFriend(QPointF)),
             m_mapEngine, SLOT(setViewLocation(QPointF)));
index 11dbff3..d7781a5 100644 (file)
@@ -27,6 +27,7 @@
 #define ENGINE_H
 
 #include <QObject>
+#include <QPointF>
 
 class QMainWindow;
 
@@ -137,6 +138,12 @@ public slots:
 
 private:
     /**
+      * @brief Read settings and determine whether to use GPS and autocentering.
+      * When values does not found on the settings, GPS and autocentering are enabled as a default.
+      */
+    void initializeGpsAndAutocentering();
+
+    /**
       * @brief Connect signals coming from Facdebook authenticator
       */
     void signalsFromFacebookAuthenticator();
@@ -194,6 +201,15 @@ private slots:
     void enableGPS(bool enabled);
 
     /**
+     * @brief Sets zoom level to default when first GPS location is received if autocentering
+     * is enabled.
+     *
+     * @param latLonCoordinate own location
+     * @param accuracy accuracy of GPS location
+     */
+    void setFirstStartZoomLevel(QPointF latLonCoordinate, qreal accuracy);
+    
+    /**
     * @brief Slot for intercepting signal when credentials are invalid
     *
     */
@@ -229,7 +245,6 @@ private:
     MainWindow *m_ui;                                ///< Instance of the MainWindow UI
     MapEngine *m_mapEngine;                          ///< MapEngine
     SituareService *m_situareService;  ///< Instance of the situare server communication service
-
 };
 
 #endif // ENGINE_H
index db7efb4..4c4d60c 100644 (file)
@@ -47,11 +47,15 @@ void GPSPositionPrivate::setMode(GPSPosition::Mode mode, const QString &filePath
         delete m_gpsSource;
     }
 
-    if (mode == GPSPosition::Default)
+    if (mode == GPSPosition::Default) {
         m_gpsSource = QGeoPositionInfoSource::createDefaultSource(this);
 
-    if ((!m_gpsSource) || (mode == GPSPosition::Simulation)) {
-        qDebug() << "Using NMEA info source.";
+        if (!m_gpsSource) {
+            emit m_parent->error(tr("Unable to use GPS"));
+            return;
+        }
+    }
+    else if (mode == GPSPosition::Simulation) {
         QNmeaPositionInfoSource *nmeaSource = new QNmeaPositionInfoSource(
                 QNmeaPositionInfoSource::SimulationMode, this);
         QFile *logFile = new QFile(filePath, this);
index d8ad37e..19f49ba 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <QtAlgorithms>
 #include <QDebug>
-#include <QNetworkAccessManager>
 #include <QString>
 #include <QStringList>
 #include <QUrl>
@@ -42,6 +41,7 @@
 #include "ownlocationitem.h"
 
 #include "mapengine.h"
+#include "network/networkaccessmanager.h"
 
 MapEngine::MapEngine(QObject *parent)
     : QObject(parent),
@@ -56,7 +56,7 @@ MapEngine::MapEngine(QObject *parent)
 
     m_mapScene = new MapScene(this);
 
-    m_mapFetcher = new MapFetcher(new QNetworkAccessManager(this), this);
+    m_mapFetcher = new MapFetcher(NetworkAccessManager::instance(), this);
     connect(this, SIGNAL(fetchImage(int, int, int)),
             m_mapFetcher, SLOT(enqueueFetchMapImage(int, int, int)));
     connect(m_mapFetcher, SIGNAL(mapImageReceived(int, int, int, QPixmap)),
@@ -244,16 +244,13 @@ void MapEngine::init()
     QPointF startLocation;
     QSettings settings(DIRECTORY_NAME, FILE_NAME);
 
-    if (settings.value(MAP_LAST_POSITION, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toString() ==
-        ERROR_VALUE_NOT_FOUND_ON_SETTINGS ||
-        settings.value(MAP_LAST_ZOOMLEVEL, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toString() ==
-        ERROR_VALUE_NOT_FOUND_ON_SETTINGS) {
+    if (settings.value(MAP_LAST_POSITION, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toString()
+        == ERROR_VALUE_NOT_FOUND_ON_SETTINGS || settings.value(MAP_LAST_ZOOMLEVEL,
+        ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toString() == ERROR_VALUE_NOT_FOUND_ON_SETTINGS) {
 
         startLocation = QPointF(DEFAULT_LONGITUDE, DEFAULT_LATITUDE);
         m_zoomLevel = DEFAULT_START_ZOOM_LEVEL;
-    }
-
-    else {
+    } else {
         m_zoomLevel = settings.value(MAP_LAST_ZOOMLEVEL, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toInt();
         startLocation = settings.value(MAP_LAST_POSITION,
                                        ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toPointF();
@@ -348,6 +345,14 @@ void MapEngine::setLocation(QPoint sceneCoordinate)
     }
 }
 
+void MapEngine::setZoomLevel(int newZoomLevel)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_zoomLevel = newZoomLevel;
+    emit zoomLevelChanged(m_zoomLevel);
+}
+
 void MapEngine::setViewLocation(QPointF latLonCoordinate)
 {
     qDebug() << __PRETTY_FUNCTION__;
index e80061a..1f2d5ba 100644 (file)
@@ -128,6 +128,13 @@ public:
     QGraphicsScene* scene();
 
     /**
+    * @brief Sets new zoom level
+    *
+    * @return newZoomLevel value that is set to new zoom level
+    */
+    void setZoomLevel(const int newZoomLevel);
+
+    /**
     * @brief Return tile path created from tile values.
     *
     * @param zoomLevel tile's zoom level
@@ -175,7 +182,7 @@ public slots:
     *
     * @param latLonCoordinate Latitude & longitude coordinates for location
     */
-    void setViewLocation(QPointF latLonCoordinate);
+    void setViewLocation(QPointF latLonCoordinate);    
 
     /**
     * @brief Slot for view resizing.
index 9a01db8..9e8726f 100644 (file)
 
 #include "mapfetcher.h"
 #include "mapcommon.h"
+#include "network/networkaccessmanager.h"
 
 const int MAX_PARALLEL_DOWNLOADS = 2; ///< Max simultaneous parallel downloads
 const int NOT_FOUND = -1; ///< Return value if matching request is not found from the list
 
-MapFetcher::MapFetcher(QNetworkAccessManager *manager, QObject *parent)
+MapFetcher::MapFetcher(NetworkAccessManager *manager, QObject *parent)
     : QObject(parent)
     , m_pendingRequestsSize(0)
     , m_fetchMapImagesTimerRunning(false)
@@ -108,35 +109,36 @@ void MapFetcher::downloadFinished(QNetworkReply *reply)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if (reply->error() == QNetworkReply::NoError) {
-        QImage image;
-        QUrl url = reply->url();
+    if (m_currentDownloads.contains(reply)) {
 
-        if (!image.load(reply, 0))
-            image = QImage();
+        if (reply->error() == QNetworkReply::NoError) {
+            QImage image;
+            QUrl url = reply->url();
 
-        int zoomLevel;
-        int x;
-        int y;
-        parseURL(url, &zoomLevel, &x, &y);
+            if (!image.load(reply, 0))
+                image = QImage();
 
-        emit mapImageReceived(zoomLevel, x, y, QPixmap::fromImage(image));
-    }
-    else {
-        emit error(reply->errorString());
-    }
+            int zoomLevel;
+            int x;
+            int y;
+            parseURL(url, &zoomLevel, &x, &y);
 
-    m_currentDownloads.removeAll(reply);
-    reply->deleteLater();
-    startNextDownload();
+            emit mapImageReceived(zoomLevel, x, y, QPixmap::fromImage(image));
+        }
+        else {
+            emit error(reply->errorString());
+        }
+
+        m_currentDownloads.removeAll(reply);
+        reply->deleteLater();
+        startNextDownload();
+    }
 }
 
 void MapFetcher::enqueueFetchMapImage(int zoomLevel, int x, int y)
 {
     QUrl url = buildURL(zoomLevel, QPoint(x, y));
 
-    qDebug() << __PRETTY_FUNCTION__ << "url:" << url.toString();
-
     // check if new request is already in the list and move it to the begin of the list...
     bool found = false;
     for (int i = 0; i < m_pendingRequests.size(); i++) {
index 9edbfb5..702f953 100644 (file)
@@ -27,6 +27,7 @@
 #include <QNetworkAccessManager>
 
 #include "maptilerequest.h"
+#include "network/networkaccessmanager.h"
 
 class QNetworkReply;
 class QUrl;
@@ -48,7 +49,7 @@ public:
     * @param manager Network access manager
     * @param parent parent object
     */
-    MapFetcher(QNetworkAccessManager *manager, QObject *parent = 0);
+    MapFetcher(NetworkAccessManager *manager, QObject *parent = 0);
 
 /*******************************************************************************
  * CLASS SPECIFIC MEMBER FUNCTIONS AND SLOTS
@@ -191,7 +192,7 @@ private:
     QList<QNetworkReply*> m_currentDownloads; ///< List of current downloads
     int m_pendingRequestsSize; ///< Max number of pending requests
     bool m_fetchMapImagesTimerRunning; ///< is the singleshot timer already running
-    QNetworkAccessManager *m_manager; ///< Network access manager
+    NetworkAccessManager *m_manager; ///< Network access manager
     QList<MapTileRequest> m_pendingRequests; ///< List of map image fetching requests
 };
 
diff --git a/src/network/networkaccessmanager.cpp b/src/network/networkaccessmanager.cpp
new file mode 100644 (file)
index 0000000..76757d5
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#include <QNetworkRequest>
+#include <QNetworkAccessManager>
+#include <QDebug>
+
+#include "networkhandler.h"
+#include "networkaccessmanager.h"
+#include "networkreply.h"
+
+NetworkAccessManager *NetworkAccessManager::m_instance = 0;
+
+NetworkAccessManager::NetworkAccessManager()
+    : m_networkHandler(0),
+      m_networkAccessManagerPrivate(0)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_networkHandler = new NetworkHandler(this);
+    m_networkAccessManagerPrivate = new QNetworkAccessManager(this);
+
+    connect(m_networkHandler, SIGNAL(connected()),
+            this, SLOT(connected()));
+
+    connect(m_networkAccessManagerPrivate, SIGNAL(finished(QNetworkReply*)),
+            this, SLOT(downloadFinished(QNetworkReply*)));
+}
+
+QAbstractNetworkCache *NetworkAccessManager::cache() const
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return m_networkAccessManagerPrivate->cache();
+}
+
+void NetworkAccessManager::connected()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    //Loop through all requests and calls get method.
+    foreach (const QNetworkRequest &request, m_requestQueue) {
+        QNetworkReply *reply = m_networkAccessManagerPrivate->get(request);
+        m_temporaryReplyQueue.insert(request.url().toString(), reply);
+    }
+
+    m_requestQueue.clear();
+}
+
+void NetworkAccessManager::downloadFinished(QNetworkReply *reply)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    QString key = m_temporaryReplyQueue.key(reply, "");
+
+    //Replace offline reply object's content with server reply's content
+    if (!key.isEmpty()) {
+        QNetworkReply *offlineReply = m_offlineReplyQueue.value(key, 0);
+
+        if (offlineReply) {
+            memmove(offlineReply, reply, sizeof(QNetworkReply));
+            m_offlineReplyQueue.remove(key);
+            m_temporaryReplyQueue.remove(key);
+            emit finished(offlineReply);
+        }
+    }
+    //Forward online request's reply
+    else {
+        emit finished(reply);
+    }
+}
+
+QNetworkReply *NetworkAccessManager::get(const QNetworkRequest &request)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    //Disconnected from network, queue request and return empty reply.
+    if (!m_networkHandler->isConnected()) {
+        m_requestQueue.append(request);
+        m_networkHandler->connect();
+        QNetworkReply *reply = new NetworkReply(request, this);
+        m_offlineReplyQueue.insert(request.url().toString(), reply);
+        return reply;
+    }
+    //Connected, use normal get method.
+    else {
+        return m_networkAccessManagerPrivate->get(request);
+    }
+}
+
+
+NetworkAccessManager *NetworkAccessManager::instance()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if (!m_instance)
+        m_instance = new NetworkAccessManager();
+
+    return m_instance;
+}
+
+void NetworkAccessManager::setCache(QAbstractNetworkCache *cache)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_networkAccessManagerPrivate->setCache(cache);
+}
diff --git a/src/network/networkaccessmanager.h b/src/network/networkaccessmanager.h
new file mode 100644 (file)
index 0000000..10a2ae3
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#ifndef NETWORKACCESSMANAGER_H
+#define NETWORKACCESSMANAGER_H
+
+#include <QList>
+#include <QHash>
+#include <QNetworkReply>
+#include <QNetworkRequest>
+#include <QAbstractNetworkCache>
+
+class NetworkHandler;
+class QNetworkAccessManager;
+
+/**
+* @brief NetworkAccessManager class.
+*
+* This class handles network requests and receives network replies.
+* NetworkAccessManager queues requests when disconnected from network
+* and makes requests when connected to network.
+*/
+class NetworkAccessManager : public QObject
+{
+    Q_OBJECT
+
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public:
+    /**
+    * @brief Returns instance of NetworkAccessManager.
+    *
+    * Creates instance if not created.
+    */
+    static NetworkAccessManager *instance();
+
+    /**
+    * @brief Makes request and return reply.
+    *
+    * @param request QNetworkRequest
+    * @return QNetworkReply
+    */
+    QNetworkReply *get(const QNetworkRequest &request);
+
+    /**
+    * @brief Sets cache.
+    *
+    * @param cache QAbstractNetworkCache instance
+    */
+    void setCache(QAbstractNetworkCache *cache);
+
+    /**
+    * @brief Returns cache.
+    *
+    * @return QAbstractNetworkCache
+    */
+    QAbstractNetworkCache *cache() const;
+
+protected:
+    /**
+    * @brief Constructor.
+    *
+    * Instance of this class can only be created by using instance method.
+    */
+    NetworkAccessManager();
+
+private slots:
+    /**
+    * @brief Slot for network connected state.
+    */
+    void connected();
+
+    /**
+    * @brief Slot for finished download.
+    *
+    * @param reply reply from network
+    */
+    void downloadFinished(QNetworkReply *reply);
+
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
+signals:
+    /**
+    * Signal for finished download.
+    *
+    * @param reply reply from network
+    */
+    void finished(QNetworkReply *reply);
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+private:
+    static NetworkAccessManager *m_instance;                ///< Instance of NetworkAccessManager
+    NetworkHandler *m_networkHandler;                       ///< Instance of NetworkHandler
+    QNetworkAccessManager *m_networkAccessManagerPrivate;   ///< Instance of QNetworkAccessManager
+    QList<QNetworkRequest> m_requestQueue;                  ///< Queue for requests
+    QHash<QString, QNetworkReply*> m_offlineReplyQueue;     ///< Queue for offline replies
+    QHash<QString, QNetworkReply*> m_temporaryReplyQueue;   ///< Queue for temporary replies
+};
+
+#endif // NETWORKACCESSMANAGER_H
diff --git a/src/network/networkhandler.cpp b/src/network/networkhandler.cpp
new file mode 100644 (file)
index 0000000..324549b
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#include <QDebug>
+
+#include "networkhandler.h"
+
+#if defined(Q_WS_MAEMO_5) | defined(Q_WS_SIMULATOR)
+#include "networkhandlerprivate.h"
+#else
+#include "networkhandlerprivatestub.h"
+#endif
+
+NetworkHandler::NetworkHandler(QObject *parent)
+    : QObject(parent)
+{
+    m_networkHandlerPrivate = new NetworkHandlerPrivate(this);
+}
+
+void NetworkHandler::connect()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_networkHandlerPrivate->connect();
+}
+
+void NetworkHandler::disconnect()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_networkHandlerPrivate->disconnect();
+}
+
+bool NetworkHandler::isConnected()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return m_networkHandlerPrivate->isConnected();
+}
+
+void NetworkHandler::state()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_networkHandlerPrivate->state();
+}
diff --git a/src/network/networkhandler.h b/src/network/networkhandler.h
new file mode 100644 (file)
index 0000000..5eb84ee
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#ifndef NETWORKHANDLER_H
+#define NETWORKHANDLER_H
+
+#include <QObject>
+
+class NetworkHandlerPrivate;
+
+/**
+* @brief NetworkHandler class.
+*
+* This class handles network connection. Class notifies about
+* network connection states.
+*/
+class NetworkHandler : public QObject
+{
+    Q_OBJECT
+
+public:
+    /**
+    * @brief Friend class for NetworkHandlerPrivate.
+    */
+    friend class NetworkHandlerPrivate;
+
+
+    /**
+    * @brief Constructor.
+    *
+    * Creates ICD D-Bus interface.
+    */
+    NetworkHandler(QObject *parent = 0);
+
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public:
+    /**
+    * @brief Requests network connection.
+    *
+    * Request is done via ICD D-Bus.
+    */
+    void connect();
+
+    /**
+    * @brief Requests to disconnect a connection.
+    *
+    * Request is done via ICD D-Bus.
+    */
+    void disconnect();
+
+    /**
+    * @brief Checks if connected to network.
+    *
+    * @return true if connected, false otherwise
+    */
+    bool isConnected();
+
+    /**
+    * @brief Requests network state.
+    */
+    void state();
+
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
+signals:
+    /**
+    * @brief Signals when connected to network.
+    */
+    void connected();
+
+    /**
+    * @brief Signals when disconnected from network.
+    */
+    void disconnected();
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+private:
+    NetworkHandlerPrivate *m_networkHandlerPrivate; ///< Instance of NetworkHandlerPrivate
+};
+
+#endif // NETWORKHANDLER_H
diff --git a/src/network/networkhandlerprivate.cpp b/src/network/networkhandlerprivate.cpp
new file mode 100644 (file)
index 0000000..55265b3
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#include <icd/dbus_api.h>
+
+#include "networkhandler.h"
+#include "networkhandlerprivate.h"
+
+const int CONNECTION_STATE_INDEX = 7;
+
+static QDBusConnection dBusConnection = QDBusConnection::systemBus();
+
+NetworkHandlerPrivate::NetworkHandlerPrivate(QObject *parent)
+    : QObject(parent),
+      m_connected(false),
+      m_connecting(false)
+{
+    m_parent = static_cast<NetworkHandler*>(parent);
+
+    dBusInterface = new QDBusInterface(ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH,
+                                       ICD_DBUS_API_INTERFACE, dBusConnection);
+
+    dBusConnection.connect(ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH, ICD_DBUS_API_INTERFACE,
+                           ICD_DBUS_API_STATE_SIG,
+                           this, SLOT(stateChanged(const QDBusMessage &)));
+
+    state();
+}
+
+void NetworkHandlerPrivate::stateChanged(const QDBusMessage &message)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if (message.arguments().count() > CONNECTION_STATE_INDEX) {
+
+        bool conversionOk;
+        int connectionState = message.arguments().at(CONNECTION_STATE_INDEX).toInt(&conversionOk);
+
+        if (conversionOk) {
+            if ((connectionState == ICD_STATE_DISCONNECTED) && (isConnected())) {
+                m_connected = false;
+                m_connecting = false;
+                emit m_parent->disconnected();
+            }
+            else if ((connectionState == ICD_STATE_CONNECTED) &&(!isConnected())) {
+                m_connected = true;
+                m_connecting = false;
+                emit m_parent->connected();
+            }
+        }
+    }
+}
+
+void NetworkHandlerPrivate::connect()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if (!m_connecting && !m_connected) {
+        m_connecting = true;
+        dBusInterface->call(ICD_DBUS_API_CONNECT_REQ,
+                            QVariant((unsigned int)ICD_CONNECTION_FLAG_USER_EVENT));
+    }
+}
+
+void NetworkHandlerPrivate::disconnect()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    dBusInterface->call(ICD_DBUS_API_DISCONNECT_REQ,
+                        QVariant((unsigned int)ICD_CONNECTION_FLAG_USER_EVENT));
+}
+
+bool NetworkHandlerPrivate::isConnected()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return m_connected;
+}
+
+void NetworkHandlerPrivate::state()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    dBusInterface->call(ICD_DBUS_API_STATE_REQ);
+}
diff --git a/src/network/networkhandlerprivate.h b/src/network/networkhandlerprivate.h
new file mode 100644 (file)
index 0000000..054b179
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#ifndef NETWORKHANDLERPRIVATE_H
+#define NETWORKHANDLERPRIVATE_H
+
+#include <QtDBus>
+
+class NetworkHandler;
+
+/**
+* @brief NetworkHandlerPrivate class.
+*
+* This class handles network connection. Class notifies about
+* network connection states.
+*/
+class NetworkHandlerPrivate : public QObject
+{
+    Q_OBJECT
+
+public:
+    /**
+    * @brief Constructor.
+    *
+    * Creates ICD D-Bus interface.
+    */
+    NetworkHandlerPrivate(QObject *parent);
+
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public:
+    /**
+    * @brief Requests network connection.
+    *
+    * Request is done via ICD D-Bus.
+    */
+    void connect();
+
+    /**
+    * @brief Requests to disconnect a connection.
+    *
+    * Request is done via ICD D-Bus.
+    */
+    void disconnect();
+
+    /**
+    * @brief Checks if connected to network.
+    *
+    * @return true if connected, false otherwise
+    */
+    bool isConnected();
+
+    /**
+    * @brief Requests network state.
+    */
+    void state();
+
+private slots:
+    /**
+    * @brief Slot for ICD D-Bus state change.
+    *
+    * @param message received D-Bus message
+    */
+    void stateChanged(const QDBusMessage &message);
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+private:
+    QDBusInterface *dBusInterface;  ///< D-Bus interface
+    bool m_connected;               ///< Connection state variable
+    bool m_connecting;              ///< Connecting state variable
+
+    NetworkHandler *m_parent;       ///< Parent object
+};
+
+#endif // NETWORKHANDLERPRIVATE_H
diff --git a/src/network/networkhandlerprivatestub.cpp b/src/network/networkhandlerprivatestub.cpp
new file mode 100644 (file)
index 0000000..b85dc91
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#include <QDebug>
+
+#include "networkhandler.h"
+#include "networkhandlerprivatestub.h"
+
+
+NetworkHandlerPrivate::NetworkHandlerPrivate(QObject *parent)
+    : QObject(parent)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+}
+
+void NetworkHandlerPrivate::connect()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+}
+
+void NetworkHandlerPrivate::disconnect()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+}
+
+bool NetworkHandlerPrivate::isConnected()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return true;
+}
+
+void NetworkHandlerPrivate::state()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+}
diff --git a/src/network/networkhandlerprivatestub.h b/src/network/networkhandlerprivatestub.h
new file mode 100644 (file)
index 0000000..d66327a
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#ifndef NETWORKHANDLERPRIVATESTUB_H
+#define NETWORKHANDLERPRIVATESTUB_H
+
+#include <QObject>
+
+/**
+* @brief NetworkHandlerPrivate class does nothing.
+*
+* Class is used when compiling in desktop.
+*/
+class NetworkHandlerPrivate : public QObject
+{
+public:
+    /**
+    * @brief Constructor.
+    *
+    * @param parent QObject
+    */
+    NetworkHandlerPrivate(QObject *parent);
+
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public:
+    /**
+    * @brief Requests network connection.
+    *
+    * DOES NOTHING.
+    */
+    void connect();
+
+    /**
+    * @brief Requests to disconnect a connection.
+    *
+    * DOES NOTHING.
+    */
+    void disconnect();
+
+    /**
+    * @brief Checks if connected to network.
+    *
+    * RETURNS TRUE.
+    */
+    bool isConnected();
+
+    /**
+    * @brief Requests network state.
+    *
+    * DOES NOTHING.
+    */
+    void state();
+};
+
+#endif // NETWORKHANDLERPRIVATESTUB_H
diff --git a/src/network/networkreply.cpp b/src/network/networkreply.cpp
new file mode 100644 (file)
index 0000000..ea3756c
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#include <QDebug>
+
+#include "networkreply.h"
+
+NetworkReply::NetworkReply(const QNetworkRequest &request, QObject *parent)
+    : QNetworkReply(parent)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    setRequest(request);
+}
+
+qint64 NetworkReply::readData(char *data, qint64 maxlen)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if (m_offset < m_content.size()) {
+        qint64 number = qMin(maxlen, m_content.size() - m_offset);
+        memcpy(data, m_content.constData() + m_offset, number);
+        m_offset += number;
+        return number;
+    } else
+        return -1;
+}
+
+void NetworkReply::abort()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+}
diff --git a/src/network/networkreply.h b/src/network/networkreply.h
new file mode 100644 (file)
index 0000000..dc5755a
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#ifndef NETWORKREPLY_H
+#define NETWORKREPLY_H
+
+#include <QNetworkReply>
+#include <QNetworkRequest>
+
+/**
+* @brief NetworkReply class.
+*
+* Class is used by NetworkAccessManager when network state is disconnected.
+*/
+class NetworkReply : public QNetworkReply
+{
+public:
+    /**
+    * @brief Constructor.
+    *
+    * @param request QNetworkRequest
+    * @param parent QObject
+    */
+    NetworkReply(const QNetworkRequest &request, QObject *parent = 0);
+
+/*******************************************************************************
+ * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
+ ******************************************************************************/
+protected:
+    /**
+    * @brief Reads data from the device.
+    *
+    * @param data data is read into this
+    * @param maxlen maximum size to read
+    * @return number of bytes read or -1 if error occured
+    */
+    qint64 readData(char *data, qint64 maxlen);
+
+    /**
+    * @brief Aborts the operation.
+    */
+    void abort();
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+private:
+    QByteArray m_content;   ///< Content of data
+    qint64 m_offset;        ///< Offset for data read
+
+};
+
+#endif // NETWORKREPLY_H
index d6f2f79..6de18fc 100644 (file)
@@ -24,8 +24,9 @@
 #include <QNetworkReply>
 #include <QPixmap>
 #include "imagefetcher.h"
+#include "network/networkaccessmanager.h"
 
-ImageFetcher::ImageFetcher(QNetworkAccessManager *manager, QObject *parent)
+ImageFetcher::ImageFetcher(NetworkAccessManager *manager, QObject *parent)
     : QObject(parent)
     , m_manager(manager)
 {
@@ -51,6 +52,7 @@ void ImageFetcher::startNextDownload()
     QUrl url = m_downloadQueue.dequeue();
 
     QNetworkRequest request(url);
+    request.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);
     request.setRawHeader("User-Agent", "Situare");
     QNetworkReply *reply = m_manager->get(request);
 
@@ -61,22 +63,26 @@ void ImageFetcher::downloadFinished(QNetworkReply *reply)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if (reply->error() == QNetworkReply::NoError) {
-        QPixmap image;
-        QUrl url = reply->url();
+    //Reply from Facebook
+    if (m_currentDownloads.contains(reply)) {
 
-        if (!image.loadFromData(reply->readAll(), 0))
-            image = QPixmap();
+        if (reply->error() == QNetworkReply::NoError) {
+            QPixmap image;
+            QUrl url = reply->url();
 
-        emit imageReceived(url, image);
-    }
-    else {
-        emit error(reply->errorString());
-    }
+            if (!image.loadFromData(reply->readAll(), 0))
+                image = QPixmap();
 
-    m_currentDownloads.removeAll(reply);
-    reply->deleteLater();
+            emit imageReceived(url, image);
+        }
+        else {
+            emit error(reply->errorString());
+        }
 
-    if (!m_downloadQueue.isEmpty())
-        startNextDownload();
+        m_currentDownloads.removeAll(reply);
+        reply->deleteLater();
+
+        if (!m_downloadQueue.isEmpty())
+            startNextDownload();
+    }
 }
index 53d075c..39bdd9c 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <QtCore>
 
-class QNetworkAccessManager;
+class NetworkAccessManager;
 class QNetworkReply;
 class QUrl;
 
@@ -45,7 +45,7 @@ public:
     * @param manager QNetworkAccessManager
     * @param parent Parent object
     */
-    ImageFetcher(QNetworkAccessManager *manager, QObject *parent = 0);
+    ImageFetcher(NetworkAccessManager *manager, QObject *parent = 0);
 
 /*******************************************************************************
  * CLASS SPECIFIC MEMBER FUNCTIONS AND SLOTS
@@ -103,7 +103,7 @@ signals:
 private:
     QList<QNetworkReply*> m_currentDownloads; ///< List of current downloads
     QQueue<QUrl> m_downloadQueue;             ///< Queue of pending requests
-    QNetworkAccessManager *m_manager;       ///< Network access manager
+    NetworkAccessManager *m_manager;       ///< Network access manager
 };
 
 #endif // IMAGEFETCHER_H
index 0959bf2..c74e7dc 100644 (file)
@@ -29,6 +29,7 @@
 #include "situarecommon.h"
 #include "parser.h"
 #include "ui/avatarimage.h"
+#include "network/networkaccessmanager.h"
 
 SituareService::SituareService(QObject *parent)
         : QObject(parent),
@@ -36,10 +37,10 @@ SituareService::SituareService(QObject *parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_networkManager = new QNetworkAccessManager;
+    m_networkManager = NetworkAccessManager::instance();
     connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(requestFinished(QNetworkReply*)));
 
-    m_imageFetcher = new ImageFetcher(new QNetworkAccessManager(this), this);
+    m_imageFetcher = new ImageFetcher(NetworkAccessManager::instance(), this);
     connect(this, SIGNAL(fetchImage(QUrl)), m_imageFetcher, SLOT(fetchImage(QUrl)));
     connect(m_imageFetcher, SIGNAL(imageReceived(QUrl,QPixmap)), this,
             SLOT(imageReceived(QUrl, QPixmap)));
@@ -50,14 +51,10 @@ SituareService::~SituareService()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    delete m_networkManager;
-    m_networkManager = 0;
     if(m_user) {
         delete m_user;
         m_user = 0;
     }
-    delete m_imageFetcher;
-    m_imageFetcher = 0;
 
     qDeleteAll(m_friendsList.begin(), m_friendsList.end());
     m_friendsList.clear();
@@ -225,11 +222,12 @@ QString SituareService::formUrlParameters(const QPointF &coordinates, QString st
 
 void SituareService::sendRequest(const QUrl &url, const QString &cookieType, const QString &cookie)
 {
-    qDebug() << __PRETTY_FUNCTION__ << "url: " << url;
+    qDebug() << __PRETTY_FUNCTION__;
 
     QNetworkRequest request;
 
     request.setUrl(url);
+    request.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);
     request.setRawHeader(cookieType.toAscii(), cookie.toUtf8());
 
     QNetworkReply *reply = m_networkManager->get(request);
@@ -241,52 +239,56 @@ void SituareService::requestFinished(QNetworkReply *reply)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    QUrl url = reply->url();
-    qDebug() << "BytesAvailable: " << reply->bytesAvailable();
-    if (reply->error()) {
-        qDebug() << reply->errorString();
-        emit error(reply->errorString());
-    }
-    else {
-        qint64 max = reply->size();
-        QByteArray replyArray = reply->read(max);
-        qDebug() << "Reply from: " << url << "reply " << replyArray;
-        // ToDo: results handling includes Situare's errors
-        // works like situare's error handling i.e. both lat & lon are missing/wrong
-        // -> we get only error for wrong lon
-        if(replyArray == ERROR_LAT.toAscii()) {
-            qDebug() << "Error: " << ERROR_LAT;
-            emit error(replyArray);
-        }
-        else if(replyArray == ERROR_LON.toAscii()) {
-            qDebug() << "Error: " << ERROR_LON;
-            emit error(replyArray);
-        }
-        else if(replyArray.contains(ERROR_SESSION.toAscii())) {
-            qDebug() << "Error: " << ERROR_SESSION;
-            emit invalidSessionCredentials();
-        }
-        else if(replyArray.startsWith(OPENING_BRACE_MARK.toAscii())) {
-            qDebug() << "JSON string";
-            parseUserData(replyArray);
+    //Reply from situare
+    if (m_currentRequests.contains(reply)) {
+
+        QUrl url = reply->url();
+        qDebug() << "BytesAvailable: " << reply->bytesAvailable();
+        if (reply->error()) {
+            qDebug() << reply->errorString();
+            emit error(reply->errorString());
         }
-        else if(replyArray == "") {
-                       if(url.toString().contains(UPDATE_LOCATION.toAscii())) {
-                emit updateWasSuccessful();
+        else {
+            qint64 max = reply->size();
+            QByteArray replyArray = reply->read(max);
+            qDebug() << "Reply from: " << url << "reply " << replyArray;
+            // ToDo: results handling includes Situare's errors
+            // works like situare's error handling i.e. both lat & lon are missing/wrong
+            // -> we get only error for wrong lon
+            if(replyArray == ERROR_LAT.toAscii()) {
+                qDebug() << "Error: " << ERROR_LAT;
+                emit error(replyArray);
             }
-            else {
-                // session credentials are invalid
+            else if(replyArray == ERROR_LON.toAscii()) {
+                qDebug() << "Error: " << ERROR_LON;
+                emit error(replyArray);
+            }
+            else if(replyArray.contains(ERROR_SESSION.toAscii())) {
+                qDebug() << "Error: " << ERROR_SESSION;
                 emit invalidSessionCredentials();
             }
+            else if(replyArray.startsWith(OPENING_BRACE_MARK.toAscii())) {
+                qDebug() << "JSON string";
+                parseUserData(replyArray);
+            }
+            else if(replyArray == "") {
+                            if(url.toString().contains(UPDATE_LOCATION.toAscii())) {
+                    emit updateWasSuccessful();
+                }
+                else {
+                    // session credentials are invalid
+                    emit invalidSessionCredentials();
+                }
+            }
+            else {
+                // Street address ready
+                QString address = QString::fromUtf8(replyArray);
+                emit reverseGeoReady(address);
+            }
         }
-        else {
-            // Street address ready
-            QString address = QString::fromUtf8(replyArray);
-            emit reverseGeoReady(address);
-        }
+        m_currentRequests.removeAll(reply);
+        reply->deleteLater();
     }
-    m_currentRequests.removeAll(reply);
-    reply->deleteLater();
 }
 
 void SituareService::credentialsReady(const FacebookCredentials &credentials)
index 7d799ac..0be2214 100644 (file)
@@ -28,7 +28,7 @@
 #include "../user/user.h"
 #include "imagefetcher.h"
 
-class QNetworkAccessManager;
+class NetworkAccessManager;
 class QNetworkReply;
 class QNetworkRequest;
 class QPointF;
@@ -241,7 +241,7 @@ private:
     QList<QNetworkReply *> m_currentRequests;   ///< List of current http requests
     QList<User *> m_friendsList;                ///< List of friends(User)
 
-    QNetworkAccessManager *m_networkManager;    ///< Pointer to QNetworkAccessManager
+    NetworkAccessManager *m_networkManager;    ///< Pointer to QNetworkAccessManager
 
     FacebookCredentials m_credentials;          ///< handle for FacebookCredentials
     ImageFetcher *m_imageFetcher;               ///< Instance of the image fetcher
index 4eedcad..fe92caf 100644 (file)
@@ -3,8 +3,8 @@
 # -------------------------------------------------
 TARGET = ../situare
 TEMPLATE = app
-INCLUDEPATH += "/usr/include/qjson"
-LIBS += "-lqjson"
+INCLUDEPATH += /usr/include/qjson
+LIBS += -lqjson
 RESOURCES += ../images.qrc
 SOURCES += main.cpp \
     ui/mainwindow.cpp \
@@ -43,7 +43,11 @@ SOURCES += main.cpp \
     ui/userinfo.cpp \
     ui/sidepanel.cpp \
     networkcookiejar.cpp \
-    ui/zoombutton.cpp
+    ui/zoombutton.cpp \
+    ui/zoombutton.cpp \
+    network/networkaccessmanager.cpp \
+    network/networkhandler.cpp \
+    network/networkreply.cpp
 HEADERS += ui/mainwindow.h \
     map/mapengine.h \
     map/mapview.h \
@@ -86,16 +90,23 @@ HEADERS += ui/mainwindow.h \
     ui/userinfo.h \
     ui/sidepanel.h \
     networkcookiejar.h \
-    ui/zoombutton.h
+    ui/zoombutton.h \
+    network/networkaccessmanager.h \
+    network/networkhandler.h \
+    network/networkreply.h
 QT += network \
     webkit
-#DEFINES += QT_NO_DEBUG_OUTPUT
+
+DEFINES += QT_NO_DEBUG_OUTPUT
 
 maemo5 | simulator {
-    SOURCES += gps/gpspositionprivate.cpp
-    HEADERS += gps/gpspositionprivate.h
-    QT += maemo5
-    CONFIG += mobility
+    INCLUDEPATH += /usr/include/glib-2.0 /usr/lib/glib-2.0/include
+    SOURCES += gps/gpspositionprivate.cpp \
+               network/networkhandlerprivate.cpp
+    HEADERS += gps/gpspositionprivate.h \
+               network/networkhandlerprivate.h
+    QT += maemo5 dbus
+    CONFIG += mobility icd2
     MOBILITY = location
     message([QJson])
     message(Make sure you have QJson development headers installed)
@@ -107,8 +118,10 @@ maemo5 | simulator {
     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
+    SOURCES += gps/gpspositionprivatestub.cpp \
+               network/networkhandlerprivatestub.cpp
+    HEADERS += gps/gpspositionprivatestub.h \
+               network/networkhandlerprivatestub.h
     message(QJson built in)
     message(Make sure you have QJson development headers installed)
     message(install headers with: sudo apt-get install libqjson-dev)
index c3cd297..909f421 100644 (file)
@@ -170,7 +170,8 @@ void FriendListItem::setData(User *user)
     if(user) {
         m_user = user;
 
-        m_findButton->setButtonIcon(m_user->profileImage());
+        if (!m_user->profileImage().isNull())
+            m_findButton->setButtonIcon(m_user->profileImage());
 
         QString unit;
         double value;
index 2f4dac8..bd48668 100644 (file)
@@ -34,13 +34,13 @@ ImageButton::ImageButton(QWidget *parent, QString normalIconPictureFileName,
     qDebug() << __PRETTY_FUNCTION__;
 
     // If there is a file name provided for icon image, use it as the icon for the button
-    if (normalIconPictureFileName != "") {
+    if (!normalIconPictureFileName.isEmpty()) {
         QPixmap iconPixmap(normalIconPictureFileName);
         QSize buttonSize = iconPixmap.size(); // Get the button size from the normal state icon picture
         QIcon icon(iconPixmap);
 
         // If there is a picture for selected state, use it instead of a simple highlight change
-        if(selectedIconPictureFileName != "")
+        if(!selectedIconPictureFileName.isEmpty())
             icon.addFile(selectedIconPictureFileName, buttonSize, QIcon::Selected);
 
         setIcon(icon);
@@ -51,6 +51,8 @@ ImageButton::ImageButton(QWidget *parent, QString normalIconPictureFileName,
 
 void ImageButton::setButtonIcon(const QPixmap &image)
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     QSize buttonSize = image.size(); // Get the button size from the normal state icon picture
     QIcon icon(image);
 
@@ -66,6 +68,9 @@ void ImageButton::mousePressEvent(QMouseEvent *event)
     if(m_buttonMode != QIcon::Disabled) {
         QPushButton::mousePressEvent(event);
         setMode(QIcon::Selected);
+    } else {
+        setDown(true);
+        emit pressed();
     }
 }
 
@@ -76,6 +81,9 @@ void ImageButton::mouseReleaseEvent(QMouseEvent *event)
     if(m_buttonMode != QIcon::Disabled) {
         QPushButton::mouseReleaseEvent(event);
         setMode(QIcon::Normal);
+    } else {
+        setDown(false);
+        emit released();
     }
 }
 
index c0847e9..6af3a8d 100644 (file)
@@ -117,9 +117,6 @@ void MainWindow::buildFriendListPanel()
             this, SIGNAL(findFriend(QPointF)));
 
     connect(m_mapView, SIGNAL(viewResized(QSize)),
-            m_zoomButtonPanel, SLOT(screenResized(QSize)));
-
-    connect(m_mapView, SIGNAL(viewResized(QSize)),
             m_friendsListPanel, SLOT(screenResized(QSize)));
 
     connect(this, SIGNAL(locationItemClicked(QList<QString>)),
@@ -213,6 +210,9 @@ void MainWindow::buildUserInfoPanel()
     m_userPanelSidebar->stackUnder(m_friendsListPanel);
     m_userPanel->stackUnder(m_userPanelSidebar);
 
+    connect(m_userPanel, SIGNAL(findUser(QPointF)),
+            this, SIGNAL(findUser(QPointF)));
+
     connect(this, SIGNAL(userLocationReady(User*)),
             m_userPanel, SLOT(userDataReceived(User*)));
 
@@ -249,8 +249,7 @@ void MainWindow::buildZoomButtonPanel()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_zoomButtonPanel = new ZoomButtonPanel(this, ZOOM_BUTTON_PANEL_POSITION_X,
-                                            ZOOM_BUTTON_PANEL_POSITION_Y);
+    m_zoomButtonPanel = new ZoomButtonPanel(this);
 
     connect(m_zoomButtonPanel->zoomInButton(), SIGNAL(clicked()),
             this, SIGNAL(zoomIn()));
@@ -267,10 +266,8 @@ void MainWindow::buildZoomButtonPanel()
     connect(this, SIGNAL(minZoomLevelReached()),
             m_zoomButtonPanel, SLOT(disableZoomOutButton()));
 
-    QSettings settings(DIRECTORY_NAME, FILE_NAME);
-    m_zoomButtonPanel->move(settings.value(ZOOMPANEL_POSITION,
-                                           QPoint(ZOOM_BUTTON_PANEL_POSITION_X,
-                                                  ZOOM_BUTTON_PANEL_POSITION_Y)).toPoint());
+    connect(m_mapView, SIGNAL(viewResized(QSize)),
+            m_zoomButtonPanel, SLOT(screenResized(QSize)));
 }
 
 void MainWindow::clearCookieJar()
index e63c02d..05c98eb 100644 (file)
@@ -340,6 +340,13 @@ signals:
     void fetchUsernameFromSettings();
 
     /**
+    * @brief Signal for finding user.
+    *
+    * @param coordinates user geo coordinates
+    */
+    void findUser(const QPointF &coordinates);
+
+    /**
     * @brief GPS setting changed
     *
     * @param enabled True if GPS is enabled, otherwise false
index f39cc00..481fb87 100644 (file)
 
 enum Side {LEFT, RIGHT};  ///< Enumerator for panel sideness
 
-const int DRAG_INIT_TIME = 1000;    ///< How long buttons must be pressed to start drag mode
+const int DRAG_INIT_TIME = 1000;        ///< How long buttons must be pressed to start drag mode
+const int FORCE_RELEASE_TIME = 10000;   ///< How long mouse can be grabbed
 
-const int SIDEBAR_WIDTH = 23;       ///< Width of the sidebar
-const int SIDEBAR_HEIGHT = 424;     ///< Height of the sidebar
+const int SIDEBAR_WIDTH = 23;           ///< Width of the sidebar
+const int SIDEBAR_HEIGHT = 424;         ///< Height of the sidebar
 
-const int SLIDINGBAR_WIDTH = 24;    ///< Width of the slidingbar
-const int SLIDINGBAR_HEIGHT = 424;  ///< Height of the slidingbar
+const int SLIDINGBAR_WIDTH = 24;        ///< Width of the slidingbar
+const int SLIDINGBAR_HEIGHT = 424;      ///< Height of the slidingbar
 
-const int PANEL_PEEK_AMOUNT = 25; ///< Amount of pixels shown when panel is closed
+const int PANEL_PEEK_AMOUNT = 25;       ///< Amount of pixels shown when panel is closed
 
-const int FRIENDPANEL_WIDTH  = 430; ///< Width of the friends list panel
+const int FRIENDPANEL_WIDTH  = 430;     ///< Width of the friends list panel
 const int FRIENDPANEL_HEIGHT = DEFAULT_SCREEN_HEIGHT; ///< Height of the friends list panel
 
-const int USERPANEL_WIDTH  = 300; ///< Width of the user panel
+const int USERPANEL_WIDTH  = 300;       ///< Width of the user panel
 const int USERPANEL_HEIGHT = DEFAULT_SCREEN_HEIGHT; ///< Height of the user panetl
 
 const int MARGIN_CORRECTION = 1; ///< Amount of correction to make panels touch the window borders
 const int MARGIN_CORRECTION2 = 2; ///< Amount of correction to make panels touch the window borders
 
-const int PANEL_TOP_Y = 0; ///< Y coordinate for top of both panels
-const int TOP_CORNER_X = 0;  ///< X coordinate for top left corner
+const int PANEL_TOP_Y = 0;              ///< Y coordinate for top of both panels
+const int TOP_CORNER_X = 0;             ///< X coordinate for top left corner
 
 const int FRIENDPANEL_CLOSED_X =
         DEFAULT_SCREEN_WIDTH - PANEL_PEEK_AMOUNT
-        - SLIDINGBAR_WIDTH; ///< X location of the friend list panel when closed
+        - SLIDINGBAR_WIDTH;             ///< X location of the friend list panel when closed
 const int FRIENDPANEL_OPENED_X =
         DEFAULT_SCREEN_WIDTH - FRIENDPANEL_WIDTH
-        - SLIDINGBAR_WIDTH; ///< X location of the friend list panel when opened
+        - SLIDINGBAR_WIDTH;             ///< X location of the friend list panel when opened
 
 const int USERPANEL_CLOSED_X =
         2 - USERPANEL_WIDTH + PANEL_PEEK_AMOUNT;  ///< X location of the user panel when closed
-const int USERPANEL_OPENED_X = 0;     ///< X location of the user panel when opened
+const int USERPANEL_OPENED_X = 0;       ///< X location of the user panel when opened
 
 
 const int ZOOM_BUTTON_PANEL_POSITION_X = 10
@@ -66,4 +67,6 @@ const int ZOOM_BUTTON_PANEL_POSITION_X = 10
 const int ZOOM_BUTTON_PANEL_POSITION_Y = 10; ///< Vertical position of zoom panel
 const int ZOOM_BUTTON_PANEL_BUTTON_SPACING = 4; ///< Size of a zoom button spacing
 
+const QString ZOOMPANEL_POSITION = "Zoom_Panel_Position";
+
 #endif // PANELCOMMON_H
index d457e46..4cdc9ed 100644 (file)
 #include "../user/user.h"
 #include "userinfo.h"
 
-const int BACKGROUND_TOP_HEIGHT = 20;
-const int BACKGROUND_BOTTOM_HEIGHT = 15;
-const QColor COLOR_GRAY = QColor(152, 152, 152);    ///< Gray color
-const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal);    ///< Normal font
-const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal);     ///< Small font
-const int ICON_HEIGHT = 24;     ///< Icon height
-const int ICON_WIDTH = 24;       ///< Icon width
-const int IMAGE_HEIGHT = 60; ///< Friend image height
-const int IMAGE_WIDTH = 60;  ///< Friend image width
-const int ITEM_MIN_WIDTH = 250;  ///< Minimum width for item
-const int MARGIN = 5;   ///< Icon margin
+const int BACKGROUND_WIDTH = 240; ///< Width for item
+const int BACKGROUND_TOP_HEIGHT = 16; ///< Height for item top
+const int BACKGROUND_BOTTOM_HEIGHT = 15; ///< Height for item bottom
+const QColor COLOR_GRAY = QColor(152, 152, 152); ///< Gray color
+const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal); ///< Normal font
+const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal);  ///< Small font
+const int ICON_HEIGHT = 24; ///< Icon height
+const int ICON_WIDTH = 24;  ///< Icon width
+const int IMAGE_HEIGHT = 60;    ///< Profile image height
+const int IMAGE_WIDTH = 60;     ///< Profile image width
+const int MARGIN = 5; ///< Icon margin
 const int MOUSE_PRESS_AREA_WIDTH = 20;  ///< Area width for item height toggling
 const int MOUSE_PRESS_AREA_HEIGHT = 20; ///< Area height for item height toggling
 
@@ -45,21 +45,16 @@ const int MOUSE_PRESS_AREA_HEIGHT = 20; ///< Area height for item height togglin
 *
 * @brief All label's maximum width
 */
-const int LABEL_MAX_WIDTH = ITEM_MIN_WIDTH - 3*MARGIN - ICON_WIDTH;
-
-/**
-* @brief Name label's maximum width
-*
-* @var NAME_LABEL_MAX_WIDTH
-*/
-const int NAME_LABEL_MAX_WIDTH = LABEL_MAX_WIDTH + 30;
+const int LABEL_MAX_WIDTH = BACKGROUND_WIDTH - 3 * MARGIN - ICON_WIDTH + 130;
 
 UserInfo::UserInfo(QWidget *parent)
-    : QWidget(parent)
-        , m_expanded(false)
+    : QWidget(parent),
+      m_expanded(false)
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     QVBoxLayout *verticalLayout = new QVBoxLayout(this);
-    verticalLayout->setContentsMargins(MARGIN, 0, MARGIN*2, MARGIN*2);
+    verticalLayout->setContentsMargins(MARGIN * 2, 0, MARGIN * 2, MARGIN * 2);
     verticalLayout->setSpacing(0);
     setLayout(verticalLayout);
 
@@ -71,10 +66,6 @@ UserInfo::UserInfo(QWidget *parent)
     buttonLayout->setMargin(0);
     buttonLayout->setSpacing(0);
 
-    QLabel *clockLabel = new QLabel();
-    clockLabel->setPixmap(QPixmap(":/res/images/clock.png"));
-    clockLabel->setContentsMargins(0, 0, MARGIN, 0);
-    clockLabel->setFixedSize(ICON_WIDTH + MARGIN, ICON_HEIGHT);
     QLabel *envelopeLabel = new QLabel();
     envelopeLabel->setPixmap(QPixmap(":/res/images/envelope.png"));
     envelopeLabel->setContentsMargins(0, 0, MARGIN, 0);
@@ -83,21 +74,22 @@ UserInfo::UserInfo(QWidget *parent)
     compassLabel->setPixmap(QPixmap(":/res/images/compass.png"));
     compassLabel->setContentsMargins(0, 0, MARGIN, 0);
     compassLabel->setFixedSize(ICON_WIDTH + MARGIN, ICON_HEIGHT);
+    QLabel *clockLabel = new QLabel();
+    clockLabel->setPixmap(QPixmap(":/res/images/clock.png"));
+    clockLabel->setContentsMargins(0, 0, MARGIN, 0);
+    clockLabel->setFixedSize(ICON_WIDTH + MARGIN, ICON_HEIGHT);
 
-    m_imageLabel = new QLabel();
-    m_imageLabel->setFixedSize(IMAGE_WIDTH, IMAGE_HEIGHT);
-    m_imageLabel->setAlignment(Qt::AlignHCenter);
+    m_findButton = new ImageButton();
 
     m_nameLabel = new QLabel();
-    m_nameLabel->setFixedHeight(IMAGE_HEIGHT);
-    m_nameLabel->setAlignment(Qt::AlignHCenter);
+    m_nameLabel->setWordWrap(true);
 
-    m_updatedLabel = new QLabel();
-    m_updatedLabel->setWordWrap(true);
     m_statusTextLabel = new QLabel();
     m_statusTextLabel->setWordWrap(true);
     m_locationLabel = new QLabel();
     m_locationLabel->setWordWrap(true);
+    m_updatedLabel = new QLabel();
+    m_updatedLabel->setWordWrap(true);
 
     ImageButton *updateFriendsButton = new ImageButton(this, ":/res/images/refresh.png",
                                                              ":/res/images/refresh_s.png");
@@ -107,20 +99,23 @@ UserInfo::UserInfo(QWidget *parent)
     buttonLayout->addWidget(updateFriendsButton);
     buttonLayout->addWidget(updateStatusMessageButton);
 
-    infoLayout->addRow(compassLabel, m_locationLabel);
     infoLayout->addRow(envelopeLabel, m_statusTextLabel);
+    infoLayout->addRow(compassLabel, m_locationLabel);
     infoLayout->addRow(clockLabel, m_updatedLabel);
 
-    verticalLayout->addWidget(m_imageLabel, 0, Qt::AlignHCenter);
-
-    verticalLayout->addWidget(m_nameLabel, 1);
+    verticalLayout->addWidget(m_findButton, 0, Qt::AlignHCenter);
+    verticalLayout->addWidget(m_nameLabel, 0, Qt::AlignHCenter);
     verticalLayout->addLayout(infoLayout);
-    verticalLayout->addLayout(buttonLayout, 2);
+    verticalLayout->addLayout(buttonLayout);
 
     connect(updateStatusMessageButton,SIGNAL(clicked()),
             this,SLOT(messageUpdate()));
     connect(updateFriendsButton,SIGNAL(clicked()),
             this, SIGNAL(refreshUserData()));
+    connect(m_findButton, SIGNAL(clicked()),
+        this, SLOT(findButtonClicked()));
+
+    setFixedWidth(BACKGROUND_WIDTH);
 
     this->setFont(NOKIA_FONT_SMALL);
     m_nameLabel->setFont(NOKIA_FONT_NORMAL);
@@ -131,26 +126,23 @@ UserInfo::UserInfo(QWidget *parent)
     namePalette.setColor(QPalette::Foreground, Qt::white);
     m_nameLabel->setPalette(namePalette);
 
-    m_backgroundTopImage.load(":/res/images/list_item_top.png");
-    m_backgroundMiddleImage.load(":/res/images/list_item_middle.png");
-    m_backgroundBottomImage.load(":/res/images/list_item_bottom.png");
-
-    this->setMinimumWidth(ITEM_MIN_WIDTH);
+    m_backgroundTopImage.load(":/res/images/user_info_item_top.png");
+    m_backgroundMiddleImage.load(":/res/images/user_info_item_middle.png");
+    m_backgroundBottomImage.load(":/res/images/user_info_item_bottom.png");
 }
 
-void UserInfo::setUserName(const QString &name)
+void UserInfo::setAddress(const QString &address)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_userName = name;
-    setText(false);
+    m_locationLabel->setText(address);
 }
 
-void UserInfo::setAvatar(const QPixmap &image)
+void UserInfo::setCoordinates(const QPointF &coordinates)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_imageLabel->setPixmap(image);
+    m_coordinates = coordinates;
 }
 
 void UserInfo::setMessageText(const QString &text)
@@ -161,18 +153,26 @@ void UserInfo::setMessageText(const QString &text)
     setText(false);
 }
 
-void UserInfo::setAddress(const QString &addr)
+void UserInfo::setProfileImage(const QPixmap &image)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_locationLabel->setText(addr);
+    m_findButton->setButtonIcon(image);
 }
 
-void UserInfo::setTime(const QString &tim)
+void UserInfo::setTime(const QString &time)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_updatedLabel->setText(tim);
+    m_updatedLabel->setText(time);
+}
+
+void UserInfo::setUserName(const QString &name)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_userName = name;
+    setText(false);
 }
 
 QString UserInfo::shortenText(const QLabel *label, const QString &text, int textMaxWidth)
@@ -201,7 +201,7 @@ void UserInfo::setText(bool expanded)
         m_statusTextLabel->setText(m_messageText);
     }
     else {
-        m_nameLabel->setText(shortenText(m_nameLabel, m_userName, NAME_LABEL_MAX_WIDTH));
+        m_nameLabel->setText(shortenText(m_nameLabel, m_userName, LABEL_MAX_WIDTH));
         m_statusTextLabel->setText(shortenText(m_statusTextLabel, m_messageText,
                                                LABEL_MAX_WIDTH));
     }
@@ -229,10 +229,10 @@ void UserInfo::paintEvent(QPaintEvent *aPaintEvent)
 
     QPainter painter(this);
 
-    QRect topRect = QRect(0, 0, ITEM_MIN_WIDTH, BACKGROUND_TOP_HEIGHT);
-    QRect middleRect = QRect(0, topRect.bottom(), ITEM_MIN_WIDTH,
+    QRect topRect = QRect(0, MARGIN, BACKGROUND_WIDTH, BACKGROUND_TOP_HEIGHT);
+    QRect middleRect = QRect(0, topRect.bottom(), BACKGROUND_WIDTH,
                              height() - BACKGROUND_TOP_HEIGHT - BACKGROUND_BOTTOM_HEIGHT);
-    QRect bottomRect = QRect(topRect.left(), middleRect.bottom(), ITEM_MIN_WIDTH,
+    QRect bottomRect = QRect(topRect.left(), middleRect.bottom(), BACKGROUND_WIDTH,
                              BACKGROUND_BOTTOM_HEIGHT);
 
     painter.drawPixmap(topRect, m_backgroundTopImage);
@@ -247,6 +247,13 @@ void UserInfo::mousePressEvent(QMouseEvent *event)
     m_mousePosition = event->pos();
 }
 
+void UserInfo::findButtonClicked()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    emit findUser(m_coordinates);
+}
+
 void UserInfo::messageUpdate()
 {
     qDebug() << __PRETTY_FUNCTION__;
index 06c2494..7e3684f 100644 (file)
 #include <QWidget>
 #include "updatelocation/updatelocationdialog.h"
 
+class ImageButton;
+
+/**
+* @brief UserInfo shows user's data in expandable item.
+*
+* @class UserInfo userinfo.h "ui/userinfo.h"
+*/
 class UserInfo : public QWidget
 {
     Q_OBJECT
@@ -49,6 +56,7 @@ protected:
     * @param event QMouseEvent mouse press event
     */
     void mousePressEvent(QMouseEvent *event);
+
     /**
     * @brief Call toggleHeight if mouse position is unchanged.
     *
@@ -56,6 +64,7 @@ protected:
     * @param event QMouseEvent mouse release event
     */
     void mouseReleaseEvent(QMouseEvent *event);
+
     /**
     * @brief This function is called when the widget is drawn
     *
@@ -70,16 +79,16 @@ public:
     /**
     * @brief Sets the users current address
     *
-    * @param addr Reference to users current address
+    * @param address Reference to users current address
     */
-    void setAddress(const QString &addr);
+    void setAddress(const QString &address);
 
     /**
-    * @brief Sets the user picture
+    * @brief Sets the users current coordinates
     *
-    * @param avat Reference to user picture
+    * @param coordinates Reference to users current coordinates
     */
-    void setAvatar(const QPixmap &image);
+    void setCoordinates(const QPointF &coordinates);
 
     /**
     * @brief Sets the message text
@@ -89,16 +98,23 @@ public:
     void setMessageText(const QString &text);
 
     /**
+    * @brief Sets the user picture
+    *
+    * @param image Reference to user picture
+    */
+    void setProfileImage(const QPixmap &image);
+
+    /**
     * @brief Sets the time of updated message
     *
-    * @param tim Reference to time when message was sent.
+    * @param time Reference to time when message was sent.
     */
-    void setTime(const QString &tim);
+    void setTime(const QString &time);
 
    /**
     * @brief Sets the user name
     *
-    * @param usernam Reference to user name
+    * @param name Reference to user name
     */
     void setUserName(const QString &name);
 
@@ -119,6 +135,11 @@ private:
 
 private slots:
     /**
+    * @brief Slot for find button click
+    */
+    void findButtonClicked();
+
+    /**
     * @brief Slot function to forward messageUpdate launch signal
     *
     */
@@ -129,6 +150,13 @@ private slots:
 ******************************************************************************/
 signals:
     /**
+    * @brief Signal for finding user.
+    *
+    * @param coordinates user geo coordinates
+    */
+    void findUser(const QPointF &coordinates);
+
+    /**
     * @brief Signal for refreshing user data.
     *
     */
@@ -160,7 +188,6 @@ signals:
 ******************************************************************************/
 private:
     bool m_expanded;                    ///< Item expanded state
-    QLabel *m_imageLabel;               ///< Image label
     QLabel *m_locationLabel;            ///< Location label
     QLabel *m_nameLabel;                ///< Name label
     QLabel *m_statusTextLabel;          ///< Status text label
@@ -169,11 +196,12 @@ private:
     QPixmap m_backgroundMiddleImage;    ///< Middle background image
     QPixmap m_backgroundTopImage;       ///< Top background image
     QPoint m_mousePosition;             ///< Current mouse press position
+    QPointF m_coordinates;              ///< User current coordinates
     QString m_address;                  ///< Address from where the new message was sent.
     QString m_messageText;              ///< User's message
     QString m_time;                     ///< Time when the new message was sent
     QString m_userName;                 ///< User's name
-
+    ImageButton *m_findButton;          ///< User find button
 };
 
 #endif // USERINFO_H
index 7d76313..33afd5e 100644 (file)
@@ -26,10 +26,30 @@ UserInfoPanel::UserInfoPanel(QWidget *parent)
     : SidePanel(parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
+
     setType(SidePanel::UserPanel);
 
     m_userInfo = new UserInfo(this);
-    m_panelVBox->addWidget(m_userInfo, 0, Qt::AlignCenter);
+
+    QWidget *userInfoView = new QWidget(this);
+    QVBoxLayout *userViewLayout = new QVBoxLayout(userInfoView);
+    userViewLayout->setMargin(0);
+    userViewLayout->setSpacing(0);
+    userViewLayout->setStretch(0, 0);
+    userViewLayout->setSizeConstraint(QLayout::SetFixedSize);
+    userViewLayout->addWidget(m_userInfo);
+
+    QScrollArea *userInfoScroll = new QScrollArea(this);
+    userInfoScroll->setWidgetResizable(true);
+    userInfoScroll->setWidget(userInfoView);
+    userInfoScroll->setAlignment(Qt::AlignVCenter);
+    userInfoScroll->viewport()->setAutoFillBackground(false);
+    userInfoScroll->widget()->setAutoFillBackground(false);
+
+    m_panelVBox->addWidget(userInfoScroll);
+
+    connect(m_userInfo, SIGNAL(findUser(QPointF)),
+            this, SIGNAL(findUser(QPointF)));
 
     connect(m_userInfo,SIGNAL(requestReverseGeo()),
             this, SIGNAL(requestReverseGeo()));
@@ -50,9 +70,10 @@ void UserInfoPanel::userDataReceived(User *user)
 
     if(user) {
         m_userInfo->setUserName(user->name());
-        m_userInfo->setAvatar(user->profileImage());
+        m_userInfo->setProfileImage(user->profileImage());
         m_userInfo->setMessageText(user->note());
         m_userInfo->setAddress(user->address());
         m_userInfo->setTime(user->timestamp());
+        m_userInfo->setCoordinates(user->coordinates());
     }
 }
index 21d1e2c..7aabce7 100644 (file)
@@ -58,8 +58,18 @@ public slots:
     */
     void userDataReceived(User *user);
 
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
 signals:
     /**
+    * @brief Signal for finding user.
+    *
+    * @param coordinates user geo coordinates
+    */
+    void findUser(const QPointF &coordinates);
+
+    /**
     * @brief Signal for refreshing user data.
     *
     */
@@ -91,5 +101,6 @@ signals:
  ******************************************************************************/
 private:
     UserInfo *m_userInfo; ///< Instance of the user info view
+
 };
 #endif // USERPANEL_H
index 143fbac..f1d8439 100644 (file)
@@ -29,41 +29,30 @@ ZoomButton::ZoomButton(QWidget *parent, QString normalIconPictureFileName,
                        QString selectedIconPictureFileName)
     : ImageButton(parent, normalIconPictureFileName, selectedIconPictureFileName)
 {
-    m_dragStartTimer = new QTimer(this);
-    m_dragStartTimer->setSingleShot(true);
-    connect(m_dragStartTimer, SIGNAL(timeout()),
-            this, SLOT(timerExpired()));
 }
 
-void ZoomButton::mousePressEvent(QMouseEvent *event)
+void ZoomButton::mouseMoveEvent(QMouseEvent *event)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if(m_buttonMode != QIcon::Disabled) {
-        QAbstractButton::mousePressEvent(event);
-        setMode(QIcon::Selected);
+    if(rect().contains(event->pos())) {
+        m_eventPosition = mapToParent(event->pos());
     }
-
-    m_eventPosition = mapToParent(event->pos());
-
-    m_dragStartTimer->start(DRAG_INIT_TIME);
+    ImageButton::mouseMoveEvent(event);
 }
 
-void ZoomButton::mouseReleaseEvent(QMouseEvent *event)
+void ZoomButton::mousePressEvent(QMouseEvent *event)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if(m_buttonMode != QIcon::Disabled) {
-        QAbstractButton::mouseReleaseEvent(event);
-        setMode(QIcon::Normal);
-    }
+    ImageButton::mousePressEvent(event);
 
-    m_dragStartTimer->stop();
+    m_eventPosition = mapToParent(event->pos());
 }
-void ZoomButton::timerExpired()
+
+const QPoint& ZoomButton::eventPosition()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    setMode(QIcon::Normal);
-    emit startDragMode(true, m_eventPosition);
+    return m_eventPosition;
 }
index 4dc3564..745981f 100644 (file)
@@ -51,46 +51,31 @@ public:
  ******************************************************************************/
 protected:
     /**
-     * @brief Event handler for mouse press events
+     * @brief Event handler for mouse move events
      *
      * @param event Mouse event
      */
-    void mousePressEvent(QMouseEvent *event);
+    void mouseMoveEvent(QMouseEvent *event);
 
     /**
-     * @brief Event handler for mouse release events
+     * @brief Event handler for mouse press events
      *
      * @param event Mouse event
      */
-    void mouseReleaseEvent(QMouseEvent *event);
+    void mousePressEvent(QMouseEvent *event);
 
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
-private slots:
-    /**
-     * @brief Slot to emit signal to zoom button panel to start drag mode after timer timeout
-     */
-    void timerExpired();
-
-/*******************************************************************************
- * SIGNALS
- ******************************************************************************/
-signals:
-    /**
-     * @brief Signal for starting drag mode
-     *
-     * @param mode True to start drag mode
-     * @param eventPosition Position of mousePressEvent mapped to parent
-     */
-    void startDragMode(bool mode, QPoint eventPosition);
+public:
+    const QPoint& eventPosition();
 
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
 private:
     QTimer *m_dragStartTimer;   ///< Mouse press timer, initiates drag mode
-    QPoint m_eventPosition;       ///< Position of mousePressEvent
+    QPoint m_eventPosition;     ///< Position of mousePressEvent
 };
 
 #endif // ZOOMBUTTON_H
index 63e57c3..7757918 100644 (file)
 #include "zoombutton.h"
 #include "common.h"
 
-ZoomButtonPanel::ZoomButtonPanel(QWidget *parent, int x, int y)
+ZoomButtonPanel::ZoomButtonPanel(QWidget *parent)
     : QWidget(parent),
-      m_zoomInButton(0),
-      m_zoomOutButton(0),
       m_isDraggable(false),
-      m_panelLayout(this)
+      m_panelLayout(this),
+      m_zoomInButton(0),
+      m_zoomOutButton(0)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -49,26 +49,36 @@ ZoomButtonPanel::ZoomButtonPanel(QWidget *parent, int x, int y)
     m_panelLayout.addWidget(m_zoomInButton, 0, 0);
     m_panelLayout.addWidget(m_zoomOutButton, 1, 0);
 
-    move(x, y);
+    QSettings settings(DIRECTORY_NAME, FILE_NAME);
+    move(settings.value(ZOOMPANEL_POSITION,
+                        QPoint(ZOOM_BUTTON_PANEL_POSITION_X,
+                               ZOOM_BUTTON_PANEL_POSITION_Y)).toPoint());
 
     QPalette pal = palette();
     pal.setColor(QPalette::Background, QColor(0, 0, 0, 128));
     setPalette(pal);
 
-    m_eventBlocker = new QWidget(this);
-    m_eventBlocker->setAttribute(Qt::WA_TransparentForMouseEvents, true);
-    m_eventBlocker->resize(size().width(),
-                           m_zoomInButton->size().height() * 2 + ZOOM_BUTTON_PANEL_BUTTON_SPACING);
-
-    connect(m_zoomInButton, SIGNAL(startDragMode(bool, QPoint)),
-            this, SLOT(setDraggable(bool, QPoint)));
-    connect(m_zoomOutButton, SIGNAL(startDragMode(bool, QPoint)),
-            this, SLOT(setDraggable(bool, QPoint)));
-
     m_dragStartTimer = new QTimer(this);
     m_dragStartTimer->setSingleShot(true);
+    m_dragStartTimer->setInterval(DRAG_INIT_TIME);
+
+    m_forceReleaseTimer = new QTimer(this);
+    m_forceReleaseTimer->setSingleShot(true);
+    m_forceReleaseTimer->setInterval(FORCE_RELEASE_TIME);
+
+    connect(m_zoomInButton, SIGNAL(pressed()),
+            m_dragStartTimer, SLOT(start()));
+    connect(m_zoomInButton, SIGNAL(released()),
+            m_dragStartTimer, SLOT(stop()));
+    connect(m_zoomOutButton, SIGNAL(pressed()),
+            m_dragStartTimer, SLOT(start()));
+    connect(m_zoomOutButton, SIGNAL(released()),
+            m_dragStartTimer, SLOT(stop()));
+
     connect(m_dragStartTimer, SIGNAL(timeout()),
             this, SLOT(timerExpired()));
+    connect(m_forceReleaseTimer, SIGNAL(timeout()),
+            this, SLOT(forceMouseRelease()));
 }
 
 void ZoomButtonPanel::mouseMoveEvent(QMouseEvent *event)
@@ -78,23 +88,24 @@ void ZoomButtonPanel::mouseMoveEvent(QMouseEvent *event)
     if(m_isDraggable) {
         if (event->buttons() & Qt::LeftButton) {
             QPoint newLocation = mapToParent(event->pos()) - m_dragPosition;
-            if (newLocation.x() < SIDEBAR_WIDTH) {
+
+            if (newLocation.x() < SIDEBAR_WIDTH)
                 newLocation.rx() = SIDEBAR_WIDTH;
-            }
-            else if (newLocation.x() > m_screenSize.width()
-                - m_eventBlocker->width()){
-                newLocation.rx() =  m_screenSize.width() - m_eventBlocker->width();
-            }
-            if (newLocation.y() < 0){
+            else if (newLocation.x() > m_screenSize.width() - width() - SIDEBAR_WIDTH)
+                newLocation.rx() =  m_screenSize.width() - width() - SIDEBAR_WIDTH;
+
+            if (newLocation.y() < 0)
                 newLocation.ry() = 0;
-            }
-            else if (newLocation.y() > m_screenSize.height() - m_eventBlocker->height()) {
-                newLocation.ry() = m_screenSize.height() - m_eventBlocker->height();
-            }
+            else if (newLocation.y() > m_screenSize.height() - height())
+                newLocation.ry() = m_screenSize.height() - height();
+
             move(newLocation);
-            event->accept();
         }
+    } else {
+        if(!rect().contains(event->pos()))
+            m_dragStartTimer->stop();
     }
+    QWidget::mouseMoveEvent(event);
 }
 
 void ZoomButtonPanel::mousePressEvent(QMouseEvent *event)
@@ -103,28 +114,37 @@ void ZoomButtonPanel::mousePressEvent(QMouseEvent *event)
 
     if (event->button() == Qt::LeftButton) {
         m_dragPosition = event->pos();
-        event->accept();
     }
-    m_dragStartTimer->start(DRAG_INIT_TIME);
+    m_dragStartTimer->start();
+    QWidget::mousePressEvent(event);
 }
 
 void ZoomButtonPanel::mouseReleaseEvent(QMouseEvent *event)
 {
+    qDebug() << __PRETTY_FUNCTION__;
+    
+    m_dragStartTimer->stop();
+
     Q_UNUSED(event);
-    setDraggable(false);
-    QSettings settings(DIRECTORY_NAME, FILE_NAME);
-    settings.setValue(ZOOMPANEL_POSITION, pos());
-    releaseMouse();
+    if(m_isDraggable) {
+        setDraggable(false);
+        QSettings settings(DIRECTORY_NAME, FILE_NAME);
+        settings.setValue(ZOOMPANEL_POSITION, pos());
+        releaseMouse();
+        m_zoomInButton->setDown(false);
+        m_zoomOutButton->setDown(false);
+    }
+    QWidget::mouseReleaseEvent(event);
 }
 
-const ImageButton* ZoomButtonPanel::zoomInButton()
+const ZoomButton* ZoomButtonPanel::zoomInButton()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
     return m_zoomInButton;
 }
 
-const ImageButton* ZoomButtonPanel::zoomOutButton()
+const ZoomButton* ZoomButtonPanel::zoomOutButton()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -155,33 +175,72 @@ void ZoomButtonPanel::resetButtons()
 
 void ZoomButtonPanel::setDraggable(bool mode, QPoint eventPosition)
 {
-    if(mode == true) {
-        m_eventBlocker->setAttribute(Qt::WA_TransparentForMouseEvents, false);
-        m_isDraggable = mode;
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_isDraggable = mode;
+
+    if(mode) {
         setAutoFillBackground(true);
+
         m_zoomInMode = m_zoomInButton->mode();
         m_zoomOutMode = m_zoomOutButton->mode();
+
         m_zoomInButton->setMode(QIcon::Disabled);
         m_zoomOutButton->setMode(QIcon::Disabled);
         grabMouse();
+        m_forceReleaseTimer->start();
         m_dragPosition = eventPosition;
-    }
-    else {
-        m_eventBlocker->setAttribute(Qt::WA_TransparentForMouseEvents, true);
-        m_isDraggable = mode;
+    } else {
         setAutoFillBackground(false);
-        m_zoomInButton->setMode(m_zoomInMode);
-        m_zoomOutButton->setMode(m_zoomOutMode);
+        if(m_zoomInMode == QIcon::Selected)
+            m_zoomInButton->setMode(QIcon::Normal);
+        else
+            m_zoomInButton->setMode(m_zoomInMode);
+        if(m_zoomOutMode == QIcon::Selected)
+            m_zoomOutButton->setMode(QIcon::Normal);
+        else
+            m_zoomOutButton->setMode(m_zoomOutMode);
         releaseMouse();
+        m_forceReleaseTimer->stop();
+        m_zoomInButton->setDown(false);
+        m_zoomOutButton->setDown(false);
     }
 }
 
-void ZoomButtonPanel::screenResized(const QSize &size)
+void ZoomButtonPanel::screenResized(const QSize &newSize)
 {
-    m_screenSize = size;
+    qDebug() << __PRETTY_FUNCTION__;
+    
+    m_screenSize = newSize;
+
+    QPoint resizedPosition = pos();
+    if(resizedPosition.x() > (newSize.width() - rect().width()) - SIDEBAR_WIDTH)
+        resizedPosition.rx() = newSize.width() - rect().width() - SIDEBAR_WIDTH;
+    else if (resizedPosition.x() < SIDEBAR_WIDTH)
+        resizedPosition.rx() = SIDEBAR_WIDTH;
+    if(resizedPosition.y() > (newSize.height() - rect().height()))
+        resizedPosition.ry() = newSize.height() - rect().height();
+    else if (resizedPosition.y() < 0)
+        resizedPosition.ry() = 0;
+    move(resizedPosition);
+}
+
+void ZoomButtonPanel::forceMouseRelease()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    releaseMouse();
+    setDraggable(false);
 }
 
 void ZoomButtonPanel::timerExpired()
 {
+    qDebug() << __PRETTY_FUNCTION__;
+    
+    if(m_zoomInButton->isDown())
+        m_dragPosition = m_zoomInButton->eventPosition();
+    if(m_zoomOutButton->isDown())
+        m_dragPosition = m_zoomOutButton->eventPosition();
+
     setDraggable(true, m_dragPosition);
 }
index 913b32f..8da59de 100644 (file)
@@ -27,7 +27,7 @@
 #include <QGridLayout>
 #include <QGraphicsItem>
 
-#include "imagebutton.h"
+#include "zoombutton.h"
 
 /**
  * @brief Panel for zoom buttons
@@ -47,7 +47,7 @@ public:
      * @param x Panel x coordinate
      * @param y Panel y coordinate
      */
-    ZoomButtonPanel(QWidget *parent = 0, int x = 0, int y = 0);
+    ZoomButtonPanel(QWidget *parent = 0);
 
 /*******************************************************************************
  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
@@ -83,14 +83,14 @@ public:
     *
     * @return Pointer to the zoomInButton
     */
-    const ImageButton* zoomInButton();
+    const ZoomButton* zoomInButton();
 
     /**
     * @brief Getter for the zoom out button
     *
     * @return Pointer to the zoomOutButton
     */
-    const ImageButton* zoomOutButton();
+    const ZoomButton* zoomOutButton();
 
 public slots:
     /**
@@ -122,17 +122,18 @@ public slots:
 
 private slots:
     /**
-     * @brief Slot to emit signal to zoom button panel to start drag mode after timer timeout
+     * @brief Safeguard slot to release mouse grab if something goes horribly wrong
+     */
+    void forceMouseRelease();
+
+    /**
+     * @brief Slot that handles drag initialization once timer has timed out
      */
     void timerExpired();
 
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
-public:
-    ImageButton *m_zoomInButton;    ///< Button for zoom in
-    ImageButton *m_zoomOutButton;   ///< Button for zoom out
-
 private:
     bool m_isDraggable;             ///< Boolean for tracking the draggability state
 
@@ -146,8 +147,10 @@ private:
     QSize m_screenSize;             ///< Store for the screen size
 
     QTimer *m_dragStartTimer;       ///< Timer to init draggability of the zoom panel
+    QTimer *m_forceReleaseTimer;    ///< Timer to run forceMouseRelease;
 
-    QWidget *m_eventBlocker;        ///< Overlaying widget that catches the mouse events
+    ZoomButton *m_zoomInButton;    ///< Button for zoom in
+    ZoomButton *m_zoomOutButton;   ///< Button for zoom out
 };
 
 #endif // ZOOMBUTTONPANEL_H
index f80ac96..eb2060c 100644 (file)
@@ -2,12 +2,12 @@
 # Automatically generated by qmake (2.01a) Fri Mar 26 15:09:16 2010
 # #####################################################################
 CONFIG += qtestlib
-QT += network
+QT += network dbus
 TEMPLATE = app
-TARGET = 
 DEPENDPATH += .
 INCLUDEPATH += . \
-    ../../../src/
+    ../../../src/ \
+    /usr/include/glib-2.0 /usr/lib/glib-2.0/include
 
 # Input
 SOURCES += testfriendgroupitem.cpp \
@@ -22,7 +22,10 @@ SOURCES += testfriendgroupitem.cpp \
     ../../../src/map/mapfetcher.cpp \
     ../../../src/map/frienditemshandler.cpp \
     ../../../src/user/user.cpp \
-    ../../../src/map/gpslocationitem.cpp
+    ../../../src/map/gpslocationitem.cpp \
+    ../../../src/network/networkaccessmanager.cpp \
+    ../../../src/network/networkhandler.cpp \
+    ../../../src/network/networkreply.cpp
 HEADERS += ../../../src/map/friendgroupitem.h \
     ../../../src/map/friendlocationitem.h \
     ../../../src/map/baselocationitem.h \
@@ -35,6 +38,32 @@ HEADERS += ../../../src/map/friendgroupitem.h \
     ../../../src/map/mapcommon.h \
     ../../../src/map/frienditemshandler.h \
     ../../../src/user/user.h \
-    ../../../src/map/gpslocationitem.h
+    ../../../src/map/gpslocationitem.h \
+    ../../../src/network/networkaccessmanager.h \
+    ../../../src/network/networkhandler.h \
+    ../../../src/network/networkreply.h
 DEFINES += QT_NO_DEBUG_OUTPUT
 RESOURCES += ../../../images.qrc
+
+maemo5 | simulator {
+    INCLUDEPATH += /usr/include/glib-2.0 /usr/lib/glib-2.0/include
+    SOURCES += ../../../src/network/networkhandlerprivate.cpp
+    HEADERS += ../../../src/network/networkhandlerprivate.h
+    QT += maemo5 dbus
+    CONFIG += icd2
+    message([QJson])
+    message(Make sure you have QJson development headers installed)
+    message(add: deb http://repository.maemo.org/extras-devel fremantle free non-free)
+    message(to Scratchbox's sources.list in /etc/apt)
+    message(run: apt-get update)
+    message(install headers with: apt-get install libqjson-dev)
+    message([QtMobility])
+    message(Make sure you have QtMobility development headers installed)
+    message(install headers with: apt-get install libqtm-dev)
+} else {
+    SOURCES += ../../../src/network/networkhandlerprivatestub.cpp
+    HEADERS += ../../../src/network/networkhandlerprivatestub.h
+    message(QJson built in)
+    message(Make sure you have QJson development headers installed)
+    message(install headers with: sudo apt-get install libqjson-dev)
+}
index e62134f..45dba5e 100644 (file)
@@ -2,11 +2,12 @@
 # Automatically generated by qmake (2.01a) Tue Apr 27 14:52:31 2010
 # #####################################################################
 CONFIG += qtestlib
-QT += network
+QT += network dbus
 TEMPLATE = app
 DEPENDPATH += .
 INCLUDEPATH += . \
-    ../../../src/
+    ../../../src/ \
+    /usr/include/glib-2.0 /usr/lib/glib-2.0/include
 RESOURCES += ../../../images.qrc
 
 # Input
@@ -23,7 +24,10 @@ SOURCES += testfriendlocationitem.cpp \
     ../../../src/map/maptilerequest.cpp \
     ../../../src/map/frienditemshandler.cpp \
     ../../../src/map/friendgroupitem.cpp \
-    ../../../src/map/gpslocationitem.cpp
+    ../../../src/map/gpslocationitem.cpp \
+    ../../../src/network/networkaccessmanager.cpp \
+    ../../../src/network/networkhandler.cpp \
+    ../../../src/network/networkreply.cpp
 HEADERS += ../../../src/map/ownlocationitem.h \
     ../../../src/map/mapscene.h \
     ../../../src/map/maptile.h \
@@ -37,6 +41,33 @@ HEADERS += ../../../src/map/ownlocationitem.h \
     ../../../src/map/maptilerequest.h \
     ../../../src/map/frienditemshandler.h \
     ../../../src/map/friendgroupitem.h \
-    ../../../src/map/gpslocationitem.h
+    ../../../src/map/gpslocationitem.h \
+    ../../../src/network/networkaccessmanager.h \
+    ../../../src/network/networkhandler.h \
+    ../../../src/network/networkreply.h
 
 DEFINES += QT_NO_DEBUG_OUTPUT
+
+maemo5 | simulator {
+    INCLUDEPATH += /usr/include/glib-2.0 /usr/lib/glib-2.0/include
+    SOURCES += ../../../src/network/networkhandlerprivate.cpp
+    HEADERS += ../../../src/network/networkhandlerprivate.h
+    QT += maemo5 dbus
+    CONFIG += icd2
+    message([QJson])
+    message(Make sure you have QJson development headers installed)
+    message(add: deb http://repository.maemo.org/extras-devel fremantle free non-free)
+    message(to Scratchbox's sources.list in /etc/apt)
+    message(run: apt-get update)
+    message(install headers with: apt-get install libqjson-dev)
+    message([QtMobility])
+    message(Make sure you have QtMobility development headers installed)
+    message(install headers with: apt-get install libqtm-dev)
+} else {
+    SOURCES += ../../../src/network/networkhandlerprivatestub.cpp
+    HEADERS += ../../../src/network/networkhandlerprivatestub.h
+    message(QJson built in)
+    message(Make sure you have QJson development headers installed)
+    message(install headers with: sudo apt-get install libqjson-dev)
+}
+
index 9f0579c..575514c 100644 (file)
@@ -16,3 +16,27 @@ HEADERS += \
     ../../../src/map/gpslocationitem.h
 DEFINES += QT_NO_DEBUG_OUTPUT
 RESOURCES += ../../../images.qrc
+
+maemo5 | simulator {
+    INCLUDEPATH += /usr/include/glib-2.0 /usr/lib/glib-2.0/include
+    SOURCES += ../../../src/network/networkhandlerprivate.cpp
+    HEADERS += ../../../src/network/networkhandlerprivate.h
+    QT += maemo5 dbus
+    CONFIG += icd2
+    message([QJson])
+    message(Make sure you have QJson development headers installed)
+    message(add: deb http://repository.maemo.org/extras-devel fremantle free non-free)
+    message(to Scratchbox's sources.list in /etc/apt)
+    message(run: apt-get update)
+    message(install headers with: apt-get install libqjson-dev)
+    message([QtMobility])
+    message(Make sure you have QtMobility development headers installed)
+    message(install headers with: apt-get install libqtm-dev)
+} else {
+    SOURCES += ../../../src/network/networkhandlerprivatestub.cpp
+    HEADERS += ../../../src/network/networkhandlerprivatestub.h
+    message(QJson built in)
+    message(Make sure you have QJson development headers installed)
+    message(install headers with: sudo apt-get install libqjson-dev)
+}
+
index db044cf..380f4bd 100644 (file)
@@ -2,11 +2,12 @@
 # Automatically generated by qmake (2.01a) Fri Mar 26 15:09:16 2010
 # #####################################################################
 CONFIG += qtestlib
-QT += network
+QT += network dbus
 TEMPLATE = app
 DEPENDPATH += .
 INCLUDEPATH += . \
-    ../../../src/
+    ../../../src/ \
+    /usr/include/glib-2.0 /usr/lib/glib-2.0/include
 
 # Input
 SOURCES += testmapengine.cpp \
@@ -22,7 +23,10 @@ SOURCES += testmapengine.cpp \
     ../../../src/map/baselocationitem.cpp \
     ../../../src/user/user.cpp \
     ../../../src/map/friendlocationitem.cpp \
-    ../../../src/map/gpslocationitem.cpp
+    ../../../src/map/gpslocationitem.cpp \
+    ../../../src/network/networkaccessmanager.cpp \
+    ../../../src/network/networkhandler.cpp \
+    ../../../src/network/networkreply.cpp
 HEADERS += ../../../src/map/mapengine.h \
     ../../../src/map/mapscene.h \
     ../../../src/map/maptile.h \
@@ -36,5 +40,32 @@ HEADERS += ../../../src/map/mapengine.h \
     ../../../src/map/baselocationitem.h \
     ../../../src/user/user.h \
     ../../../src/map/friendlocationitem.h \
-    ../../../src/map/gpslocationitem.h
+    ../../../src/map/gpslocationitem.h \
+    ../../../src/network/networkaccessmanager.h \
+    ../../../src/network/networkhandler.h \
+    ../../../src/network/networkreply.h
 DEFINES += QT_NO_DEBUG_OUTPUT
+
+maemo5 | simulator {
+    INCLUDEPATH += /usr/include/glib-2.0 /usr/lib/glib-2.0/include
+    SOURCES += ../../../src/network/networkhandlerprivate.cpp
+    HEADERS += ../../../src/network/networkhandlerprivate.h
+    QT += maemo5 dbus
+    CONFIG += icd2
+    message([QJson])
+    message(Make sure you have QJson development headers installed)
+    message(add: deb http://repository.maemo.org/extras-devel fremantle free non-free)
+    message(to Scratchbox's sources.list in /etc/apt)
+    message(run: apt-get update)
+    message(install headers with: apt-get install libqjson-dev)
+    message([QtMobility])
+    message(Make sure you have QtMobility development headers installed)
+    message(install headers with: apt-get install libqtm-dev)
+} else {
+    SOURCES += ../../../src/network/networkhandlerprivatestub.cpp
+    HEADERS += ../../../src/network/networkhandlerprivatestub.h
+    message(QJson built in)
+    message(Make sure you have QJson development headers installed)
+    message(install headers with: sudo apt-get install libqjson-dev)
+}
+
index 960ad11..c3b1fad 100644 (file)
 #include <QGraphicsScene>
 #include <QtTest/QtTest>
 
+#include "common.h"
 #include "map/mapcommon.h"
 #include "map/mapengine.h"
 
+const int DEFAULT_TEST_ZOOMLEVEL = 5;
+const QPoint DEFAULT_TEST_SCENECOORDINATE = QPoint(12345,54321);
+const QPoint NEW_TEST_SCENECOORDINATE = QPoint(50000,40000);
+
 class TestMapEngine: public QObject
 {
     Q_OBJECT
@@ -37,6 +42,7 @@ private slots:
     void setLocationRemovedTilesCount();
     void zoomOutRemovedTilesCount();
     void zoomInRemovedTilesCount();
+    void usingLastLocation();
 };
 
 /**
@@ -160,5 +166,51 @@ void TestMapEngine::zoomOutRemovedTilesCount()
     QVERIFY(engine.scene()->items().count() <= maxItemsCount);
 }
 
+void TestMapEngine::usingLastLocation()
+{
+    // Create mapengine and start monitoring zoomLevelChanged-signal
+    MapEngine *mapengine = new MapEngine;
+    QSignalSpy mapEngineSpy(mapengine, SIGNAL(zoomLevelChanged(int)));
+    QVERIFY (mapEngineSpy.isValid());
+    QCOMPARE (mapEngineSpy.count(), 0);
+
+    // Write new zoomlevel and location to settings
+    QSettings settings(DIRECTORY_NAME, FILE_NAME);
+    settings.setValue(MAP_LAST_ZOOMLEVEL, DEFAULT_TEST_ZOOMLEVEL);
+    settings.setValue(MAP_LAST_POSITION,
+                      mapengine->convertSceneCoordinateToLatLon(DEFAULT_TEST_ZOOMLEVEL,
+                                                                DEFAULT_TEST_SCENECOORDINATE));
+
+    // Call mapengines init() and verify that signal will be send
+    mapengine->init();
+    QCOMPARE (mapEngineSpy.count(), 1);
+
+    // Remove zoomlevel and location from settings, call init() again and check that
+    // signals is send again
+    settings.remove(MAP_LAST_ZOOMLEVEL);
+    settings.remove(MAP_LAST_POSITION);
+    mapengine->init();
+    QCOMPARE(mapEngineSpy.count(), 2);
+
+    // Check parameters of sended signals
+    QList<QVariant> parameters = mapEngineSpy.takeFirst();
+    QVERIFY(parameters.at(0).toInt() == DEFAULT_TEST_ZOOMLEVEL);
+
+    parameters = mapEngineSpy.takeFirst();
+    QVERIFY(parameters.at(0).toInt() == DEFAULT_START_ZOOM_LEVEL);
+
+    // Call set location with know parameter to get location changed
+    // Store new location and zoomlevel to settings
+    mapengine->setLocation(NEW_TEST_SCENECOORDINATE);
+    delete mapengine;
+
+    // Read settings and verify that zoomlevel is correct
+    MapEngine testengine;// = new mapEngine;
+    QPointF LatLonLocation =
+            settings.value(MAP_LAST_POSITION, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toPointF();
+    QCOMPARE(LatLonLocation, testengine.convertSceneCoordinateToLatLon(DEFAULT_TEST_ZOOMLEVEL,
+                                                                      NEW_TEST_SCENECOORDINATE));
+}
+
 QTEST_MAIN(TestMapEngine)
 #include "testmapengine.moc"
index 9cea0ce..92fa786 100644 (file)
@@ -2,12 +2,12 @@
 # Automatically generated by qmake (2.01a) Mon Mar 29 10:06:28 2010
 # #####################################################################
 CONFIG += qtestlib
-QT += network
+QT += network dbus
 TEMPLATE = app
-TARGET = 
 DEPENDPATH += .
 INCLUDEPATH += . \
-    ../../../src/
+    ../../../src/ \
+    /usr/include/glib-2.0 /usr/lib/glib-2.0/include
 
 # Input
 SOURCES += testmapscene.cpp \
@@ -22,7 +22,10 @@ SOURCES += testmapscene.cpp \
     ../../../src/map/frienditemshandler.cpp \
     ../../../src/map/friendgroupitem.cpp \
     ../../../src/map/baselocationitem.cpp \
-    ../../../src/map/gpslocationitem.cpp
+    ../../../src/map/gpslocationitem.cpp \
+    ../../../src/network/networkaccessmanager.cpp \
+    ../../../src/network/networkhandler.cpp \
+    ../../../src/network/networkreply.cpp
 HEADERS += ../../../src/map/mapscene.h \
     ../../../src/map/maptile.h \
     ../../../src/map/mapengine.h \
@@ -34,5 +37,31 @@ HEADERS += ../../../src/map/mapscene.h \
     ../../../src/map/frienditemshandler.h \
     ../../../src/map/friendgroupitem.h \
     ../../../src/map/baselocationitem.h \
-    ../../../src/map/gpslocationitem.h
+    ../../../src/map/gpslocationitem.h \
+    ../../../src/network/networkaccessmanager.h \
+    ../../../src/network/networkhandler.h \
+    ../../../src/network/networkreply.h
 DEFINES += QT_NO_DEBUG_OUTPUT
+
+maemo5 | simulator {
+    INCLUDEPATH += /usr/include/glib-2.0 /usr/lib/glib-2.0/include
+    SOURCES += ../../../src/network/networkhandlerprivate.cpp
+    HEADERS += ../../../src/network/networkhandlerprivate.h
+    QT += maemo5 dbus
+    CONFIG += icd2
+    message([QJson])
+    message(Make sure you have QJson development headers installed)
+    message(add: deb http://repository.maemo.org/extras-devel fremantle free non-free)
+    message(to Scratchbox's sources.list in /etc/apt)
+    message(run: apt-get update)
+    message(install headers with: apt-get install libqjson-dev)
+    message([QtMobility])
+    message(Make sure you have QtMobility development headers installed)
+    message(install headers with: apt-get install libqtm-dev)
+} else {
+    SOURCES += ../../../src/network/networkhandlerprivatestub.cpp
+    HEADERS += ../../../src/network/networkhandlerprivatestub.h
+    message(QJson built in)
+    message(Make sure you have QJson development headers installed)
+    message(install headers with: sudo apt-get install libqjson-dev)
+}
index 6baaf4f..9bc4918 100644 (file)
@@ -2,12 +2,13 @@
 # Automatically generated by qmake (2.01a) Mon Mar 29 10:06:28 2010
 # #####################################################################
 CONFIG += qtestlib
-QT += network
+QT += network dbus
 TEMPLATE = app
 TARGET = 
 DEPENDPATH += .
 INCLUDEPATH += . \
-    ../../../src/
+    ../../../src/ \
+    /usr/include/glib-2.0 /usr/lib/glib-2.0/include
 
 # Input
 SOURCES += testmaptile.cpp \
@@ -22,7 +23,10 @@ SOURCES += testmaptile.cpp \
     ../../../src/map/friendgroupitem.cpp \
     ../../../src/map/baselocationitem.cpp \
     ../../../src/user/user.cpp \
-    ../../../src/map/gpslocationitem.cpp
+    ../../../src/map/gpslocationitem.cpp \
+    ../../../src/network/networkaccessmanager.cpp \
+    ../../../src/network/networkhandler.cpp \
+    ../../../src/network/networkreply.cpp
 HEADERS += ../../../src/map/maptile.h \
     ../../../src/map/mapfetcher.h \
     ../../../src/map/mapengine.h \
@@ -34,5 +38,31 @@ HEADERS += ../../../src/map/maptile.h \
     ../../../src/map/friendgroupitem.h \
     ../../../src/map/baselocationitem.h \
     ../../../src/user/user.h \
-    ../../../src/map/gpslocationitem.h
+    ../../../src/map/gpslocationitem.h \
+    ../../../src/network/networkaccessmanager.h \
+    ../../../src/network/networkhandler.h \
+    ../../../src/network/networkreply.h
 DEFINES += QT_NO_DEBUG_OUTPUT
+
+maemo5 | simulator {
+    INCLUDEPATH += /usr/include/glib-2.0 /usr/lib/glib-2.0/include
+    SOURCES += ../../../src/network/networkhandlerprivate.cpp
+    HEADERS += ../../../src/network/networkhandlerprivate.h
+    QT += maemo5 dbus
+    CONFIG += icd2
+    message([QJson])
+    message(Make sure you have QJson development headers installed)
+    message(add: deb http://repository.maemo.org/extras-devel fremantle free non-free)
+    message(to Scratchbox's sources.list in /etc/apt)
+    message(run: apt-get update)
+    message(install headers with: apt-get install libqjson-dev)
+    message([QtMobility])
+    message(Make sure you have QtMobility development headers installed)
+    message(install headers with: apt-get install libqtm-dev)
+} else {
+    SOURCES += ../../../src/network/networkhandlerprivatestub.cpp
+    HEADERS += ../../../src/network/networkhandlerprivatestub.h
+    message(QJson built in)
+    message(Make sure you have QJson development headers installed)
+    message(install headers with: sudo apt-get install libqjson-dev)
+}
index aa145fa..1a869da 100644 (file)
@@ -2,7 +2,6 @@
 # Automatically generated by qmake (2.01a) Fri Mar 26 15:22:56 2010
 # #####################################################################
 CONFIG += qtestlib
-QT += opengl
 TEMPLATE = app
 TARGET = 
 DEPENDPATH += .
index 79f2237..a2292f6 100644 (file)
@@ -2,11 +2,12 @@
 # Automatically generated by qmake (2.01a) Tue Apr 27 14:52:31 2010
 # #####################################################################
 CONFIG += qtestlib
-QT += network
+QT += network dbus
 TEMPLATE = app
 DEPENDPATH += .
 INCLUDEPATH += . \
-    ../../../src/
+    ../../../src/ \
+    /usr/include/glib-2.0 /usr/lib/glib-2.0/include
 RESOURCES += ../../../images.qrc
 
 # Input
@@ -23,7 +24,10 @@ SOURCES += testownlocationitem.cpp \
     ../../../src/map/maptilerequest.cpp \
     ../../../src/map/frienditemshandler.cpp \
     ../../../src/map/friendgroupitem.cpp \
-    ../../../src/map/gpslocationitem.cpp
+    ../../../src/map/gpslocationitem.cpp \
+    ../../../src/network/networkaccessmanager.cpp \
+    ../../../src/network/networkhandler.cpp \
+    ../../../src/network/networkreply.cpp
 HEADERS += ../../../src/map/ownlocationitem.h \
     ../../../src/map/mapscene.h \
     ../../../src/map/maptile.h \
@@ -37,5 +41,31 @@ HEADERS += ../../../src/map/ownlocationitem.h \
     ../../../src/map/maptilerequest.h \
     ../../../src/map/frienditemshandler.h \
     ../../../src/map/friendgroupitem.h \
-    ../../../src/map/gpslocationitem.h
+    ../../../src/map/gpslocationitem.h \
+    ../../../src/network/networkaccessmanager.h \
+    ../../../src/network/networkhandler.h \
+    ../../../src/network/networkreply.h
 DEFINES += QT_NO_DEBUG_OUTPUT
+
+maemo5 | simulator {
+    INCLUDEPATH += /usr/include/glib-2.0 /usr/lib/glib-2.0/include
+    SOURCES += ../../../src/network/networkhandlerprivate.cpp
+    HEADERS += ../../../src/network/networkhandlerprivate.h
+    QT += maemo5 dbus
+    CONFIG += icd2
+    message([QJson])
+    message(Make sure you have QJson development headers installed)
+    message(add: deb http://repository.maemo.org/extras-devel fremantle free non-free)
+    message(to Scratchbox's sources.list in /etc/apt)
+    message(run: apt-get update)
+    message(install headers with: apt-get install libqjson-dev)
+    message([QtMobility])
+    message(Make sure you have QtMobility development headers installed)
+    message(install headers with: apt-get install libqtm-dev)
+} else {
+    SOURCES += ../../../src/network/networkhandlerprivatestub.cpp
+    HEADERS += ../../../src/network/networkhandlerprivatestub.h
+    message(QJson built in)
+    message(Make sure you have QJson development headers installed)
+    message(install headers with: sudo apt-get install libqjson-dev)
+}
diff --git a/tests/map/uselastlocation/testuselastlocation.cpp b/tests/map/uselastlocation/testuselastlocation.cpp
deleted file mode 100644 (file)
index 15f2156..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-    Situare - A location system for Facebook
-    Copyright (C) 2010  Ixonos Plc. Authors:
-
-        Ville Tiensuu - ville.tiensuu@ixonos.com
-
-    Situare is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License
-    version 2 as published by the Free Software Foundation.
-
-    Situare is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with Situare; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
-    USA.
-*/
-
-#include <QtTest/QtTest>
-#include <QDebug>
-#include "map/mapengine.h"
-#include "map/mapcommon.h"
-#include "common.h"
-#include "ui/mainwindow.h"
-
-const int DEFAULT_TEST_ZOOMLEVEL = 5;
-const QPoint DEFAULT_TEST_SCENECOORDINATE = QPoint(12345,54321);
-const QPoint NEW_TEST_SCENECOORDINATE = QPoint(50000,40000);
-
-class TestUseLastPosition: public QObject
- {
-     Q_OBJECT
- private slots:
-
-     void testMapEngineMethods();
- };
-
- void TestUseLastPosition::testMapEngineMethods()
- {
-     // Create mapengine and start monitoring zoomLevelChanged-signal
-     MapEngine *mapengine = new MapEngine;
-     QSignalSpy mapEngineSpy(mapengine, SIGNAL(zoomLevelChanged(int)));
-     QVERIFY (mapEngineSpy.isValid());
-     QCOMPARE (mapEngineSpy.count(), 0);
-
-     // Write new zoomlevel and location to settings
-     QSettings settings(DIRECTORY_NAME, FILE_NAME);
-     settings.setValue(MAP_LAST_ZOOMLEVEL, DEFAULT_TEST_ZOOMLEVEL);
-     settings.setValue(MAP_LAST_POSITION,
-                       mapengine->convertSceneCoordinateToLatLon(DEFAULT_TEST_ZOOMLEVEL,
-                                                                 DEFAULT_TEST_SCENECOORDINATE));
-
-     // Call mapengines init() and verify that signal will be send
-     mapengine->init();
-     QCOMPARE (mapEngineSpy.count(), 1);
-
-     // Remove zoomlevel and location from settings, call init() again and check that
-     // signals is send again
-     settings.remove(MAP_LAST_ZOOMLEVEL);
-     settings.remove(MAP_LAST_POSITION);
-     mapengine->init();
-     QCOMPARE(mapEngineSpy.count(), 2);
-
-     // Check parameters of sended signals
-     QList<QVariant> parameters = mapEngineSpy.takeFirst();
-     QVERIFY(parameters.at(0).toInt() == DEFAULT_TEST_ZOOMLEVEL);
-//     parameters = mapEngineSpy.takeFirst();
-//     QVERIFY(parameters.at(0).toInt() == 0);
-     parameters = mapEngineSpy.takeFirst();
-     QVERIFY(parameters.at(0).toInt() == DEFAULT_START_ZOOM_LEVEL);
-
-     // Call set location with know parameter to get location changed
-     // Store new location and zoomlevel to settings
-     mapengine->setLocation(NEW_TEST_SCENECOORDINATE);
-     delete mapengine;
-
-     // Read settings and verify that zoomlevel is correct
-     MapEngine testengine;// = new mapEngine;
-     QPointF LatLonLocation =
-             settings.value(MAP_LAST_POSITION, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toPointF();
-     QCOMPARE(LatLonLocation, testengine.convertSceneCoordinateToLatLon(DEFAULT_TEST_ZOOMLEVEL,
-                                                                       NEW_TEST_SCENECOORDINATE));
- }
-
- QTEST_MAIN(TestUseLastPosition)
- #include "testuselastlocation.moc"
diff --git a/tests/map/uselastlocation/uselastlocation.pro b/tests/map/uselastlocation/uselastlocation.pro
deleted file mode 100644 (file)
index 8d92a32..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-# #####################################################################
-# Automatically generated by qmake (2.01a) Tue Apr 27 14:52:31 2010
-# #####################################################################
-CONFIG += qtestlib
-QT += network \
-      webkit
-TEMPLATE = app
-TARGET = uselastlocation
-DEPENDPATH += .
-INCLUDEPATH += . \
-    ../../../src/
-RESOURCES += ../../../images.qrc
-
-# Input
-SOURCES += testuselastlocation.cpp \
-    ../../../src/map/mapengine.cpp \
-    ../../../src/map/mapscene.cpp \
-    ../../../src/map/mapfetcher.cpp \
-    ../../../src/map/ownlocationitem.cpp \
-    ../../../src/map/gpslocationitem.cpp \
-    ../../../src/map/frienditemshandler.cpp \
-    ../../../src/map/maptile.cpp \
-    ../../../src/user/user.cpp \
-    ../../../src/map/maptilerequest.cpp \
-    ../../../src/map/baselocationitem.cpp \
-    ../../../src/map/friendlocationitem.cpp \
-    ../../../src/map/friendgroupitem.cpp \
-    ../../../src/ui/mainwindow.cpp \
-    ../../../src/ui/mapviewscreen.cpp \
-    ../../../src/ui/settingsdialog.cpp \
-    ../../../src/ui/logindialog.cpp \
-    ../../../src/map/mapview.cpp \
-    ../../../src/ui/friendlistpanel.cpp \
-    ../../../src/ui/userpanel.cpp \
-    ../../../src/ui/panelsidebar.cpp \
-    ../../../src/ui/zoombuttonpanel.cpp \
-    ../../../src/ui/friendlistview.cpp \
-    ../../../src/ui/panelsliderbar.cpp \
-    ../../../src/ui/friendlistitem.cpp \
-    ../../../src/ui/userinfo.cpp \
-    ../../../src/ui/imagebutton.cpp \
-    ../../../src/ui/updatelocation/updatelocationdialog.cpp \
-    ../../../src/ui/updatelocation/texteditautoresizer.cpp
-
-HEADERS += ../../../src/map/mapengine.h \
-    ../../../src/map/mapscene.h \
-    ../../../src/map/mapfetcher.h \
-    ../../../src/map/ownlocationitem.h \
-    ../../../src/map/gpslocationitem.h \
-    ../../../src/map/frienditemshandler.h \
-    ../../../src/map/maptile.h \
-    ../../../src/user/user.h \
-    ../../../src/map/maptilerequest.h \
-    ../../../src/map/baselocationitem.h \
-    ../../../src/map/friendlocationitem.h \
-    ../../../src/map/friendgroupitem.h \
-    ../../../src/ui/mainwindow.h \
-    ../../../src/ui/mapviewscreen.h \
-    ../../../src/ui/settingsdialog.h \
-    ../../../src/ui/logindialog.h \
-    ../../../src/map/mapview.h \
-    ../../../src/ui/friendlistpanel.h \
-    ../../../src/ui/userpanel.h \
-    ../../../src/ui/panelsidebar.h \
-    ../../../src/ui/zoombuttonpanel.h \
-    ../../../src/ui/friendlistview.h \
-    ../../../src/ui/panelsliderbar.h \
-    ../../../src/ui/friendlistitem.h \
-    ../../../src/ui/userinfo.h \
-    ../../../src/ui/imagebutton.h \
-    ../../../src/ui/updatelocation/updatelocationdialog.h \
-    ../../../src/ui/updatelocation/texteditautoresizer.h
-
-
-
-#DEFINES += QT_NO_DEBUG_OUTPUT
index 990fbc4..0b94bef 100644 (file)
@@ -9,4 +9,4 @@ SUBDIRS = map/mapengine \
           map/friendlocationitem \
           user \
           ui/friendlist \
-          ui/zoombuttonpanel
+          ui/sidepanel
index 94de6d8..ce737c4 100644 (file)
@@ -13,3 +13,4 @@ SOURCES += ../../../src/ui/friendlistview.cpp \
     ../../../src/ui/avatarimage.cpp \
     ../../../src/ui/imagebutton.cpp \
     testfriendlist.cpp
+RESOURCES += ../../../images.qrc
diff --git a/tests/ui/friendlist/situare_user.gif b/tests/ui/friendlist/situare_user.gif
new file mode 100644 (file)
index 0000000..cd34a82
Binary files /dev/null and b/tests/ui/friendlist/situare_user.gif differ
index 351dbb2..c8d3d7d 100644 (file)
@@ -51,9 +51,11 @@ void TestFriendList::friendListViewAddWidget()
     User *user1 = new User(QString("Address"), QPointF(12.22, 23.33), QString("Name"),
                            QString("Note"), QUrl("http://image.url"), QString("Timestamp"), true,
                            QString("UserID1"), QString("Units"), 44.12);
+    user1->setProfileImage(QPixmap("situare_user.gif"));
     User *user2 = new User(QString("Address"), QPointF(12.22, 23.33), QString("Name"),
                            QString("Note"), QUrl("http://image.url"), QString("Timestamp"), true,
                            QString("UserID2"), QString("Units"), 44.12);
+    user2->setProfileImage(QPixmap("situare_user.gif"));
 
     FriendListItem *item1 = new FriendListItem(view);
     item1->setData(user1);
@@ -68,6 +70,7 @@ void TestFriendList::friendListViewAddWidget()
     User *user3 = new User(QString("Address"), QPointF(12.22, 23.33), QString("Name"),
                            QString("Note"), QUrl("http://image.url"), QString("Timestamp"), true,
                            QString("UserID3"), QString("Units"), 44.12);
+    user3->setProfileImage(QPixmap("situare_user.gif"));
 
     FriendListItem *item3 = new FriendListItem(view);
     item3->setData(user3);
@@ -87,9 +90,11 @@ void TestFriendList::friendListViewClearUnused()
     User *user1 = new User(QString("Address"), QPointF(12.22, 23.33), QString("Name"),
                            QString("Note"), QUrl("http://image.url"), QString("Timestamp"), true,
                            QString("UserID1"), QString("Units"), 44.12);
+    user1->setProfileImage(QPixmap("situare_user.gif"));
     User *user2 = new User(QString("Address"), QPointF(12.22, 23.33), QString("Name"),
                            QString("Note"), QUrl("http://image.url"), QString("Timestamp"), true,
                            QString("UserID2"), QString("Units"), 44.12);
+    user2->setProfileImage(QPixmap("situare_user.gif"));
 
     FriendListItem *item1 = new FriendListItem(view);
     item1->setData(user1);
diff --git a/tests/ui/sidepanel/sidepanel.pro b/tests/ui/sidepanel/sidepanel.pro
new file mode 100644 (file)
index 0000000..18c6afd
--- /dev/null
@@ -0,0 +1,16 @@
+CONFIG += qtestlib
+TEMPLATE = app
+TARGET +=
+DEPENDPATH += .
+INCLUDEPATH += "../../../src"
+SOURCES += \
+    testsidepanel.cpp \
+    ../../../src/ui/sidepanel.cpp \
+    ../../../src/ui/panelsliderbar.cpp
+
+HEADERS += \
+    ../../../src/ui/sidepanel.h \
+    ../../../src/ui/panelsliderbar.h \
+    ../../../src/ui/panelcommon.h \
+    ../../../src/map/mapcommon.h
+DEFINES += QT_NO_DEBUG_OUTPUT
diff --git a/tests/ui/sidepanel/testsidepanel.pro b/tests/ui/sidepanel/testsidepanel.pro
deleted file mode 100644 (file)
index 99a148c..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += qtestlib
-TEMPLATE = app
-TARGET +=
-DEPENDPATH += .
-INCLUDEPATH += "../../../src"
-SOURCES += \
-    testsidepanel.cpp \
-    ../../../src/ui/sidepanel.cpp \
-    ../../../src/ui/panelsliderbar.cpp
-
-HEADERS += \
-    ../../../src/ui/sidepanel.h \
-    ../../../src/ui/panelsliderbar.h \
-    ../../../src/ui/panelcommon.h \
-    ../../../src/map/mapcommon.h
diff --git a/tests/ui/zoombuttonpanel/testzoombuttonpanel.cpp b/tests/ui/zoombuttonpanel/testzoombuttonpanel.cpp
deleted file mode 100644 (file)
index 58cbdfd..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
-   Situare - A location system for Facebook
-   Copyright (C) 2010  Ixonos Plc. Authors:
-
-       Pekka Nissinen - pekka.nissinen@ixonos.com
-
-   Situare is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License
-   version 2 as published by the Free Software Foundation.
-
-   Situare is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with Situare; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
-   USA.
-*/
-
-#include <QtTest>
-
-#include "../../../src/ui/zoombuttonpanel.h"
-
-class TestZoomButtonPanel : public QObject
-{
-    Q_OBJECT
-
-private slots:
-    /**
-      * @brief Test case for initialization
-      */
-    void init();
-
-    /**
-      * @brief Test case for disabling Zoom In button
-      */
-    void disableZoomIn();
-
-    /**
-      * @brief Test case for disabling Zoom Out button
-      */
-    void disableZoomOut();
-
-    /**
-      * @brief Test case for resetting buttons
-      */
-    void reset();
-};
-
-void TestZoomButtonPanel::init()
-{
-    // Create a new instance of ZoomButtonPanel
-    ZoomButtonPanel zoomButtonPanel(0, 10, 10);
-
-    // Check that panel is positioned to the right place
-    QCOMPARE(zoomButtonPanel.pos(), QPoint(10, 10));
-
-    // Check that both of the buttons images are loaded successfully
-    QVERIFY(zoomButtonPanel.m_zoomInButton != 0);
-    QVERIFY(zoomButtonPanel.m_zoomOutButton != 0);
-
-    // Check that both of the button icons are at normal mode
-    QVERIFY(zoomButtonPanel.m_zoomInButton->mode() == QIcon::Normal);
-    QVERIFY(zoomButtonPanel.m_zoomOutButton->mode() == QIcon::Normal);
-}
-
-void TestZoomButtonPanel::disableZoomIn()
-{
-    // Create a new instance of ZoomButtonPanel
-    ZoomButtonPanel zoomButtonPanel(0, 0, 0);
-
-    // Disable the button
-    zoomButtonPanel.disableZoomInButton();
-
-    // Check that Zoom In button is disabled
-    QVERIFY(zoomButtonPanel.m_zoomInButton->mode() == QIcon::Disabled);
-}
-
-void TestZoomButtonPanel::disableZoomOut()
-{
-    // Create a new instance of ZoomButtonPanel
-    ZoomButtonPanel zoomButtonPanel(0, 0, 0);
-
-    // Disable the button
-    zoomButtonPanel.disableZoomOutButton();
-
-    // Check that Zoom In button is disabled
-    QVERIFY(zoomButtonPanel.m_zoomOutButton->mode() == QIcon::Disabled);
-}
-
-void TestZoomButtonPanel::reset()
-{
-    // Create a new instance of ZoomButtonPanel
-    ZoomButtonPanel zoomButtonPanel(0, 0, 0);
-
-    // Set both buttons to disabled mode
-    zoomButtonPanel.m_zoomInButton->setMode(QIcon::Disabled);
-    zoomButtonPanel.m_zoomOutButton->setMode(QIcon::Disabled);
-
-    // Reset the buttons
-    zoomButtonPanel.resetButtons();
-
-    // Check that both buttons are properly resetted to normal mode
-    QVERIFY(zoomButtonPanel.m_zoomInButton->mode() == QIcon::Normal);
-    QVERIFY(zoomButtonPanel.m_zoomOutButton->mode() == QIcon::Normal);
-}
-
-QTEST_MAIN(TestZoomButtonPanel)
-#include "testzoombuttonpanel.moc"
diff --git a/tests/ui/zoombuttonpanel/zoombuttonpanel.pro b/tests/ui/zoombuttonpanel/zoombuttonpanel.pro
deleted file mode 100644 (file)
index 9b46a68..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-# #####################################################################
-# Automatically generated by qmake (2.01a) Mon May 18 15:38:16 2010
-# #####################################################################
-CONFIG += qtestlib
-TEMPLATE = app
-TARGET =
-DEPENDPATH += .
-INCLUDEPATH += . \
-    ../../../src/
-
-# Input
-SOURCES += testzoombuttonpanel.cpp \
-    ../../../src/ui/zoombuttonpanel.cpp \
-    ../../../src/ui/imagebutton.cpp
-HEADERS += ../../../src/ui/zoombuttonpanel.h \
-    ../../../src/ui/imagebutton.h
-
-DEFINES += QT_NO_DEBUG_OUTPUT
-RESOURCES += ../../../images.qrc