Fixed defects found in review stacked_friends
authorSami Rämö <sami.ramo@ixonos.com>
Mon, 10 May 2010 12:55:42 +0000 (15:55 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Mon, 10 May 2010 12:55:42 +0000 (15:55 +0300)
 - Code reviewed by Henri

 - Unit & functional tests reviewed by Jussi

doc/test_cases/functionality-tests.doc
src/map/friendgroupitem.cpp
src/map/friendgroupitem.h
src/map/frienditemshandler.cpp
src/map/friendlocationitem.cpp
tests/map/friendgroupitem/testfriendgroupitem.cpp

index f2b2b1f..2c79150 100644 (file)
Binary files a/doc/test_cases/functionality-tests.doc and b/doc/test_cases/functionality-tests.doc differ
index 6bd1f5a..8ae761e 100644 (file)
@@ -49,7 +49,6 @@ void FriendGroupItem::dropFriend(FriendLocationItem *item)
 
     m_friends.removeOne(item);
     item->setPartOfGroup(false);
-    item->show();
 }
 
 bool FriendGroupItem::dropFriends(int zoomLevel)
@@ -57,7 +56,8 @@ bool FriendGroupItem::dropFriends(int zoomLevel)
     qDebug() << __PRETTY_FUNCTION__;
 
     foreach (FriendLocationItem *friendItem, m_friends) {
-        if (!friendItem->sceneTransformedBoundingRect(zoomLevel).intersects(sceneTransformedBoundingRect(zoomLevel)))
+        if (!friendItem->sceneTransformedBoundingRect(zoomLevel)
+            .intersects(sceneTransformedBoundingRect(zoomLevel)))
             dropFriend(friendItem);
     }
 
@@ -78,7 +78,6 @@ void FriendGroupItem::joinFriend(FriendLocationItem *item)
 
     m_friends.append(item);
     item->setPartOfGroup(true);
-    item->hide();
 }
 
 void FriendGroupItem::mergeWithGroup(FriendGroupItem *group)
@@ -91,14 +90,15 @@ void FriendGroupItem::mergeWithGroup(FriendGroupItem *group)
     }
 }
 
-void FriendGroupItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+void FriendGroupItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+                            QWidget *widget)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
     BaseLocationItem::paint(painter, option, widget);
 
     QFont font = painter->font();
-    font.setPointSize(painter->font().pointSize() * 2);
+    font.setPointSize(painter->font().pointSize() * 2); // double default font size
     painter->setFont(font);
-    painter->drawText(QRect(-25, -25, 50, 50), Qt::AlignCenter, QString::number(m_friends.size()));
+    painter->drawText(boundingRect(), Qt::AlignCenter, QString::number(m_friends.count()));
 }
index 31a5646..d9f8f22 100644 (file)
@@ -33,6 +33,8 @@ class FriendLocationItem;
   * @brief Friend group map item
   *
   * Contains grouped FriendLocationItem items and draws group image with number of grouped friends
+  *
+  * @author Sami Rämö - sami.ramo@ixonos.com
   */
 class FriendGroupItem : public BaseLocationItem
 {
index 800bdaf..9b61023 100644 (file)
@@ -170,6 +170,7 @@ void FriendItemsHandler::cleanOldFriendData(const QList<User *> &friendsList)
 
         if (!friendFound) {
             m_mapScene->removeItem(*iter);
+            delete *iter;
             iter = m_friendItems.erase(iter);
         }
         else {
@@ -265,6 +266,7 @@ void FriendItemsHandler::updateFriendLocationsAndImages(const QList<User *> &fri
                 if ((*iter)->profileImageUrl()
                     != friendsList.at(i)->profileImageUrl()) {
                     (*iter)->setPixmap(friendsList.at(i)->profileImage());
+                    (*iter)->setProfileImageUrl(friendsList.at(i)->profileImageUrl());
                 }
             }
         }
index cbd8114..b72e637 100644 (file)
@@ -56,6 +56,11 @@ void FriendLocationItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
 void FriendLocationItem::setPartOfGroup(bool value)
 {
     m_partOfGroup = value;
+
+    if (value)
+        hide();
+    else
+        show();
 }
 
 QString FriendLocationItem::userId() const
index ffa08b6..aa7847f 100644 (file)
@@ -89,6 +89,7 @@ void TestFriendGroupItem::init()
     // create test group
     group = new FriendGroupItem(friend1);
     QVERIFY(group != 0);
+    QVERIFY(friend1->isPartOfGroup());
 }
 
 void TestFriendGroupItem::cleanup()
@@ -170,7 +171,7 @@ void TestFriendGroupItem::mergeWithGroup()
     FriendGroupItem anotherGroup(friend3);
     anotherGroup.joinFriend(friend4);
 
-    // move friens to first group
+    // move friends to first group
     anotherGroup.mergeWithGroup(group);
 
     // no-one should actually be dropped because groups should be empty already