Span items also when items are moved
authorSami Rämö <sami.ramo@ixonos.com>
Tue, 8 Jun 2010 12:01:34 +0000 (15:01 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Tue, 8 Jun 2010 12:01:34 +0000 (15:01 +0300)
 - span items also when friends locations, own Situare location
   or GPS location are changed

 - some cleaning

src/map/frienditemshandler.cpp
src/map/frienditemshandler.h
src/map/mapcommon.h
src/map/mapengine.cpp
src/map/mapengine.h
src/map/mapscene.cpp
src/map/mapscene.h

index d5fd823..7775f7c 100644 (file)
@@ -259,20 +259,6 @@ void FriendItemsHandler::refactorFriendItems(int zoomLevel)
     checkAllFriendsForCollidingFriends();
 }
 
-void FriendItemsHandler::spanHiddenFriendLocationItems(ScrollDirection direction, QRect spanRect, QPoint sceneCoordinate)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    int delta = -WORLD_PIXELS_X;
-    if (sceneCoordinate.x() > spanRect.right())
-        delta = WORLD_PIXELS_X;
-
-    foreach (FriendLocationItem *item, m_friendItems) {
-        if (!item->isVisible() && spanRect.contains(item->pos().toPoint()))
-            item->moveBy(delta, 0);
-    }
-}
-
 void FriendItemsHandler::updateFriendItem(FriendLocationItem *friendItem, User *friendData)
 {
     qDebug() << __PRETTY_FUNCTION__;
index 2bbd059..2676517 100644 (file)
@@ -57,9 +57,6 @@ public:
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
-public:
-    void spanHiddenFriendLocationItems(ScrollDirection direction, QRect spanRect, QPoint sceneCoordinate);
-
 public slots:
     /**
       * @brief Re-factors all FriendLocationItem and FriendGroupItem items.
index 47f29a7..b3270c5 100644 (file)
@@ -96,6 +96,4 @@ const QString ERROR_VALUE_NOT_FOUND_ON_SETTINGS = "Value_not_found";
 */
 const int UNDEFINED = -1;
 
-enum ScrollDirection { SCROLL_EAST, SCROLL_WEST };
-
 #endif // MAPCOMMON_H
index 68f8183..4530ca8 100644 (file)
@@ -78,6 +78,9 @@ MapEngine::MapEngine(QObject *parent)
     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
             m_friendItemsHandler, SLOT(friendListUpdated(QList<User*>&)));
 
+    connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
+            this, SLOT(friendsPositionsUpdated()));
+
     connect(m_friendItemsHandler, SIGNAL(locationItemClicked(QList<QString>)),
             this, SIGNAL(locationItemClicked(QList<QString>)));
 }
@@ -191,6 +194,14 @@ bool MapEngine::disableAutoCentering(QPoint sceneCoordinate)
     return false;
 }
 
+void MapEngine::friendsPositionsUpdated()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_mapScene->spanItems(m_zoomLevel, m_sceneCoordinate, m_viewSize);
+    /// @todo removed m_friendItemsHandler->refactorFriendItems(m_zoomLevel);
+}
+
 void MapEngine::getTiles(QPoint sceneCoordinate)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -238,6 +249,7 @@ void MapEngine::gpsPositionUpdate(QPointF position, qreal accuracy)
     qDebug() << __PRETTY_FUNCTION__;
 
     m_gpsLocationItem->updatePosition(convertLatLonToSceneCoordinate(position), accuracy);
+    m_mapScene->spanItems(m_zoomLevel, m_sceneCoordinate, m_viewSize);
 
     if (m_autoCenteringEnabled)
         setViewLocation(position);
@@ -386,6 +398,8 @@ void MapEngine::receiveOwnLocation(User *user)
     else {
         m_ownLocation->hide();
     }
+
+    m_mapScene->spanItems(m_zoomLevel, m_sceneCoordinate, m_viewSize);
 }
 
 QGraphicsScene* MapEngine::scene()
@@ -415,11 +429,6 @@ void MapEngine::setLocation(QPoint sceneCoordinate)
     else if (sceneCoordinate.x() > WORLD_PIXELS_X - 1)
         sceneCoordinate.setX(sceneCoordinate.x() - WORLD_PIXELS_X);
 
-    if (sceneCoordinate.x() > m_sceneCoordinate.x())
-        m_scrollDirection = SCROLL_EAST;
-    else
-        m_scrollDirection = SCROLL_WEST;
-
     if (disableAutoCentering(sceneCoordinate))
         emit mapScrolledManually();
 
@@ -431,7 +440,7 @@ void MapEngine::setLocation(QPoint sceneCoordinate)
         m_mapScene->removeOutOfViewTiles(m_viewTilesGrid, m_zoomLevel);
     }
 
-    m_mapScene->spanItems(m_scrollDirection, m_zoomLevel, m_sceneCoordinate, m_viewSize);
+    m_mapScene->spanItems(m_zoomLevel, m_sceneCoordinate, m_viewSize);
 }
 
 void MapEngine::setZoomLevel(int newZoomLevel)
@@ -547,6 +556,8 @@ void MapEngine::zoomed()
     m_mapScene->setTilesDrawingLevels(m_zoomLevel);
     getTiles(m_sceneCoordinate);
     m_mapScene->setSceneVerticalOverlap(m_viewSize.height(), m_zoomLevel);
+    /// @todo remove m_friendItemsHandler->refactorFriendItems(m_zoomLevel);
+    m_mapScene->spanItems(m_zoomLevel, m_sceneCoordinate, m_viewSize);
 }
 
 void MapEngine::zoomIn()
index ec75097..1633b5d 100644 (file)
@@ -264,6 +264,8 @@ private:
     void zoomed();
 
 private slots:
+    void friendsPositionsUpdated();
+
     /**
       * @brief Slot for GPS position updates
       *
@@ -383,7 +385,6 @@ private:
     MapFetcher *m_mapFetcher;                   ///< Fetcher for map tiles
     MapScene *m_mapScene;                       ///< Scene for map tiles
     OwnLocationItem *m_ownLocation;             ///< Item to show own location
-    ScrollDirection m_scrollDirection;
 };
 
 #endif // MAPENGINE_H
index 2e16267..6d4b926 100644 (file)
@@ -218,7 +218,7 @@ void MapScene::setTilesDrawingLevels(int zoomLevel)
     }
 }
 
-void MapScene::spanItems(ScrollDirection direction, int zoomLevel, QPoint sceneCoordinate, QSize viewSize)
+void MapScene::spanItems(int zoomLevel, QPoint sceneCoordinate, QSize viewSize)
 {
 //    qWarning() << __PRETTY_FUNCTION__;
 
index 73431c8..16fa8d5 100644 (file)
@@ -115,7 +115,7 @@ public:
     */
     void setTilesDrawingLevels(int zoomLevel);
 
-    void spanItems(ScrollDirection direction, int zoomLevel, QPoint sceneCoordinate, QSize viewSize);
+    void spanItems(int zoomLevel, QPoint sceneCoordinate, QSize viewSize);
 
     /**
     * @brief Save new tiles scene rect