Fixed defects found in review
[situare] / src / map / friendgroupitem.h
1 /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Sami Rämö - sami.ramo@ixonos.com
6
7     Situare is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     version 2 as published by the Free Software Foundation.
10
11     Situare is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with Situare; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19     USA.
20 */
21
22
23 #ifndef FRIENDGROUPITEM_H
24 #define FRIENDGROUPITEM_H
25
26 #include <QList>
27
28 #include "baselocationitem.h"
29
30 class FriendLocationItem;
31
32 /**
33   * @brief Friend group map item
34   *
35   * Contains grouped FriendLocationItem items and draws group image with number of grouped friends
36   *
37   * @author Sami Rämö - sami.ramo@ixonos.com
38   */
39 class FriendGroupItem : public BaseLocationItem
40 {
41 public:
42     /**
43       * @brief Constructor
44       *
45       * Create new group, set picture and join first FriendLocationItem to the group.
46       * Group position is set to be exactly same as item given as parameter.
47       *
48       * @param item First FriendLocationItem to be joined to new group
49       */
50     FriendGroupItem(FriendLocationItem *item);
51
52 /*******************************************************************************
53  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
54  ******************************************************************************/
55     /**
56       * @brief Paint event
57       *
58       * Draw amount of joined FriendLocationItem items over the image.
59       */
60     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
61
62 /*******************************************************************************
63  * MEMBER FUNCTIONS AND SLOTS
64  ******************************************************************************/
65 public:
66     /**
67       * @brief Drop all FriendLocationItem items which bounding rect is not colliding with
68       * this group anymore
69       *
70       * Dropped items are set to visible again.
71       */
72     bool dropFriends(int zoomLevel);
73
74     /**
75       * @brief Join new FriendLocationItem to this group.
76       *
77       * Given item is also hidden.
78       *
79       * @param item FriendLocationItem to be joined
80       */
81     void joinFriend(FriendLocationItem *item);
82
83     /**
84       * @brief Merge this group to another FriendGroupItem
85       *
86       * Removes all FrienLocationItem items from this group and joins then to given group.
87       * Group item is not deleted, so caller must delete group after merging.
88       *
89       * @param group FriendGroupItem which takes all this group FriendLocationItem items
90       */
91     void mergeWithGroup(FriendGroupItem *group);
92
93 private:
94     /**
95       * @brief Drop single FriendLocationItem from this group
96       *
97       * @param item FriendLocationItem to be dropped
98       */
99     void dropFriend(FriendLocationItem *item);
100
101 private:
102     QList<FriendLocationItem *> m_friends; ///< List of joined FriendLocationItem items
103 };
104
105 #endif // FRIENDGROUPITEM_H