#include "baselocationitem.h"
/**
-* @brief Class that shows friends location icons on the map
-*
-* @class FriendLocationItem friendlocationitem.h "map/friendlocationitem.h"
-* @author Ville Tiensuu.
-* @author Sami Rämö - sami.ramo@ixonos.com
-*/
+ * @brief Class that shows friends location icons on the map
+ *
+ * @class FriendLocationItem friendlocationitem.h "map/friendlocationitem.h"
+ * @author Ville Tiensuu.
+ * @author Sami Rämö - sami.ramo@ixonos.com
+ */
class FriendLocationItem : public BaseLocationItem
{
Q_OBJECT
public:
/**
- * @brief Constructor of FriendLocationItem
- *
- * Sets user ID
- * Sets position to UNDEFINED.
- * Sets default Z-value.
- * Sets item to ignore transformations. this feature is needed to make icon on the map
- * immune to scaling
- *
- * @param userId Used ID of the friend
- * @param parent Parent
- */
+ * @brief Constructor of FriendLocationItem
+ *
+ * Sets user ID
+ * Sets position to UNDEFINED.
+ * Sets default Z-value.
+ * Sets item to ignore transformations. this feature is needed to make icon on the map
+ * immune to scaling
+ *
+ * @param userId Used ID of the friend
+ * @param parent Parent
+ */
FriendLocationItem(const QString &userId, QObject *parent = 0);
/*******************************************************************************
******************************************************************************/
public:
/**
- * @brief Paints item pixmap.
- *
- * Paints normal or highlighted pixmap image.
- *
- * @param painter QPainter
- * @param option QStyleOptionGraphicsItem
- * @param widget QWidget
- */
+ * @brief Paints item pixmap.
+ *
+ * Paints normal or highlighted pixmap image.
+ *
+ * @param painter QPainter
+ * @param option QStyleOptionGraphicsItem
+ * @param widget QWidget
+ */
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
/*******************************************************************************
******************************************************************************/
public:
/**
- * @brief Is item part of any group
- *
- * @return True if item is part of group, otherwise false.
- */
+ * @brief Is item part of any group
+ *
+ * @return True if item is part of group, otherwise false.
+ */
bool isPartOfGroup() const;
/**
- * @brief getter for friends profile image URL
- *
- * @return QUrl friends profile images URL
- */
+ * @brief getter for friends profile image URL
+ *
+ * @return QUrl friends profile images URL
+ */
QUrl profileImageUrl() const;
/**
- * @brief Set profile image and it's URL for friend
- *
- * Also offset is set matching new image dimensions.
- *
- * @param image New profile image
- * @param url URL of the new profile image
- */
+ * @brief Set profile image and it's URL for friend
+ *
+ * Also offset is set matching new image dimensions.
+ *
+ * @param image New profile image
+ * @param url URL of the new profile image
+ */
void setProfileImage(const QPixmap image, const QUrl &url);
/**
- * @brief Set value for m_partOfGroup flag
- *
- * @param value New value
- */
+ * @brief Set value for m_partOfGroup flag
+ *
+ * @param value New value
+ */
void setPartOfGroup(bool value);
/**
- * @brief getter for m_userId
- *
- * @return QString friends user identity
- */
+ * @brief getter for m_userId
+ *
+ * @return QString friends user identity
+ */
QString userId() const;
protected:
/**
- * @brief method that detects when friend icon is moved
- *
- * Disables m_clickEvent flag if press and release where not
- * in same area.
- *
- * @param event detects the mouse move (or touch in Maemo)
- */
+ * @brief method that detects when friend icon is moved
+ *
+ * Disables m_clickEvent flag if press and release where not
+ * in same area.
+ *
+ * @param event detects the mouse move (or touch in Maemo)
+ */
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
/**
- * @brief method that detects when friend icon is clicked
- *
- * @param event detects the mouse click (or touch in Maemo)
- */
+ * @brief method that detects when friend icon is clicked
+ *
+ * @param event detects the mouse click (or touch in Maemo)
+ */
void mousePressEvent(QGraphicsSceneMouseEvent *event);
/**
- * @brief method that detects when friend icon press is released
- *
- * @param event detects the mouse release event (or touch in Maemo)
- */
+ * @brief method that detects when friend icon press is released
+ *
+ * @param event detects the mouse release event (or touch in Maemo)
+ */
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- /*******************************************************************************
- * SIGNALS
- ******************************************************************************/
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
signals:
/**
- * @brief Signal is emitted when l item is clicked.
- *
- * @param userIDs list of friends user IDs in the group
- */
+ * @brief Signal is emitted when l item is clicked.
+ *
+ * @param userIDs list of friends user IDs in the group
+ */
void locationItemClicked(const QList<QString> &userIDs);
/*******************************************************************************
-* DATA MEMBERS
-******************************************************************************/
+ * DATA MEMBERS
+ ******************************************************************************/
private:
bool m_partOfGroup; ///< Flag to mark if item is part of any group
const QString m_userId; ///< Friends user ID. Can't be changed afterwards
class User;
/**
-* @brief Map engine
-*
-* Logic for controlling map functionality. Does also include static methods for
-* converting coordinates.
-*
-* @author Sami Rämö - sami.ramo (at) ixonos.com
-* @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
-* @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
-* @author Ville Tiensuu - ville.tiensuu (at) ixonos.com
-*/
+ * @brief Map engine
+ *
+ * Logic for controlling map functionality. Does also include static methods for
+ * converting coordinates.
+ *
+ * @author Sami Rämö - sami.ramo (at) ixonos.com
+ * @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
+ * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
+ * @author Ville Tiensuu - ville.tiensuu (at) ixonos.com
+ */
class MapEngine : public QObject
{
Q_OBJECT
public:
/**
- * @brief Constructor
- *
- * @param parent Parent
- */
+ * @brief Constructor
+ *
+ * @param parent Parent
+ */
MapEngine(QObject *parent = 0);
/**
- * @brief Destructor
- * Saves view of the map to settings file
- */
+ * @brief Destructor
+ * Saves view of the map to settings file
+ */
~MapEngine();
/*******************************************************************************
******************************************************************************/
public:
/**
- * @brief Coordinates of the current center point
- *
- * @return Current coordinates (latitude & longitude)
- */
+ * @brief Coordinates of the current center point
+ *
+ * @return Current coordinates (latitude & longitude)
+ */
QPointF centerGeoCoordinate();
/**
- * @brief Convert latitude and longitude to scene coordinates.
- *
- * @param latLonCoordinate latitude and longitude values
- * @return scene coordinate
- */
+ * @brief Convert latitude and longitude to scene coordinates.
+ *
+ * @param latLonCoordinate latitude and longitude values
+ * @return scene coordinate
+ */
static QPoint convertLatLonToSceneCoordinate(QPointF latLonCoordinate);
/**
- * @brief converts scene coordinates to latitude and longitude
- *
- * @param zoomLevel current zoom level
- * @param sceneCoordinate that will be converted
- */
+ * @brief converts scene coordinates to latitude and longitude
+ *
+ * @param zoomLevel current zoom level
+ * @param sceneCoordinate that will be converted
+ */
QPointF convertSceneCoordinateToLatLon(int zoomLevel, QPoint sceneCoordinate);
/**
- * @brief Convert MapScene coordinate to tile x & y numbers.
- *
- * @param zoomLevel ZoomLevel
- * @param sceneCoordinate MapScene coordinate
- * @return QPoint tile x & y numbers
- */
+ * @brief Convert MapScene coordinate to tile x & y numbers.
+ *
+ * @param zoomLevel ZoomLevel
+ * @param sceneCoordinate MapScene coordinate
+ * @return QPoint tile x & y numbers
+ */
static QPoint convertSceneCoordinateToTileNumber(int zoomLevel, QPoint sceneCoordinate);
/**
- * @brief Convert tile x & y numbers to MapScene coordinates
- *
- * @param zoomLevel Zoom level
- * @param tileNumber x & y numbers of the tile
- * @return QPoint MapScene coordinate
- */
+ * @brief Convert tile x & y numbers to MapScene coordinates
+ *
+ * @param zoomLevel Zoom level
+ * @param tileNumber x & y numbers of the tile
+ * @return QPoint MapScene coordinate
+ */
static QPoint convertTileNumberToSceneCoordinate(int zoomLevel, QPoint tileNumber);
/**
qreal greatCircleDistance(QPointF firstLocation, QPointF secondLocation);
/**
- * @brief MapEngine initializer
- *
- * Set initial location and zoom level for the engine. locationChanged and
- * zoomLevelChanged signals are emitted, so init should be called after
- * those signals are connected to MapView.
- */
+ * @brief MapEngine initializer
+ *
+ * Set initial location and zoom level for the engine. locationChanged and
+ * zoomLevelChanged signals are emitted, so init should be called after
+ * those signals are connected to MapView.
+ */
void init();
/**
- * @brief Getter for scene
- *
- * @return QGraphicsScene
- */
+ * @brief Getter for scene
+ *
+ * @return QGraphicsScene
+ */
QGraphicsScene* scene();
/**
- * @brief Sets new zoom level
- *
- * @return newZoomLevel value that is set to new zoom level
- */
+ * @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 x tile's x value
- * @param y tile's y value
- * @return QString tile path
- */
+ * @brief Return tile path created from tile values.
+ *
+ * @param zoomLevel tile's zoom level
+ * @param x tile's x value
+ * @param y tile's y value
+ * @return QString tile path
+ */
static QString tilePath(int zoomLevel, int x, int y);
public slots:
-
/**
- * @brief Slot to catch user own location data
- *
- * @param user User info
- */
+ * @brief Slot to catch user own location data
+ *
+ * @param user User info
+ */
void receiveOwnLocation(User *user);
/**
- * @brief Set auto centering.
- *
- * @param enabled true if enabled, false otherwise
- */
+ * @brief Set auto centering.
+ *
+ * @param enabled true if enabled, false otherwise
+ */
void setAutoCentering(bool enabled);
/**
- * @brief Slot for enabling / disabling GPS
- *
- * GPS location item is disabled or enabled based on GPS state
- *
- * @param enabled True is GPS is enabled, otherwise false
- */
+ * @brief Slot for enabling / disabling GPS
+ *
+ * GPS location item is disabled or enabled based on GPS state
+ *
+ * @param enabled True is GPS is enabled, otherwise false
+ */
void setGPSEnabled(bool enabled);
/**
- * @brief Slot for setting current view location
- *
- * Emits locationChanged signal.
- * @param sceneCoordinate Scene coordinates for new position
- */
+ * @brief Slot for setting current view location
+ *
+ * Emits locationChanged signal.
+ * @param sceneCoordinate Scene coordinates for new position
+ */
void setLocation(QPoint sceneCoordinate);
/**
- * @brief Helper for setting view location based on latitude and longitude
- * coordinates
- *
- * @param latLonCoordinate Latitude & longitude coordinates for location
- */
+ * @brief Helper for setting view location based on latitude and longitude
+ * coordinates
+ *
+ * @param latLonCoordinate Latitude & longitude coordinates for location
+ */
void setViewLocation(QPointF latLonCoordinate);
/**
- * @brief Slot for view resizing.
- *
- * @param size view size
- */
+ * @brief Slot for view resizing.
+ *
+ * @param size view size
+ */
void viewResized(const QSize &size);
private:
/**
- * @brief Calculate grid of tile coordinates from current scene coordinate.
- *
- * Grid size is calculated from view size and scene's current center coordinate.
- *
- * @param sceneCoordinate scene's current center coordinate
- * @return QRect grid of tile coordinates
- */
+ * @brief Calculate grid of tile coordinates from current scene coordinate.
+ *
+ * Grid size is calculated from view size and scene's current center coordinate.
+ *
+ * @param sceneCoordinate scene's current center coordinate
+ * @return QRect grid of tile coordinates
+ */
QRect calculateTileGrid(QPoint sceneCoordinate);
/**
- * @brief Check if auto centering should be disabled.
- *
- * @param sceneCoordinate scene's center coordinate
- * @return bool true if auto centering should be disabled
- */
+ * @brief Check if auto centering should be disabled.
+ *
+ * @param sceneCoordinate scene's center coordinate
+ * @return bool true if auto centering should be disabled
+ */
bool disableAutoCentering(QPoint sceneCoordinate);
/**
- * @brief Get new tiles.
- *
- * Calculates which tiles has to be fetched. Does emit fetchImage for tiles which
- * aren't already in the scene.
- * @param sceneCoordinate scene's center coordinate
- */
+ * @brief Get new tiles.
+ *
+ * Calculates which tiles has to be fetched. Does emit fetchImage for tiles which
+ * aren't already in the scene.
+ * @param sceneCoordinate scene's center coordinate
+ */
void getTiles(QPoint sceneCoordinate);
/**
- * @brief Check if auto centering is enabled
- *
- * @return true if enabled, false otherwise
- */
+ * @brief Check if auto centering is enabled
+ *
+ * @return true if enabled, false otherwise
+ */
bool isAutoCenteringEnabled();
/**
- * @brief Check if center tile has changed.
- *
- * @param sceneCoordinate scene's center coordinate
- * @return bool true if center tile changed, false otherwise
- */
+ * @brief Check if center tile has changed.
+ *
+ * @param sceneCoordinate scene's center coordinate
+ * @return bool true if center tile changed, false otherwise
+ */
bool isCenterTileChanged(QPoint sceneCoordinate);
/**
qreal sceneResolution();
/**
- * @brief Calculate maximum value for tile in this zoom level.
- *
- * @param zoomLevel zoom level
- * @return int tile's maximum value
- */
+ * @brief Calculate maximum value for tile in this zoom level.
+ *
+ * @param zoomLevel zoom level
+ * @return int tile's maximum value
+ */
int tileMaxValue(int zoomLevel);
/**
- * @brief Updates the current view rect including margins
- *
- * Calculates tiles rect in scene based on m_viewTilesGrid and
- * calls MapScene::viewRectUpdated()
- */
+ * @brief Updates the current view rect including margins
+ *
+ * Calculates tiles rect in scene based on m_viewTilesGrid and
+ * calls MapScene::viewRectUpdated()
+ */
void updateViewTilesSceneRect();
private slots:
/**
- * @brief Slot for GPS position updates
- *
- * GPS location item is updated and map centered to new location (if automatic
- * centering is enabled).
- *
- * @param position New coordinates from GPS
- * @param accuracy Accuracy of the GPS fix
- */
+ * @brief Slot for GPS position updates
+ *
+ * GPS location item is updated and map centered to new location (if automatic
+ * centering is enabled).
+ *
+ * @param position New coordinates from GPS
+ * @param accuracy Accuracy of the GPS fix
+ */
void gpsPositionUpdate(QPointF position, qreal accuracy);
/**
- * @brief Slot for received map tile images
- *
- * Does add MapTile objects to MapScene.
- * @param zoomLevel Zoom level
- * @param x Tile x index
- * @param y Tile y index
- * @param image Received pixmap
- */
+ * @brief Slot for received map tile images
+ *
+ * Does add MapTile objects to MapScene.
+ * @param zoomLevel Zoom level
+ * @param x Tile x index
+ * @param y Tile y index
+ * @param image Received pixmap
+ */
void mapImageReceived(int zoomLevel, int x, int y, const QPixmap &image);
/**
- * @brief Slot for actions after view zoom is finished
- *
- * Does run removeOutOfViewTiles
- */
+ * @brief Slot for actions after view zoom is finished
+ *
+ * Does run removeOutOfViewTiles
+ */
void viewZoomFinished();
/**
- * @brief Slot for zooming in
- */
+ * @brief Slot for zooming in
+ */
void zoomIn();
/**
- * @brief Slot for zooming out
- */
+ * @brief Slot for zooming out
+ */
void zoomOut();
/*******************************************************************************
******************************************************************************/
signals:
/**
- * @brief Signals error
- *
- * @param error error code
- */
+ * @brief Signals error
+ *
+ * @param error error code
+ */
void error(const int error);
/**
- * @brief Signal for image fetching.
- *
- * @param zoomLevel Zoom level
- * @param x Tile x index
- * @param y Tile y index
- */
+ * @brief Signal for image fetching.
+ *
+ * @param zoomLevel Zoom level
+ * @param x Tile x index
+ * @param y Tile y index
+ */
void fetchImage(int zoomLevel, int x, int y);
/**
- * @brief Signal when friend list locations are fetched
- *
- * @param friendsList Friends list data
- */
+ * @brief Signal when friend list locations are fetched
+ *
+ * @param friendsList Friends list data
+ */
void friendsLocationsReady(QList<User *> &friendsList);
/**
- * @brief Request view centering to new locaiton
- *
- * @param sceneCoordinate New scene coordinates
- */
+ * @brief Request view centering to new locaiton
+ *
+ * @param sceneCoordinate New scene coordinates
+ */
void locationChanged(QPoint sceneCoordinate);
/**
- * @brief Signal is emitted when location item is clicked.
- *
- * @param userIDs list of friends user IDs in the group
- */
+ * @brief Signal is emitted when location item is clicked.
+ *
+ * @param userIDs list of friends user IDs in the group
+ */
void locationItemClicked(const QList<QString> &userIDs);
/**
- * @brief Signal to notify map scrolling.
- */
+ * @brief Signal to notify map scrolling.
+ */
void mapScrolledManually();
/**
- * @brief Signal to notify when map is zoomed in to the maxmimum.
- */
+ * @brief Signal to notify when map is zoomed in to the maxmimum.
+ */
void maxZoomLevelReached();
/**
- * @brief Signal to notify when map is zoomed out to the minimum.
- */
+ * @brief Signal to notify when map is zoomed out to the minimum.
+ */
void minZoomLevelReached();
/**
void newMapResolution(qreal scale);
/**
- * @brief Request view changing zoom level
- *
- * @param newZoomLevel New zoom level
- */
+ * @brief Request view changing zoom level
+ *
+ * @param newZoomLevel New zoom level
+ */
void zoomLevelChanged(int newZoomLevel);
/*******************************************************************************