<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>
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"
# 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
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
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),
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();
}
enableAutoCentering(enabled);
}
+
void SituareEngine::disableAutoCentering()
{
qDebug() << __PRETTY_FUNCTION__;
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__;
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__;
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)));
#define ENGINE_H
#include <QObject>
+#include <QPointF>
class QMainWindow;
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();
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
*
*/
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
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);
#include <QtAlgorithms>
#include <QDebug>
-#include <QNetworkAccessManager>
#include <QString>
#include <QStringList>
#include <QUrl>
#include "ownlocationitem.h"
#include "mapengine.h"
+#include "network/networkaccessmanager.h"
MapEngine::MapEngine(QObject *parent)
: 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)),
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();
}
}
+void MapEngine::setZoomLevel(int newZoomLevel)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_zoomLevel = newZoomLevel;
+ emit zoomLevelChanged(m_zoomLevel);
+}
+
void MapEngine::setViewLocation(QPointF latLonCoordinate)
{
qDebug() << __PRETTY_FUNCTION__;
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
*
* @param latLonCoordinate Latitude & longitude coordinates for location
*/
- void setViewLocation(QPointF latLonCoordinate);
+ void setViewLocation(QPointF latLonCoordinate);
/**
* @brief Slot for view resizing.
#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)
{
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++) {
#include <QNetworkAccessManager>
#include "maptilerequest.h"
+#include "network/networkaccessmanager.h"
class QNetworkReply;
class QUrl;
* @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
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
};
--- /dev/null
+/*
+ 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);
+}
--- /dev/null
+/*
+ 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
--- /dev/null
+/*
+ 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();
+}
--- /dev/null
+/*
+ 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
--- /dev/null
+/*
+ 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);
+}
--- /dev/null
+/*
+ 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
--- /dev/null
+/*
+ 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__;
+}
--- /dev/null
+/*
+ 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
--- /dev/null
+/*
+ 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__;
+}
--- /dev/null
+/*
+ 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
#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)
{
QUrl url = m_downloadQueue.dequeue();
QNetworkRequest request(url);
+ request.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);
request.setRawHeader("User-Agent", "Situare");
QNetworkReply *reply = m_manager->get(request);
{
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();
+ }
}
#include <QtCore>
-class QNetworkAccessManager;
+class NetworkAccessManager;
class QNetworkReply;
class QUrl;
* @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
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
#include "situarecommon.h"
#include "parser.h"
#include "ui/avatarimage.h"
+#include "network/networkaccessmanager.h"
SituareService::SituareService(QObject *parent)
: 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)));
{
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();
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);
{
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)
#include "../user/user.h"
#include "imagefetcher.h"
-class QNetworkAccessManager;
+class NetworkAccessManager;
class QNetworkReply;
class QNetworkRequest;
class QPointF;
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
# -------------------------------------------------
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 \
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 \
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)
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)
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;
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);
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);
if(m_buttonMode != QIcon::Disabled) {
QPushButton::mousePressEvent(event);
setMode(QIcon::Selected);
+ } else {
+ setDown(true);
+ emit pressed();
}
}
if(m_buttonMode != QIcon::Disabled) {
QPushButton::mouseReleaseEvent(event);
setMode(QIcon::Normal);
+ } else {
+ setDown(false);
+ emit released();
}
}
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>)),
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*)));
{
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()));
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()
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
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
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
#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
*
* @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);
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);
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");
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);
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)
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)
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));
}
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);
m_mousePosition = event->pos();
}
+void UserInfo::findButtonClicked()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ emit findUser(m_coordinates);
+}
+
void UserInfo::messageUpdate()
{
qDebug() << __PRETTY_FUNCTION__;
#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
* @param event QMouseEvent mouse press event
*/
void mousePressEvent(QMouseEvent *event);
+
/**
* @brief Call toggleHeight if mouse position is unchanged.
*
* @param event QMouseEvent mouse release event
*/
void mouseReleaseEvent(QMouseEvent *event);
+
/**
* @brief This function is called when the widget is drawn
*
/**
* @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
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);
private slots:
/**
+ * @brief Slot for find button click
+ */
+ void findButtonClicked();
+
+ /**
* @brief Slot function to forward messageUpdate launch signal
*
*/
******************************************************************************/
signals:
/**
+ * @brief Signal for finding user.
+ *
+ * @param coordinates user geo coordinates
+ */
+ void findUser(const QPointF &coordinates);
+
+ /**
* @brief Signal for refreshing user data.
*
*/
******************************************************************************/
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
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
: 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()));
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());
}
}
*/
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.
*
*/
******************************************************************************/
private:
UserInfo *m_userInfo; ///< Instance of the user info view
+
};
#endif // USERPANEL_H
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;
}
******************************************************************************/
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
#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__;
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)
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)
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__;
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);
}
#include <QGridLayout>
#include <QGraphicsItem>
-#include "imagebutton.h"
+#include "zoombutton.h"
/**
* @brief Panel for zoom buttons
* @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
*
* @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:
/**
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
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
# 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 \
../../../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 \
../../../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)
+}
# 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
../../../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 \
../../../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)
+}
+
../../../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)
+}
+
# 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 \
../../../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 \
../../../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)
+}
+
#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
void setLocationRemovedTilesCount();
void zoomOutRemovedTilesCount();
void zoomInRemovedTilesCount();
+ void usingLastLocation();
};
/**
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"
# 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 \
../../../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 \
../../../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)
+}
# 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 \
../../../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 \
../../../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)
+}
# Automatically generated by qmake (2.01a) Fri Mar 26 15:22:56 2010
# #####################################################################
CONFIG += qtestlib
-QT += opengl
TEMPLATE = app
TARGET =
DEPENDPATH += .
# 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
../../../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 \
../../../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)
+}
+++ /dev/null
-/*
- 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"
+++ /dev/null
-# #####################################################################
-# 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
map/friendlocationitem \
user \
ui/friendlist \
- ui/zoombuttonpanel
+ ui/sidepanel
../../../src/ui/avatarimage.cpp \
../../../src/ui/imagebutton.cpp \
testfriendlist.cpp
+RESOURCES += ../../../images.qrc
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);
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);
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);
--- /dev/null
+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
+++ /dev/null
-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
+++ /dev/null
-/*
- 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"
+++ /dev/null
-# #####################################################################
-# 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