From: Sami Rämö Date: Tue, 15 Jun 2010 12:57:45 +0000 (+0300) Subject: Fixed bug #5831: Friend groups do not always release friends when zooming in X-Git-Tag: v0.6~1^2~1 X-Git-Url: https://vcs.maemo.org/git/?p=situare;a=commitdiff_plain;h=ef2d91fa3039ab30ade162db872027ff6d7dff6f Fixed bug #5831: Friend groups do not always release friends when zooming in - Reviewed by Jussi Laitinen --- diff --git a/src/map/baselocationitem.cpp b/src/map/baselocationitem.cpp index 95f5acd..0c1a3fc 100644 --- a/src/map/baselocationitem.cpp +++ b/src/map/baselocationitem.cpp @@ -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)); } diff --git a/src/map/baselocationitem.h b/src/map/baselocationitem.h index ed85f74..72826a1 100644 --- a/src/map/baselocationitem.h +++ b/src/map/baselocationitem.h @@ -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 diff --git a/src/map/frienditemshandler.cpp b/src/map/frienditemshandler.cpp index 9562570..954153a 100644 --- a/src/map/frienditemshandler.cpp +++ b/src/map/frienditemshandler.cpp @@ -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)