Merge branch 'crosshair2'
authorVille Tiensuu <ville.tiensuu@ixonos.com>
Tue, 18 May 2010 05:06:43 +0000 (08:06 +0300)
committerVille Tiensuu <ville.tiensuu@ixonos.com>
Tue, 18 May 2010 05:06:43 +0000 (08:06 +0300)
Conflicts:
images.qrc
src/engine/engine.h
src/map/mapengine.cpp
src/map/mapview.cpp
src/map/mapview.h
src/ui/mainwindow.cpp
src/ui/mapviewscreen.cpp
src/ui/mapviewscreen.h

1  2 
images.qrc
src/engine/engine.h
src/map/mapengine.cpp
src/map/mapengine.h
src/map/mapview.cpp
src/map/mapview.h
src/ui/mainwindow.cpp
src/ui/mapviewscreen.cpp
src/ui/mapviewscreen.h

diff --combined images.qrc
          <file>res/images/sliding_bar_right.png</file>
          <file>res/images/led_red.png</file>
          <file>res/images/led_red_s.png</file>
 -        <file>res/images/friend_group.png</file>
          <file>res/images/list_item.png</file>
          <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/gps_pos_accurate.png</file>
 +        <file>res/images/gps_pos_coarse.png</file>
 +        <file>res/images/friend_group.png</file>
+               <file>res/images/sight.png</file>
      </qresource>
  </RCC>
diff --combined src/engine/engine.h
@@@ -61,7 -61,6 +61,6 @@@ public
   * MEMBER FUNCTIONS AND SLOTS
   ******************************************************************************/
  public slots:
      /**
      * @brief Slot to intercept error signal from ImageFetcher and SituareService
      *
      void loginOk();
  
      /**
+     * @brief Slot to receive location of crosshair
+     *
+     * @param ownLocation (Latitude and Longitude)
+     */
+     void receiveOwnLocation(QPointF ownLocation);
+     /**
      * @brief Calls reverseGeo from SituareService to translate coordinates to street address
      *
      */
   * SIGNALS
   ******************************************************************************/
  signals:
-     /**
-     * @brief Signals when new user data is ready
-     *
-     * @param user Instance of User
-     */
-     void userLocationReady(User *user);
 +
      /**
      * @brief Signals when new friends data is ready
      *
      */
      void friendsLocationsReady(QList<User *> &friendList);
  
+     /**
+     * @brief Signal causes mapengine to send updated location of crosshair.
+     *
+     */
+     void requestOwnLocation();
+     /**
+     * @brief Signals when new user data is ready
+     *
+     * @param user Instance of User
+     */
+     void userLocationReady(User *user);
  /*******************************************************************************
   * DATA MEMBERS
   ******************************************************************************/
@@@ -157,6 -169,7 +170,7 @@@ private
      GPSPositionInterface *m_gps;   ///< Instance of the gps position
      MainWindow *m_ui; ///< Instance of the MainWindow UI
      SituareService *m_situareService; ///< Instance of the situare server communication service
+     QPointF m_latestLocation; ///< Placeholder for user's latest asked location
  };
  
  #endif // ENGINE_H
diff --combined src/map/mapengine.cpp
@@@ -32,7 -32,6 +32,7 @@@
  #include <QRect>
  
  #include "frienditemshandler.h"
 +#include "gpslocationitem.h"
  #include "mapcommon.h"
  #include "mapengine.h"
  #include "maptile.h"
@@@ -60,13 -59,9 +60,13 @@@ MapEngine::MapEngine(QObject *parent
      m_ownLocation->hide(); // hide until first location info is received
      m_mapScene->addItem(m_ownLocation);
  
 +    m_gpsLocationItem = new GPSLocationItem();
 +    m_mapScene->addItem(m_gpsLocationItem);
 +
      m_friendItemsHandler = new FriendItemsHandler(m_mapScene, this);
      connect(this, SIGNAL(zoomLevelChanged(int)),
              m_friendItemsHandler, SLOT(refactorFriendItems(int)));
 +
      connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
              m_friendItemsHandler, SLOT(friendListUpdated(QList<User*>&)));
  }
