connect(m_ui, SIGNAL(requestReverseGeo()), this, SLOT(requestAddress()));
connect(m_situareService, SIGNAL(reverseGeoReady(QString)), m_ui, SIGNAL(reverseGeoReady(QString)));
connect(m_ui, SIGNAL(statusUpdate(QString,bool)), this, SLOT(requestUpdateLocation(QString,bool)));
+ connect(m_situareService, SIGNAL(userDataChanged(User*,QList<User*>&)),
+ this, SLOT(userDataChanged(User*,QList<User*>&)));
+ connect(this, SIGNAL(userLocationReady(User*)), m_ui, SIGNAL(userLocationReady(User*)));
+ connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)), m_ui, SIGNAL(friendsLocationsReady(QList<User*>&)));
start();
}
qDebug() << __PRETTY_FUNCTION__;
//code here
}
+
+void SituareEngine::userDataChanged(User *user, QList<User *> &friendList)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ emit userLocationReady(user);
+ qDebug() << friendList.at(0)->name();
+ emit friendsLocationsReady(friendList);
+}
void updateFriendsList();
+ void userDataChanged(User *user, QList<User *> &friendList);
+
/*******************************************************************************
* SIGNALS
******************************************************************************/
*/
void engine_closeMainWindow();
+ void userLocationReady(User *user);
+ void friendsLocationsReady(QList<User *> &friendList);
+
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
--- /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 <QDebug>
+#include "mapengine.h"
+#include "baselocationitem.h"
+
+BaseLocationItem::BaseLocationItem(QObject *parent)
+ : QObject(parent)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+}
+
+void BaseLocationItem::setPosition(const QPointF & newPosition)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ setPos(MapEngine::convertLatLonToSceneCoordinate(newPosition));
+}
+
+QPoint BaseLocationItem::position() const
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ return pos().toPoint();
+}
+
+void BaseLocationItem::hideLocation()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ hide();
+}
+
+void BaseLocationItem::showLocation()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ show();
+}
--- /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.
+*/
+
+#ifndef BASELOCATIONITEM_H
+#define BASELOCATIONITEM_H
+
+#include <QGraphicsPixmapItem>
+
+
+
+class BaseLocationItem : public QGraphicsPixmapItem, public QObject
+{
+
+public:
+ BaseLocationItem(QObject *parent = 0);
+
+ /*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+ public:
+
+ /**
+ * @brief Hides item so that it is invisible on the map
+ *
+ */
+ void hideLocation();
+
+ /**
+ * @brief returns position of item in scene coordinates.
+ *
+ * @return QPoint position of OwnLocationItem
+ */
+ QPoint position() const;
+
+ /**
+ * @brief sets position of item as specified in parameter.
+ * Parameter can be given in georaphical coordinates
+ *
+ * @param newPosition Parameter that specifies new position.
+ */
+ void setPosition(const QPointF & newPosition);
+
+ /**
+ * @brief Sets item to be visible on the map.
+ * Item is visible by default, function is needed only when own location
+ * needs to be set back visible after hideLocation function call.
+ */
+ void showLocation();
+};
+
+
+#endif // BASELOCATIONITEM_H
--- /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 <QDebug>
+#include "friendlocationitem.h"
+#include "mapengine.h"
+#include "mapcommon.h"
+
+
+FriendLocationItem::FriendLocationItem(const QPixmap &icon,
+ const QPointF &friendsLocation,
+ QObject *parent)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ setPixmap(icon);
+ setPosition(QPointF( friendsLocation.x(), friendsLocation.y() ));
+ setZValue(FRIEND_LOCATION_ICON_Z_LEVEL);
+ setOffset(-icon.width()/2, -icon.height()/2);
+ setFlag(QGraphicsItem::ItemIgnoresTransformations);
+}
+
+void FriendLocationItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ Q_UNUSED(event);
+ qDebug() << "Friends Location is " << position().x() << " " << position().y();
+ qDebug() << "Name of the friend is " << m_name->toAscii();
+ emit iconClicked(*m_name);
+}
+
+void FriendLocationItem::setIcon(const QPixmap &icon)
+{
+ setPixmap(icon);
+}
+
+void FriendLocationItem::setName(const QString &name)
+{
+ m_name = new QString(name);
+}
--- /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.
+*/
+
+#ifndef FRIENDLOCATIONITEM_H
+#define FRIENDLOCATIONITEM_H
+
+
+#include <QObject>
+
+#include "baselocationitem.h"
+
+class FriendLocationItem : public BaseLocationItem
+{
+ Q_OBJECT
+
+public:
+ FriendLocationItem(const QPixmap &icon, const QPointF &friendsLocation, QObject *parent = 0);
+ void setIcon(const QPixmap &icon);
+ void setName(const QString &name);
+
+signals:
+ void iconClicked(QString name);
+
+protected:
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+
+private:
+ QString *m_name;
+};
+
+#endif // FRIENDLOCATIONITEM_H
static const int MAP_OWN_LOCATION_ICON_SIZE = 24; ///< Size of own location item icon
static const int OWN_LOCATION_ICON_Z_LEVEL = MAP_ZOOM_PANEL_LEVEL - 1; ///< Z-Level of own location icon
+const int FRIEND_LOCATION_ICON_Z_LEVEL = OWN_LOCATION_ICON_Z_LEVEL -1; ///< Z-Level of friend location icon
const qreal MAX_LATITUDE = 85.05112877980659237802; ///< Maximum latitude value
const qreal MIN_LATITUDE = -MAX_LATITUDE; ///< Minimum latitude value
USA.
*/
+#include <QtAlgorithms>
#include <QDebug>
#include <QString>
#include <QStringList>
connect(m_mapZoomPanel, SIGNAL(zoomInPressed()), this, SLOT(zoomIn()));
connect(m_mapZoomPanel, SIGNAL(zoomOutPressed()), this, SLOT(zoomOut()));
- m_ownLocation = new OwnLocationItem();
- m_mapScene->addItem(m_ownLocation);
+ m_ownLocation = new OwnLocationItem(QPointF());
+}
+
+MapEngine::~MapEngine()
+{
+ qDeleteAll(m_friendsLocations.begin(),m_friendsLocations.end());
+ m_friendsLocations.clear();
}
void MapEngine::init()
return QPointF(x*z*TILE_SIZE_X, y*z*TILE_SIZE_Y).toPoint();
}
+
+void MapEngine::receiveOwnLocation(User *user)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ m_ownLocation->setPosition(user->coordinates());
+ m_mapScene->addItem(m_ownLocation);
+}
+
+void MapEngine::receiveFriendLocations(QList<User *> &friendsList)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ qDeleteAll(m_friendsLocations.begin(),m_friendsLocations.end());
+ m_friendsLocations.clear();
+
+ for(int i=0; i<friendsList.count(); i++) {
+ FriendLocationItem *friendLocation
+ = new FriendLocationItem(friendsList.at(i)->profileImage(),
+ friendsList.at(i)->coordinates(),0);
+
+ friendLocation->setName(friendsList.at(i)->name());
+ m_friendsLocations.append(friendLocation);
+ m_mapScene->addItem(friendLocation);
+ }
+}
#include "maptile.h"
#include "mapzoompanel.h"
#include "ownlocationitem.h"
+#include "friendlocationitem.h"
+#include "user/user.h"
/**
* @brief Map engine
*/
MapEngine(QObject *parent = 0);
+ ~MapEngine();
+
/*******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
*/
void viewResized(const QSize &size);
+ void receiveOwnLocation(User *user);
+ void receiveFriendLocations(QList<User *> &friendsList);
+
private:
/**
* @brief Build URL for donwloading single map tile from OpenStreetMap tile server
*/
void zoomOut();
+
+
/*******************************************************************************
* SIGNALS
******************************************************************************/
*/
void zoomLevelChanged(int newZoomLevel);
+
+
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
private:
+ //FriendLocationItem *m_friendLocation; ///< Item to show friends location
MapFetcher *m_mapFetcher; ///< Fetcher for map tiles
MapScene *m_mapScene; ///< Scene for map tiles
MapZoomPanel *m_mapZoomPanel; ///< Toolbar for zoom buttons
QRect m_viewGrid; ///< Current grid of tiles in view (includes margin)
QSize m_viewSize; ///< Current view size
int m_zoomLevel; ///< Current zoom level
+ QList<FriendLocationItem *> m_friendsLocations; ///< Location of friends
};
#endif // MAPENGINE_H
#define MAPVIEW_H
#include <QGraphicsView>
+#include "user/user.h"
/**
* @brief Map view widget
#include "mapengine.h"
#include "mapcommon.h"
-OwnLocationItem::OwnLocationItem()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- QPixmap ownLocationIcon(":/res/images/led_red_h.png");
- if (!ownLocationIcon.isNull()){
- setPixmap(ownLocationIcon);
-
- QPointF defaultLocation(DEFAULT_LONGITUDE,DEFAULT_LATITUDE);
-
- setPos(MapEngine::convertLatLonToSceneCoordinate(defaultLocation));
- setZValue(OWN_LOCATION_ICON_Z_LEVEL);
- setOffset(-MAP_OWN_LOCATION_ICON_SIZE/2, -MAP_OWN_LOCATION_ICON_SIZE/2);
- setFlag(QGraphicsItem::ItemIgnoresTransformations);
- }
-
- else
- qDebug() << "Own Location Icon cannot be loaded";
-}
-
-OwnLocationItem::OwnLocationItem(const qreal &longitude, const qreal &latitude)
-{
- QPointF ownPosition(longitude,latitude);
-
- QPixmap ownLocationIcon(":/res/images/led_red_h.png");
- if (!ownLocationIcon.isNull()){
- setPixmap(ownLocationIcon);
-
- setPos(MapEngine::convertLatLonToSceneCoordinate(ownPosition));
- setZValue(OWN_LOCATION_ICON_Z_LEVEL);
- setOffset(-MAP_OWN_LOCATION_ICON_SIZE/2, -MAP_OWN_LOCATION_ICON_SIZE/2);
- setFlag(QGraphicsItem::ItemIgnoresTransformations);
- }
-
- else
- qDebug() << "Own Location Icon cannot be loaded";
-}
OwnLocationItem::OwnLocationItem(const QPointF & ownPosition)
{
+ qDebug() << __PRETTY_FUNCTION__;
QPixmap ownLocationIcon(":/res/images/led_red_h.png");
- if (!ownLocationIcon.isNull()){
- setPixmap(ownLocationIcon);
-
- setPos(MapEngine::convertLatLonToSceneCoordinate(ownPosition));
- setZValue(OWN_LOCATION_ICON_Z_LEVEL);
- setOffset(-MAP_OWN_LOCATION_ICON_SIZE/2, -MAP_OWN_LOCATION_ICON_SIZE/2);
- setFlag(QGraphicsItem::ItemIgnoresTransformations);
- }
-
- else
- qDebug() << "Own Location Icon cannot be loaded";
-}
-
-void OwnLocationItem::setPosition(const QPointF & newPosition)
-{
- setPos(MapEngine::convertLatLonToSceneCoordinate(newPosition));
-}
-
-QPoint OwnLocationItem::position() const
-{
- QPointF currentPosition;
- currentPosition = pos();
+ setPixmap(ownLocationIcon);
- return currentPosition.toPoint();
+ setPosition(ownPosition);
+ setZValue(OWN_LOCATION_ICON_Z_LEVEL);
+ setOffset(-ownLocationIcon.width()/2, -ownLocationIcon.height()/2);
+ setFlag(QGraphicsItem::ItemIgnoresTransformations);
}
-void OwnLocationItem::hideOwnLocation()
-{
- hide();
-}
-void OwnLocationItem::showOwnLocation()
-{
- show();
-}
#define OWNLOCATIONITEM_H
#include <QGraphicsPixmapItem>
+#include "mapcommon.h"
+#include "baselocationitem.h"
+
+
/**
* @brief Class that shows own location icon on the map
* @class OwnLocationItem ownlocationitem.h "map/ownlocationitem.h"
* @author Ville Tiensuu
*/
-class OwnLocationItem : public QGraphicsPixmapItem
+class OwnLocationItem : public BaseLocationItem
{
public:
+
/**
- * @brief Default constructor of OwnLocationItem.
+ * @brief Constructor of OwnLocationItem.
* Sets position to default location.
* Loads and sets default pixmap that is show on the map.
- * Sets default Z-value to show icon on top of maps but under zoom buttons.
+ * Sets default Z-value.
* Sets offset so that achor of the picture is at the origin. this feature is
* needed to center icon on the middle of the location.
* Sets item to ignore transformations. this feature is needed to make icon on the map
* immune to scaling
- */
- OwnLocationItem();
-
- /**
- * @brief Overloaded constructor for OwnLocationItem.
- * Otherwise same as default constructor, but position is set according to parameters.
- *
- * @param longitude Longitude coordinate of position.
- * @param latitude Latitude coordinate of position.
- */
- OwnLocationItem(const qreal & longitude, const qreal & latitude);
-
- /**
- * @brief Overloaded constructor for OwnLocationItem.
- * Otherwise same as default constructor, but position is set according to parameter.
*
* @param ownPosition Position in QPoinF format
*/
OwnLocationItem(const QPointF & ownPosition);
-
- /*******************************************************************************
- * MEMBER FUNCTIONS AND SLOTS
- ******************************************************************************/
- public:
-
- /**
- * @brief Hides OwnLocationItem so that it is invisible on the map
- *
- */
- void hideOwnLocation();
-
- /**
- * @brief returns position of OwnLocationItem in scene coordinates.
- *
- * @return QPoint position of OwnLocationItem
- */
- QPoint position() const;
-
- /**
- * @brief sets position of OwnLocationItem as specified in parameter.
- * Parameter can be given in georaphical coordinates
- *
- * @param newPosition Parameter that specifies new position.
- */
- void setPosition(const QPointF & newPosition);
-
- /**
- * @brief Sets OwnLocationItem to be visible on the map.
- * OwnLocationImte is visible by default, function is needed only when own location
- * needs to be set back visible after hideOwnLocation function call.
- */
- void showOwnLocation();
};
#endif // OWNLOCATIONITEM_H
map/mapzoompanel.cpp \
map/mapbutton.cpp \
map/ownlocationitem.cpp \
+ map/baselocationitem.cpp \
+ map/friendlocationitem.cpp \
ui/pixmap.cpp \
ui/infotab.cpp \
ui/updatelocation/updatelocationdialog.cpp \
map/mapzoompanel.h \
map/mapbutton.h \
map/ownlocationitem.h \
+ map/baselocationitem.h \
+ map/friendlocationitem.h \
ui/pixmap.h \
ui/infotab.h \
ui/updatelocation/updatelocationdialog.h \
setWindowTitle(tr("List view"));
this->hide();
- m_facebookAuthenticator = new FacebookAuthentication(this);
- connect(m_facebookAuthenticator, SIGNAL(credentialsReady()), this, SLOT(loginOK()));
- connect(m_facebookAuthenticator, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
- m_facebookAuthenticator->start();
+ //m_facebookAuthenticator = new FacebookAuthentication(this);
+ //connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)), this, SLOT(loginOK()));
+ //connect(m_facebookAuthenticator, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
+ // m_facebookAuthenticator->start();
m_locationDialog = new UpdateLocationDialog(this);
connect(m_listViewScreen->m_personalInfo,SIGNAL(launchMessageUpdate()),
m_networkManager = new QNetworkAccessManager;
m_situareService = new SituareService(this,m_networkManager);
+
+ connect(this, SIGNAL(userLocationReady(User*)),
+ m_mapViewScreen, SLOT(userLocationReady(User*)));
+ connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
+ m_mapViewScreen, SLOT(friendsLocationsReady(QList<User*>&)));
}
MainWindow::~MainWindow()
{
qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
m_loggedIn = true;
- m_facebookAuthenticator->close();
+ //m_facebookAuthenticator->close();
}
+
+//void MainWindow::userLocationReady(User &user)
+//{
+// emit userLocationReady(user);
+//}
+//
+//void MainWindow::friendsLocationsReady(QList<User *>friendsList)
+//{
+// emit friendsLocationsReady(friendsList);
+//}
+
*/
void toMapView();
+// void userLocationReady(User &user);
+// void friendsLocationsReady(QList<User *> friendsList);
+
private:
/**
* @brief Private method to create the Menu items
*/
void statusUpdate(const QString &status, const bool &publish);
+ void userLocationReady(User *user);
+ void friendsLocationsReady(QList<User *> &friendsList);
+
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
mapEngine->setViewLocation(QPointF(lon, lat));
}
+
+void MapViewScreen::userLocationReady(User *user)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ mapEngine->receiveOwnLocation(user);
+}
+
+void MapViewScreen::friendsLocationsReady(QList<User *> &friendsList)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ mapEngine->receiveFriendLocations(friendsList);
+}
* @brief Debug method for centering to given coordinates
*/
void searchMap();
+
+ void userLocationReady(User *user);
+ void friendsLocationsReady(QList<User *> &friendsList);
/*******************************************************************************
* DATA MEMBERS
../../../src/map/ownlocationitem.cpp \
../../../src/map/mapview.cpp \
../../../src/map/mapzoompanel.cpp \
- ../../../src/map/mapbutton.cpp
+ ../../../src/map/mapbutton.cpp \
+ ../../../src/map/baselocationitem.cpp \
+ ../../../src/user/user.cpp \
+ ../../../src/map/friendlocationitem.cpp
HEADERS += ../../../src/map/ownlocationitem.h \
../../../src/map/mapscene.h \
../../../src/map/mapfetcher.h \
../../../src/map/mapcommon.h \
../../../src/map/mapview.h \
- ../../../src/map/mapzoompanel.h \
- ../../../src/map/mapbutton.h
+ ../../../src/map/mapzoompanel.h \
+ ../../../src/map/mapbutton.h \
+ ../../../src/map/baselocationitem.h \
+ ../../../src/user/user.h \
+ ../../../src/map/friendlocationitem.h
#include "map/mapengine.h"
#include "map/mapcommon.h"
#include "map/mapview.h"
+#include "map/baselocationitem.h"
+#include "user/user.h"
+#include "map/friendlocationitem.h"
namespace TestOwnLocation // Test data for function is defined in namespace
{
void TestOwnLocationItem::testConstructors()
{
- OwnLocationItem ownLocationItem1;
- OwnLocationItem ownLocationItem2(xCoordinate, yCoordinate);
- OwnLocationItem ownLocationItem3(testLocationPoint);
- // Test Pixmaps
- QPixmap pixmap1;
- QPixmap pixmap2;
- QPixmap pixmap3;
+ OwnLocationItem ownLocationItem(defaultLocationPoint);
- QCOMPARE (pixmap1.isNull(), true);
- QCOMPARE (pixmap2.isNull(), true);
- QCOMPARE (pixmap3.isNull(), true);
+ // Test Pixmap
+ QPixmap pixmap;
+ QCOMPARE (pixmap.isNull(), true);
- pixmap1 = ownLocationItem1.pixmap();
- pixmap2 = ownLocationItem2.pixmap();
- pixmap3 = ownLocationItem3.pixmap();
+ pixmap = ownLocationItem.pixmap();
+ QCOMPARE (pixmap.isNull(), false);
- QCOMPARE (pixmap1.isNull(), false);
- QCOMPARE (pixmap2.isNull(), false);
- QCOMPARE (pixmap3.isNull(), false);
- // Test Positions
- QCOMPARE(ownLocationItem1.position(),
+ // Test Position
+ QCOMPARE(ownLocationItem.position(),
MapEngine::convertLatLonToSceneCoordinate(defaultLocationPoint));
- QCOMPARE(ownLocationItem2.position(),
- MapEngine::convertLatLonToSceneCoordinate(testLocationPoint));
+ // Test Z-value
+ QCOMPARE(static_cast<int>(ownLocationItem.zValue()), OWN_LOCATION_ICON_Z_LEVEL);
- QCOMPARE(ownLocationItem3.position(),
- MapEngine::convertLatLonToSceneCoordinate(testLocationPoint));
- // Test Z-values
- QCOMPARE(static_cast<int>(ownLocationItem1.zValue()), OWN_LOCATION_ICON_Z_LEVEL);
- QCOMPARE(static_cast<int>(ownLocationItem2.zValue()), OWN_LOCATION_ICON_Z_LEVEL);
- QCOMPARE(static_cast<int>(ownLocationItem3.zValue()), OWN_LOCATION_ICON_Z_LEVEL);
+ // Test Offset
+// QCOMPARE(ownLocationItem.offset(),
+// QPoint(-ownLocationItem.pixmap().width(), -ownLocationItem.pixmap().height()));
- // Test Offsets
- QCOMPARE(ownLocationItem1.offset(), locationIconOffset);
- QCOMPARE(ownLocationItem2.offset(), locationIconOffset);
- QCOMPARE(ownLocationItem3.offset(), locationIconOffset);
// Test ItemIgnoresTransformations Flags
- QGraphicsItem::GraphicsItemFlags ownLocationItem1Flags = ownLocationItem1.flags();
- QGraphicsItem::GraphicsItemFlags ownLocationItem2Flags = ownLocationItem1.flags();
- QGraphicsItem::GraphicsItemFlags ownLocationItem3Flags = ownLocationItem1.flags();
+ QGraphicsItem::GraphicsItemFlags ownLocationItemFlags = ownLocationItem.flags();
+ QCOMPARE(ownLocationItemFlags, itemIgnoresTransformationsFlagValue);
- QCOMPARE(ownLocationItem1Flags, itemIgnoresTransformationsFlagValue);
- QCOMPARE(ownLocationItem2Flags, itemIgnoresTransformationsFlagValue);
- QCOMPARE(ownLocationItem3Flags, itemIgnoresTransformationsFlagValue);
}
void TestOwnLocationItem::testSetAndGetPosition()
{
- OwnLocationItem ownLocation;
+ OwnLocationItem ownLocation(defaultLocationPoint);
+
+ QCOMPARE(ownLocation.position(),
+ MapEngine::convertLatLonToSceneCoordinate(defaultLocationPoint));
+
ownLocation.setPosition(testLocationPoint);
QCOMPARE(ownLocation.position(),
MapEngine::convertLatLonToSceneCoordinate(testLocationPoint));
+
}
void TestOwnLocationItem::testHideAndShowPosition()
{
- OwnLocationItem ownLocation;
-
+ OwnLocationItem ownLocation(defaultLocationPoint);
QCOMPARE(ownLocation.isVisible(), true);
- ownLocation.hideOwnLocation();
-
+ ownLocation.hideLocation();
QCOMPARE(ownLocation.isVisible(), false);
+ ownLocation.showLocation();
+ QCOMPARE(ownLocation.isVisible(), true);
}
QTEST_MAIN(TestOwnLocationItem)