+ // create rects for left and right side
+ QRect leftRect = sceneRect().toRect(); // this way we get the horizontal limits of the scene
+ leftRect.setTop(0);
+ leftRect.setBottom(WORLD_PIXELS_Y);
+ QRect rightRect = leftRect;
+
+ // calculate current horizontal area shown on the view
+ int viewSceneWidth = (1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel)) * viewSize.width();
+ int viewSceneLeft = sceneCoordinate.x() - viewSceneWidth / 2;
+ int viewSceneRight = sceneCoordinate.x() + viewSceneWidth / 2;
+
+ // limit rect widths to be out of the current view
+ leftRect.setRight(viewSceneLeft);
+ rightRect.setLeft(viewSceneRight);
+
+ // move all items which intersects the rects
+ if (leftRect.width() > 0)
+ moveIntersectingItemsHorizontally(leftRect, WORLD_PIXELS_X);
+ if (rightRect.width() > 0)
+ moveIntersectingItemsHorizontally(rightRect, -WORLD_PIXELS_X);
+
+ /// @todo get small rects from boths sides of the view
+
+ /// @todo get all intersecting items, check which end of the view is nearer and move there
+
+
+// QRect spanRect; // = m_viewRect;
+// spanRect.setTop(0);
+// spanRect.setBottom(WORLD_PIXELS_Y);
+// int delta;
+
+// int viewSceneWidth = (1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel)) * viewSize.width();
+// int gap = WORLD_PIXELS_X - viewSceneWidth;
+// if (gap < 0)
+// qCritical() << __PRETTY_FUNCTION__ << "viewSceneWidth > WORLD_PIXELS_X";
+
+// int limiterUnNormalized = sceneCoordinate.x() + ((viewSceneWidth + gap) / 2);
+// int limiter = MapEngine::normalize(limiterUnNormalized, 0, WORLD_PIXELS_X -1);
+
+// if (sceneCoordinate.x() > limiter) {
+// spanRect.setRight(limiter);
+// spanRect.setLeft(sceneRect().left());
+// delta = WORLD_PIXELS_X;
+// qWarning() << __PRETTY_FUNCTION__ << "-->";
+// }
+// else {
+// spanRect.setLeft(limiter);
+// spanRect.setRight(sceneRect().right());
+// delta = -WORLD_PIXELS_X;
+// qWarning() << __PRETTY_FUNCTION__ << "<--";
+// }
+
+// QTransform transform;
+// qreal scale = pow(2, zoomLevel - MAX_MAP_ZOOM_LEVEL);
+// transform.scale(scale, scale);
+// QList<QGraphicsItem *> spanItems = items(spanRect, Qt::IntersectsItemBoundingRect,
+// Qt::DescendingOrder, transform);
+
+// foreach (QGraphicsItem *item, spanItems) {
+// if (dynamic_cast<MapTile *>(item))
+// continue;
+// item->moveBy(delta, 0);
+// }
+
+// return spanRect;