@@@ -137,12 -132,17 +137,12 @@@ QRect MapEngine::calculateTileGrid(QPoi
      return QRect(topLeftX, topLeftY, gridWidth, gridHeight);
  }
  
 -void MapEngine::alignImmovableItems(QPoint viewTopLeft)
 -{
 -    qDebug() << __PRETTY_FUNCTION__ << "viewTopLeft:" << viewTopLeft;
 -}
 -
  void MapEngine::setLocation(QPoint sceneCoordinate)
  {
      qDebug() << __PRETTY_FUNCTION__;
  
      if (disableAutoCentering(sceneCoordinate))
 -        emit mapScrolled();
 +        emit mapScrolledManually();
  
      m_sceneCoordinate = sceneCoordinate;
      emit locationChanged(m_sceneCoordinate);
@@@ -234,11 -234,6 +234,11 @@@ void MapEngine::viewZoomFinished(
          m_zoomedIn = false;
          m_mapScene->removeOutOfViewTiles();
      }
 +
 +    if (m_zoomLevel == MAX_MAP_ZOOM_LEVEL)
 +        emit maxZoomLevelReached();
 +    else if (m_zoomLevel == MIN_VIEW_ZOOM_LEVEL)
 +        emit minZoomLevelReached();
  }
  
  void MapEngine::zoomIn()
@@@ -337,14 -332,6 +337,14 @@@ void MapEngine::receiveOwnLocation(Use
          m_ownLocation->show();
  }
  
 +void MapEngine::gpsPositionUpdate(QPointF position, qreal accuracy)
 +{
 +    m_gpsLocationItem->updatePosition(convertLatLonToSceneCoordinate(position), accuracy);
 +
 +    if (m_autoCenteringEnabled)
 +        setViewLocation(position);
 +}
 +
  bool MapEngine::disableAutoCentering(QPoint sceneCoordinate)
  {
      if (isAutoCenteringEnabled()) {
@@@ -374,7 -361,36 +374,42 @@@ void MapEngine::setAutoCentering(bool e
      m_autoCenteringEnabled = enabled;
  }
  
++
 +void MapEngine::gpsEnabled(bool enabled)
 +{
 +    m_gpsLocationItem->setEnabled(enabled);
 +}
++
+ QPointF MapEngine::convertSceneCoordinateToLatLon(int zoomLevel, QPoint sceneCoordinate)
+ {   
+     qDebug() << __PRETTY_FUNCTION__;
+     double tileFactor = 1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel);
+     double xFactor = (sceneCoordinate.x() / (TILE_SIZE_X*tileFactor));
+     double yFactor = (sceneCoordinate.y() / (TILE_SIZE_Y*tileFactor));
+     tileFactor = 1 << zoomLevel;
+     double longitude = xFactor / tileFactor * 360.0 - 180;
+     double n = M_PI - 2.0 * M_PI * yFactor / tileFactor;
+     double latitude = 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n)));
+     return QPointF(longitude, latitude);
+ }
+ void MapEngine::ownLocation()
+ {
+      qDebug() << __PRETTY_FUNCTION__;    
+     emit requestToGetViewPortContents();
+     QPointF ownLatitudeLongitudeLocation =
+             convertSceneCoordinateToLatLon(m_zoomLevel, m_viewArea.center());    
+     emit ownLocation(ownLatitudeLongitudeLocation);
+ }
+ void MapEngine::receiveViewSceneRect(QRect viewSceneRect)
+ {
+     qDebug() << __PRETTY_FUNCTION__;
+     m_viewArea = viewSceneRect;
+ }
diff --combined src/map/mapengine.h
@@@ -34,7 -34,6 +34,7 @@@
  #include "user/user.h"
  
  class FriendItemsHandler;
 +class GPSLocationItem;
  
  /**
  * @brief Map engine
@@@ -106,6 -105,13 +106,6 @@@ public
      QGraphicsScene* scene();
  
      /**
 -    * @brief Set auto centering.
 -    *
 -    * @param enabled true if enabled, false otherwise
 -    */
 -    void setAutoCentering(bool enabled);
 -
 -    /**
      * @brief Return tile path created from tile values.
      *
      * @param zoomLevel tile's zoom level
      */
      static QString tilePath(int zoomLevel, int x, int y);
  
