Self made kinetic scrolling first working version
[situare] / src / map / mapengine.cpp
index 12c8e3a..ca6d33e 100644 (file)
@@ -88,6 +88,9 @@ MapEngine::MapEngine(QObject *parent)
             this, SIGNAL(locationItemClicked(QList<QString>)));
 
     m_scroller = &MapScroller::getInstance();
+
+    connect(m_scroller, SIGNAL(coordinateUpdated(QPoint)),
+            this, SLOT(setLocation(QPoint)));
 }
 
 MapEngine::~MapEngine()
@@ -392,10 +395,7 @@ void MapEngine::setLocation(QPoint sceneCoordinate)
     qDebug() << __PRETTY_FUNCTION__;
 
     // jump to opposite side of the world if world horizontal limit is exceeded
-    if (sceneCoordinate.x() < MAP_MIN_PIXEL_X)
-        sceneCoordinate.setX(sceneCoordinate.x() + MAP_PIXELS_X);
-    else if (sceneCoordinate.x() > MAP_MAX_PIXEL_X)
-        sceneCoordinate.setX(sceneCoordinate.x() - MAP_PIXELS_X);
+    sceneCoordinate.setX(normalize(sceneCoordinate.x(), MAP_MIN_PIXEL_X, MAP_MAX_PIXEL_X));
 
     // don't allow vertical scene coordinates go out of the map
     sceneCoordinate.setY(qBound(MAP_MIN_PIXEL_Y, sceneCoordinate.y(), MAP_MAX_PIXEL_Y));