Changed grouping algorithm
authorSami Rämö <sami.ramo@ixonos.com>
Thu, 8 Jul 2010 10:27:19 +0000 (13:27 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Thu, 8 Jul 2010 10:27:19 +0000 (13:27 +0300)
 - All groups are always destructed and then created from
   scratch if required

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

index 8286f7f..a790125 100644 (file)
@@ -184,6 +184,15 @@ void FriendItemsHandler::deleteFriendItem(FriendLocationItem *item)
     delete item;
 }
 
+void FriendItemsHandler::destructGroups()
+{
+    qDeleteAll(m_friendGroupItems);
+    m_friendGroupItems.clear();
+
+    foreach (FriendLocationItem *item, m_friendItems)
+        item->setPartOfGroup(false);
+}
+
 void FriendItemsHandler::dropFriendFromAllGroups(FriendLocationItem *item)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -284,12 +293,20 @@ void FriendItemsHandler::refactorFriendItems(int zoomLevel)
 
     m_zoomLevel = zoomLevel;
 
-    for (int repeat = 2; repeat > 0; repeat--) {
-        mergeCollidingGroups();
-        dropOutOfGroupFriends();
-        checkAllGroupsForCollidingFriends();
-        checkAllFriendsForCollidingFriends();
-    }
+    QTime time;
+    time.start();
+
+//    for (int repeat = 2; repeat > 0; repeat--) {
+//        mergeCollidingGroups();
+//        dropOutOfGroupFriends();
+//        checkAllGroupsForCollidingFriends();
+//        checkAllFriendsForCollidingFriends();
+//    }
+
+    destructGroups();
+    checkAllFriendsForCollidingFriends();
+
+    qWarning() << __PRETTY_FUNCTION__ << "zoom level:" << zoomLevel << "time elapsed:" << time.elapsed() << "ms";
 }
 
 void FriendItemsHandler::updateFriendItem(FriendLocationItem *friendItem, User *friendData)
index ad7a133..7ce25af 100644 (file)
@@ -143,6 +143,8 @@ private:
       */
     void deleteFriendItem(FriendLocationItem *item);
 
+    void destructGroups();
+
     /**
       * @brief Drop FriendLocationItem from all FriendGroupItem groups
       *