31a56461f20460b4aaf69b3be5973888b8d0b443
[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 class FriendGroupItem : public BaseLocationItem
38 {
39 public:
40     /**
41       * @brief Constructor
42       *
43       * Create new group, set picture and join first FriendLocationItem to the group.
44       * Group position is set to be exactly same as item given as parameter.
45       *
46       * @param item First FriendLocationItem to be joined to new group
47       */
48     FriendGroupItem(FriendLocationItem *item);
49
50 /*******************************************************************************
51  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
52  ******************************************************************************/
53     /**
54       * @brief Paint event
55       *
56       * Draw amount of joined FriendLocationItem items over the image.
57       */
58     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
59
60 /*******************************************************************************
61  * MEMBER FUNCTIONS AND SLOTS
62  ******************************************************************************/
63 public:
64     /**
65       * @brief Drop all FriendLocationItem items which bounding rect is not colliding with
66       * this group anymore
67       *
68       * Dropped items are set to visible again.
69       */
70     bool dropFriends(int zoomLevel);
71
72     /**
73       * @brief Join new FriendLocationItem to this group.
74       *
75       * Given item is also hidden.
76       *
77       * @param item FriendLocationItem to be joined
78       */
79     void joinFriend(FriendLocationItem *item);
80
81     /**
82       * @brief Merge this group to another FriendGroupItem
83       *
84       * Removes all FrienLocationItem items from this group and joins then to given group.
85       * Group item is not deleted, so caller must delete group after merging.
86       *
87       * @param group FriendGroupItem which takes all this group FriendLocationItem items
88       */
89     void mergeWithGroup(FriendGroupItem *group);
90
91 private:
92     /**
93       * @brief Drop single FriendLocationItem from this group
94       *
95       * @param item FriendLocationItem to be dropped
96       */
97     void dropFriend(FriendLocationItem *item);
98
99 private:
100     QList<FriendLocationItem *> m_friends; ///< List of joined FriendLocationItem items
101 };
102
103 #endif // FRIENDGROUPITEM_H