+     /**
+     * @brief converts scene coordinates to latitude and longitude
+     *
+     * @param current zoom level
+     * @param sceneCoordinate that will be converted
+     */
+     QPointF convertSceneCoordinateToLatLon(int zoomLevel, QPoint sceneCoordinate);
  public slots:
      /**
 -    * @brief Slot for immovable scene items position correction
 -    *
 -    * @param viewTopLeft Scene coordinate of the viewport top left corner
 -    */
 -    void alignImmovableItems(QPoint viewTopLeft);
 -
 -    /**
      * @brief Slot for setting current view location
      *
      * Emits locationChanged signal.
      void viewResized(const QSize &size);
  
      /**
+     * @brief Returns own location crosshair's latitude and longitude coordinates
+     *
+     */
+     void ownLocation();
+     /**
      * @brief Slot to catch user own location data
      *
      * @param user User info
      */
-     void receiveOwnLocation(User *user);
+     void receiveOwnLocation(User *user);    
+     /**
+     * @brief Slot to receive visible area of map scene
+     *
+     * @param visible area of map scene
+     */
+     void receiveViewSceneRect(QRect viewSceneRect);
  
  private:
      /**
  
  private slots:
      /**
 +      * @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 gpsEnabled(bool enabled);
 +
 +    /**
 +      * @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.
      void mapImageReceived(int zoomLevel, int x, int y, const QPixmap &image);
  
      /**
 +    * @brief Set auto centering.
 +    *
 +    * @param enabled true if enabled, false otherwise
 +    */
 +    void setAutoCentering(bool enabled);
 +
 +    /**
      * @brief Slot for actions after view zoom is finished
      *
      * Does run removeOutOfViewTiles
@@@ -293,19 -300,21 +314,31 @@@ signals
      /**
      * @brief Signal to notify map scrolling.
      */
 -    void mapScrolled();
 +    void mapScrolledManually();
 +
 +    /**
 +    * @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.
 +    */
 +    void minZoomLevelReached();
  
      /**
+     * @brief Signal request mapView to update view port contents
+     */
+     void requestToGetViewPortContents();
+     /**
+     * @brief Signal sends location of crosshair
+     *
+     * @param ownLocation location of crosshair (Latitude, Longitude)
+     */
+     void ownLocation(const QPointF ownLocation);
+     /**
      * @brief Signal for zoom level change
      *
      * @param newZoomLevel New zoom level
   * DATA MEMBERS
   ******************************************************************************/
  private:
 -    bool m_autoCenteringEnabled;    ///< Auto centering enabled
 +    bool m_autoCenteringEnabled; ///< Auto centering enabled
      QPoint m_centerTile; ///< Current center tile
      FriendItemsHandler *m_friendItemsHandler; ///< Handler for friend and group items
 +    GPSLocationItem *m_gpsLocationItem; ///< Item pointing current location from GPS
      QPoint m_lastManualPosition;  ///< Last manually set position in scene coordinate
      MapFetcher *m_mapFetcher; ///< Fetcher for map tiles
      MapScene *m_mapScene; ///< Scene for map tiles
      QSize m_viewSize; ///< Current view size
      bool m_zoomedIn; ///< Flag for checking if zoomed in when zoom is finished
      int m_zoomLevel; ///< Current zoom level
+     QRect m_viewArea; ///< Visible area of map scene
  };
  
  #endif // MAPENGINE_H
