Added flag for map scroll direction
authorSami Rämö <sami.ramo@ixonos.com>
Mon, 31 May 2010 10:17:01 +0000 (13:17 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Mon, 31 May 2010 10:17:01 +0000 (13:17 +0300)
 - Scroll direction is used for deciding which side of the world
   should be spanned

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

index 1258458..9832afd 100644 (file)
@@ -96,4 +96,6 @@ 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 8a159ad..34fb2b2 100644 (file)
@@ -251,7 +251,7 @@ void MapEngine::getTiles(QPoint sceneCoordinate)
 
 //    m_friendItemsHandler->spanFriendItems(tilesSceneRect);
 
-    m_mapScene->spanItems();
+    m_mapScene->spanItems(m_scrollDirection);
 }
 
 void MapEngine::gpsPositionUpdate(QPointF position, qreal accuracy)
@@ -372,6 +372,11 @@ void MapEngine::setLocation(QPoint sceneCoordinate)
         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();
 
index f9ff925..9495ceb 100644 (file)
@@ -27,6 +27,8 @@
 
 #include <QtCore>
 
+#include "mapcommon.h"
+
 class QGraphicsScene;
 
 class FriendItemsHandler;
@@ -370,6 +372,7 @@ 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 d8ea772..29000aa 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "mapcommon.h"
 #include "mapengine.h"
+#include "maptile.h"
 
 #include "mapscene.h"
 
@@ -174,7 +175,7 @@ void MapScene::spanItem(QGraphicsItem *item, QRect tilesSceneRect)
         item->moveBy(-WORLD_PIXELS_X, 0);
 }
 
-void MapScene::spanItems()
+void MapScene::spanItems(ScrollDirection direction)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -185,7 +186,7 @@ void MapScene::spanItems()
                                                        << m_viewRect.topLeft().y() << ","
                                                        << m_viewRect.bottomRight().x()
                                                        << m_viewRect.bottomRight().y();
-    if (m_viewRect.left() < 0) {
+    if (direction == SCROLL_WEST) {
         spanRect = m_viewRect;
         spanRect.setTop(0);
         spanRect.setBottom(WORLD_PIXELS_Y);
index a2dffe0..ff7a917 100644 (file)
@@ -24,7 +24,9 @@
 
 #include <QGraphicsScene>
 
-#include "maptile.h"
+#include "mapcommon.h"
+
+class MapTile;
 
 /**
 * @brief Map scene for storing MapTile items
@@ -120,7 +122,7 @@ public:
 
     static void spanItem(QGraphicsItem *item, QRect tilesSceneRect);
 
-    void spanItems();
+    void spanItems(ScrollDirection direction);
 
     /**
     * @brief Save new view rect