Fixed bug #5831: Friend groups do not always release friends when zooming in
authorSami Rämö <sami.ramo@ixonos.com>
Tue, 15 Jun 2010 12:57:45 +0000 (15:57 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Tue, 15 Jun 2010 13:29:28 +0000 (16:29 +0300)
 - Reviewed by Jussi Laitinen

src/map/baselocationitem.cpp
src/map/baselocationitem.h
src/map/frienditemshandler.cpp

index 95f5acd..0c1a3fc 100644 (file)
@@ -38,15 +38,14 @@ QRect BaseLocationItem::sceneTransformedBoundingRect(int zoomLevel) const
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    QRect rect = sceneBoundingRect().toRect();
-
-    // returned rect size is size of original image and not scaled to size of currently presented
-    // image because of using ItemIgnoresTransformations flag. Thus the rect must be scaled
+    // picture side length used for collision detection
+    const int IMAGE_SIDE = 58;
 
     int multiplier = 1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel);
+    int side = multiplier * IMAGE_SIDE;
 
-    int heightDelta = (rect.height() * multiplier - rect.height()) / 2;
-    int widthDelta = (rect.width() * multiplier - rect.width()) / 2;
+    QPoint center = pos().toPoint();
+    QPoint topLeft(center.x() - side / 2, center.y() - side / 2);
 
-    return rect.adjusted(-widthDelta, -heightDelta, widthDelta, heightDelta);
+    return QRect(topLeft, QSize(side, side));
 }
index ed85f74..72826a1 100644 (file)
@@ -49,11 +49,11 @@ public:
  ******************************************************************************/
 public:
     /**
-    * @brief Return item sceneBoundingRect transformed to given zoom level
+    * @brief Return item rect transformed to given zoom level
     *
     * Because of using ItemIgnoresTransformations, and not scaling the item, the default
-    * sceneBoundingRect does always return the lowest map tile level scene bounding rect which
-    * is scaled to current zoom level.
+    * sceneBoundingRect can't be used because it always returns the lowest map tile level scene
+    * bounding rect. This method does return rect scaled to given zoom level.
     *
     * @param zoomLevel Zoom level for which the sceneBoundingRect should be transformed
     * @return sceneBoundingRect transformed to given zoom level
index 9562570..954153a 100644 (file)
@@ -271,10 +271,12 @@ void FriendItemsHandler::refactorFriendItems(int zoomLevel)
 
     m_zoomLevel = zoomLevel;
 
-    mergeCollidingGroups();
-    dropOutOfGroupFriends();
-    checkAllGroupsForCollidingFriends();
-    checkAllFriendsForCollidingFriends();
+    for (int repeat = 2; repeat > 0; repeat--) {
+        mergeCollidingGroups();
+        dropOutOfGroupFriends();
+        checkAllGroupsForCollidingFriends();
+        checkAllFriendsForCollidingFriends();
+    }
 }
 
 void FriendItemsHandler::updateFriendItem(FriendLocationItem *friendItem, User *friendData)