diff --combined src/map/mapview.cpp
@@@ -37,8 -37,7 +37,8 @@@ MapView::MapView(QWidget *parent
      setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  
      m_zoomAnimation = new QPropertyAnimation(this, "viewScale", this);
 -    connect(m_zoomAnimation, SIGNAL(finished()), this, SIGNAL(viewZoomFinished()));
 +    connect(m_zoomAnimation, SIGNAL(finished()),
 +        this, SIGNAL(viewZoomFinished()));
  }
  
  void MapView::setZoomLevel(int zoomLevel)
@@@ -69,6 -68,7 +69,6 @@@ void MapView::setViewScale(qreal viewSc
      QTransform transform;
      transform.scale(viewScale, viewScale);
      setTransform(transform);
 -    emit viewContentChanged(mapToScene(viewport()->x(), viewport()->y()).toPoint());
  }
  
  void MapView::mouseMoveEvent(QMouseEvent *event)
@@@ -80,6 -80,7 +80,6 @@@
      emit viewScrolled(m_scenePosition);
  
      m_mousePosition = mapToScene(event->pos()).toPoint();
 -    emit viewContentChanged(mapToScene(viewport()->x(), viewport()->y()).toPoint());
  }
  
  void MapView::mousePressEvent(QMouseEvent *event)
@@@ -105,4 -106,32 +105,24 @@@ void MapView::resizeEvent(QResizeEvent 
  
      emit viewResized(event->size());
      emit viewResizedNewSize(viewport()->width(), viewport()->height());
 -    //emit viewContentChanged(mapToScene(viewport()->x(), viewport()->y()).toPoint());
  }
 -void MapView::showEvent(QShowEvent *event)
 -{
 -    qDebug() << __PRETTY_FUNCTION__;
 -
 -    QGraphicsView::showEvent(event);
 -    //emit viewContentChanged(mapToScene(viewport()->x(), viewport()->y()).toPoint());
 -}
+ void MapView::updateViewPortContent()
+ {
+     qDebug() << __PRETTY_FUNCTION__;
+     QPoint topLeft = mapToScene(viewport()->contentsRect().topLeft()).toPoint();
+     QPoint bottomRight = mapToScene(viewport()->contentsRect().bottomRight()).toPoint();
+     //emit viewContentChanged(QRect(topLeft, bottomRight));
+ }
+ QRect MapView::viewportContent()
+ {
+     QPoint topLeft = mapToScene(viewport()->contentsRect().topLeft()).toPoint();
+     QPoint bottomRight = mapToScene(viewport()->contentsRect().bottomRight()).toPoint();   
+     emit updateViewContent(QRect(topLeft, bottomRight));
+     return QRect(topLeft, bottomRight);
+ }
diff --combined src/map/mapview.h
@@@ -62,6 -62,13 +62,6 @@@ protected
      */
      void resizeEvent(QResizeEvent *event);
  
 -    /**
 -    * @brief Called when view is displayed.
 -    *
 -    * @param event show event
 -    */
 -    void showEvent(QShowEvent *event);
 -
  private:
      /**
      * @brief Event handler for mouse move events
@@@ -99,6 -106,17 +99,17 @@@ public slots
      */
      void setZoomLevel(int zoomLevel);
  
+     /**
+     * @brief updates view ports content
+     */
+     void updateViewPortContent();
+     /**
+     * @brief Slot for catching request to get view port contents.
+     * implementation of this slot sends signal that includes visble area of view port.
+     */
+     QRect viewportContent();
  private:
      /**
      * @brief Set new view scale
@@@ -136,10 -154,26 +147,25 @@@ signals
  
      /**
      * @brief Signal for informing that zooming animation is finished
 -    *
      */
      void viewZoomFinished();
  
      /**
+     * @brief Signal for updating view content
+     *
+     * Signal is emitted when view content needs an update.
+     * @param viewTopLeft Scene coordinate of the viewport top left corner
+     */
+     void viewContentChanged(QPoint viewTopLeft);
+     /**
+     * @brief Signal that sends visible area of map scene
+     *
+     * @param viewArea visible area of map scene
+     */
+     void updateViewContent(QRect viewArea);
+     /**
      * @brief Signal for drawing OSM license
      *
      * Signal is emitted when view is resized.
diff --combined src/ui/mainwindow.cpp
@@@ -51,7 -51,7 +51,7 @@@ MainWindow::MainWindow(QWidget *parent
      setCentralWidget(m_mapViewScreen);
      createMenus();
      setWindowTitle(tr("Situare"));
-       show();
+     show();
  
      m_locationDialog = new UpdateLocationDialog(this);
  
@@@ -66,9 -66,9 +66,9 @@@
              m_mapViewScreen, SIGNAL(friendsLocationsReady(QList<User*>&)));
  
        connect(this, SIGNAL(autoCentering(bool)),
 -            m_mapViewScreen, SLOT(enableAutoCentering(bool)));
 +            m_mapViewScreen, SIGNAL(enableAutoCentering(bool)));
      connect(this, SIGNAL(positionReceived(QPointF, qreal)),
 -            m_mapViewScreen, SLOT(positionReceived(QPointF, qreal)));
 +            m_mapViewScreen, SIGNAL(positionReceived(QPointF, qreal)));
      connect(m_mapViewScreen, SIGNAL(mapLocationChanged()),
              this, SLOT(mapLocationChanged()));
  
      connect(this, SIGNAL(zoomOutKeyPressed()),
              m_mapViewScreen, SIGNAL(zoomOutKeyPressed()));
  
+     connect(this, SIGNAL(requestOwnLocation()),
+             m_mapViewScreen, SIGNAL(requestOwnLocation()));
+     connect(m_mapViewScreen, SIGNAL(ownLocation(QPointF)),
+             this, SIGNAL(ownLocation(QPointF)));
      this->toggleProgressIndicator(true);
  
      grabZoomKeys(true);
@@@ -115,18 -120,18 +120,20 @@@ void MainWindow::createMenus(
      m_gpsToggleAct->setChecked(true);
      connect(m_gpsToggleAct, SIGNAL(toggled(bool)),
          this, SLOT(gpsToggled(bool)));
+     connect(m_gpsToggleAct, SIGNAL(toggled(bool)),
+             m_mapViewScreen, SLOT(setOwnLocationCrosshairVisibility(bool)));
      m_autoCenteringAct = new QAction(tr("Auto centering"), this);
      m_autoCenteringAct->setCheckable(true);
      m_autoCenteringAct->setChecked(true);
      connect(m_autoCenteringAct, SIGNAL(toggled(bool)),
 -        this, SLOT(autoCenteringToggled(bool)));    
 -      
 +        this, SLOT(autoCenteringToggled(bool))); 
 +    connect(this, SIGNAL(enableGPS(bool)),
 +            m_mapViewScreen, SIGNAL(gpsEnabled(bool)));
 +
      m_viewMenu = menuBar()->addMenu(tr("Main"));
  
      m_viewMenu->addAction(m_toSettingsAct);
-       m_viewMenu->addAction(m_gpsToggleAct);
+     m_viewMenu->addAction(m_gpsToggleAct);
      m_viewMenu->addAction(m_autoCenteringAct);
      m_viewMenu->setObjectName(tr("Menu"));
  }
diff --combined src/ui/mapviewscreen.cpp
@@@ -25,7 -25,8 +25,7 @@@
  #include "panelsidebar.h"
  
  MapViewScreen::MapViewScreen(QWidget *parent)
 -   : QWidget(parent),
 -     m_autoCenteringEnabled(false)
 +   : QWidget(parent)
  {
      MapView *mapView = new MapView(this);
      m_mapEngine = new MapEngine(this);
@@@ -37,7 -38,9 +37,9 @@@
      PanelSideBar *friendsListPanelSidebar = new PanelSideBar(this, RIGHT);
  
      m_zoomButtonPanel = new ZoomButtonPanel(this, ZOOM_BUTTON_PANEL_POSITION_X,
-                                             ZOOM_BUTTON_PANEL_POSITION_Y);
+                                             ZOOM_BUTTON_PANEL_POSITION_Y);   
+     m_ownLocationCrosshair = 0;
  
      connect(mapView, SIGNAL(viewScrolled(QPoint)),
              m_mapEngine, SLOT(setLocation(QPoint)));
@@@ -47,6 -50,8 +49,8 @@@
              mapView, SLOT(setZoomLevel(int)));
      connect(mapView, SIGNAL(viewResized(QSize)),
              m_mapEngine, SLOT(viewResized(QSize)));
+     connect(mapView, SIGNAL(updateViewContent(QRect)),
+             m_mapEngine, SLOT(receiveViewSceneRect(QRect)));
      connect(mapView, SIGNAL(viewZoomFinished()),
              m_mapEngine, SLOT(viewZoomFinished()));
  
      connect(mapView, SIGNAL(viewResizedNewSize(int, int)),
              friendsListPanelSidebar, SLOT(reDrawSidebar(int, int)));
  
 -    connect(m_zoomButtonPanel->m_zoomInBtn, SIGNAL(clicked()),
 +    connect(m_zoomButtonPanel->m_zoomInButton, SIGNAL(clicked()),
              m_mapEngine, SLOT(zoomIn()));
 -    connect(m_zoomButtonPanel->m_zoomOutBtn, SIGNAL(clicked()),
 +    connect(m_zoomButtonPanel->m_zoomOutButton, SIGNAL(clicked()),
              m_mapEngine, SLOT(zoomOut()));
 +    connect(m_mapEngine, SIGNAL(zoomLevelChanged(int)),
 +            m_zoomButtonPanel, SLOT(resetButtons()));
 +    connect(m_mapEngine, SIGNAL(maxZoomLevelReached()),
 +            m_zoomButtonPanel, SLOT(disableZoomInButton()));
 +    connect(m_mapEngine, SIGNAL(minZoomLevelReached()),
 +            m_zoomButtonPanel, SLOT(disableZoomOutButton()));
  
      connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
              m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
      connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
              m_mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
  
 -    connect(m_mapEngine, SIGNAL(mapScrolled()),
 -            this, SLOT(locationChanged()));
 +    connect(m_mapEngine, SIGNAL(mapScrolledManually()),
 +            this, SIGNAL(mapLocationChanged()));
 +
 +    connect(this, SIGNAL(positionReceived(QPointF,qreal)),
 +            m_mapEngine, SLOT(gpsPositionUpdate(QPointF,qreal)));
 +    connect(this, SIGNAL(enableAutoCentering(bool)),
 +            m_mapEngine, SLOT(setAutoCentering(bool)));
 +    connect(this, SIGNAL(gpsEnabled(bool)),
 +            m_mapEngine, SLOT(gpsEnabled(bool)));
  
+     connect(mapView, SIGNAL(viewResizedNewSize(int, int)),
+             this, SLOT(drawOwnLocationCrosshair(int, int)));
+     connect(mapView, SIGNAL(viewResizedNewSize(int, int)),
+              this, SLOT(setViewPortSize(int, int)));
+     connect(m_mapEngine, SIGNAL(requestToGetViewPortContents()),
+             mapView, SLOT(viewportContent()));
+     connect(mapView, SIGNAL(updateViewContent(QRect)),
+             m_mapEngine, SLOT(receiveViewSceneRect(QRect)));
+     connect(this, SIGNAL(requestOwnLocation()),
+             m_mapEngine, SLOT(ownLocation()));
+     connect(m_mapEngine, SIGNAL(ownLocation(QPointF)),
+             this, SIGNAL(ownLocation(QPointF)));
      QHBoxLayout *mapViewLayout = new QHBoxLayout;
  
      m_osmLicense = new QLabel(this);
@@@ -129,3 -136,64 +148,41 @@@ void MapViewScreen::drawOsmLicense(int 
                          height - m_osmLicense->fontMetrics().height());
  }
  
 -void MapViewScreen::locationChanged()
 -{
 -    qDebug() << __PRETTY_FUNCTION__;
 -
 -    if (m_autoCenteringEnabled)
 -        emit mapLocationChanged();
 -}
 -
 -void MapViewScreen::positionReceived(QPointF position, qreal accuracy)
 -{
 -    qDebug() << __PRETTY_FUNCTION__;
 -
 -    if (m_autoCenteringEnabled)
 -        m_mapEngine->setViewLocation(position);
 -}
 -
 -void MapViewScreen::enableAutoCentering(bool enabled)
 -{
 -    qDebug() << __PRETTY_FUNCTION__;
 -
 -    m_autoCenteringEnabled = enabled;
 -    m_mapEngine->setAutoCentering(enabled);
 -}
+ void MapViewScreen::drawOwnLocationCrosshair(int width, int height)
+ {
+     qDebug() << __PRETTY_FUNCTION__;
+     if (m_drawOwnLocationCrosshair) {
+         m_ownLocationCrosshair->move(width/2 - m_ownLocationCrosshair->pixmap()->width()/2,
+                             height/2 - m_ownLocationCrosshair->pixmap()->height()/2);
+     }
+ }
+ void MapViewScreen::setOwnLocationCrosshairVisibility(bool visibility)
+ {   
+     if (visibility == false) {
+         if (m_ownLocationCrosshair == 0) {
+             m_ownLocationCrosshair = new QLabel(this);
+             QPixmap crosshairImage(":/res/images/sight.png");
+             m_ownLocationCrosshair->setPixmap(crosshairImage);
+             m_ownLocationCrosshair->setFixedSize(crosshairImage.size());
+         }
+         m_ownLocationCrosshair->show();
+         m_drawOwnLocationCrosshair = true;
+         drawOwnLocationCrosshair(m_viewPortWidth, m_viewPortHeight);
+     }
+     else {
+         m_ownLocationCrosshair->hide();
+         m_drawOwnLocationCrosshair = false;
+     }
+ }
+ void MapViewScreen::setViewPortSize(int width, int height)
+ {
+     m_viewPortWidth = width;
+     m_viewPortHeight = height;
+ }
diff --combined src/ui/mapviewscreen.h
@@@ -32,6 -32,8 +32,6 @@@
  
  /**
  * @brief Map View class. Used to display Map
 -*
 -* @class MapViewScreen mainwindow.h "src/ui/mainwindow.h"
  */
  class MapViewScreen : public QWidget
  {
@@@ -48,8 -50,23 +48,16 @@@ public
  /*******************************************************************************
   * MEMBER FUNCTIONS AND SLOTS
   ******************************************************************************/
+ public slots:    
+     /**
+     * @brief Slot for setting own location crosshair visibility
+     *
+     * @param visibility false <-> show, true <-> hide
+     */
+     void setOwnLocationCrosshairVisibility(bool visibility);
  private slots:
      /**
 -    * @brief Slot for enabling auto centering.
 -    *
 -    * @param enabled true if map should center to GPS position, false otherwise
 -    */
 -    void enableAutoCentering(bool enabled);
 -
 -    /**
      * @brief Slot for drawing the Open Street Map license text
      *
      * @param width Width of the viewport
      */
      void drawOsmLicense(int width, int height);
  
+     /**
+     * @brief Slot for drawing the own location crosshair
+     *
+     * @param width Width of the viewport
+     * @param height Height of the viewport
+     */
+     void drawOwnLocationCrosshair(int width, int height);
 -    /**
 -    * @brief Slot for map location change.
 -    */
 -    void locationChanged();
++//    /**
++//    * @brief Slot for map location change.
++//    */
++//    void locationChanged();
+     /**
+     * @brief Set correnct view port size to datamembers
+     *
+     * @param width Width of the viewport
+     * @param height Height of the viewport
+     */
+     void setViewPortSize(const int width, const int height);
 -    /**
 -    * @brief Slot for GPS position.
 -    *
 -    * @param position latitude and longitude values
 -    * @param accuracy coordinate accuracy in metres
 -    */
 -    void positionReceived(QPointF position, qreal accuracy);
 -
  /*******************************************************************************
   * SIGNALS
   ******************************************************************************/
  signals:
      /**
 +    * @brief Signal for enabling auto centering.
 +    *
 +    * @param enabled true if map should center to GPS position, false otherwise
 +    */
 +    void enableAutoCentering(bool enabled);
 +
 +    /**
      * @brief Signal when friend list locations are fetched
      *
      * Forwarded to map engine and friends list panel
      */
      void friendsLocationsReady(QList<User *> &friendsList);
  
 -      /**
 +    /**
 +      * @brief Signal for GPS enabling / disabling
 +      *
 +      * @param enabled True is GPS is enabled, otherwise false
 +      */
 +    void gpsEnabled(bool enabled);
 +
 +    /**
      * @brief Signal for map location change.
      */
      void mapLocationChanged();
  
      /**
 +    * @brief Slot for GPS position.
 +    *
 +    * @param position latitude and longitude values
 +    * @param accuracy coordinate accuracy in metres
 +    */
 +    void positionReceived(QPointF position, qreal accuracy);
 +
 +    /**
+     * @brief Signal from MapEngine to SituareEngine is travelling here
+     */
+     void ownLocation(QPointF ownLatitudeLongitudeLocation);
+     /**
+     * @brief Signal from SituareEngine to MapEngine is travelling here
+     */
+     void requestOwnLocation();
+     /**
      * @brief Signal when user location is fetched
      *
      * @param user User data
   * DATA MEMBERS
   ******************************************************************************/
  private:
-     FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
-     MapEngine *m_mapEngine;              ///< MapEngine
-     QLabel *m_osmLicense;                ///< Label for Open Street Map license
-     UserInfoPanel *m_userPanel;          ///< Instance of the user information panel
-     ZoomButtonPanel *m_zoomButtonPanel;  ///< Instance of zoom button panel
 -    MapEngine *m_mapEngine;                 ///< MapEngine
 -    UserInfoPanel *m_userPanel;             ///< Instance of the user information panel
 -    FriendListPanel *m_friendsListPanel;    ///< Instance of friends list panel
 -    ZoomButtonPanel *m_zoomButtonPanel;     ///< Instance of zoom button panel
 -    QLabel *m_osmLicense;                   ///< Label for Open Street Map license
 -    bool m_autoCenteringEnabled;            ///< Enable
 -    QLabel *m_ownLocationCrosshair;         ///< Label that show ownLocationCrosshair
 -    bool m_drawOwnLocationCrosshair;        ///< Flag for making ownLocationCrosshair visible or not
 -    int m_viewPortWidth;                    ///< Width of view port
 -    int m_viewPortHeight;                   ///< Height of view port
++      bool m_drawOwnLocationCrosshair;        ///< Flag for making ownLocationCrosshair visible or not
++      FriendListPanel *m_friendsListPanel; ///< Instance of friends list panel
++      MapEngine *m_mapEngine;              ///< MapEngine
++      QLabel *m_osmLicense;                ///< Label for Open Street Map license
++      QLabel *m_ownLocationCrosshair;         ///< Label that show ownLocationCrosshair    
++      UserInfoPanel *m_userPanel;          ///< Instance of the user information panel
++      int m_viewPortHeight;   ///< Height of view port
++      int m_viewPortWidth;                    ///< Width of view port
++      ZoomButtonPanel *m_zoomButtonPanel;  ///< Instance of zoom button panel
  };
  
  #endif // MAPVIEWTAB_H