Updated tests cases matching the new tabs
[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     Q_OBJECT
42
43 public:
44     /**
45       * @brief Constructor
46       *
47       * Create new group, set picture and join first FriendLocationItem to the group.
48       * Group position is set to be exactly same as item given as parameter.
49       *
50       * @param item First FriendLocationItem to be joined to new group
51       */
52     FriendGroupItem(FriendLocationItem *item);
53
54 /*******************************************************************************
55  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
56  ******************************************************************************/
57 public:
58     /**
59       * @brief Paint event
60       *
61       * Draw amount of joined FriendLocationItem items over the image.
62       */
63     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
64
65 protected:
66     /**
67     * @brief Mouse move event.
68     *
69     * Disables m_clickEvent flag if press and release where not
70     * in same area.
71     *
72     * @param event QGraphicsSceneMouseEvent.
73     */
74     void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
75
76     /**
77     * @brief Mouse press event.
78     *
79     * Sets mouse press position.
80     *
81     * @param event QGraphicsSceneMouseEvent.
82     */
83     void mousePressEvent(QGraphicsSceneMouseEvent *event);
84
85     /**
86     * @brief Mouse release event.
87     *
88     * Emits friendGroupItemClicked signal if press and release where
89     * in same area.
90     *
91     * @param event QGraphicsSceneMouseEvent.
92     */
93     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
94
95 /*******************************************************************************
96  * MEMBER FUNCTIONS AND SLOTS
97  ******************************************************************************/
98 public:
99     /**
100       * @brief Drop all FriendLocationItem items from the group
101       *
102       * Dropped items are set to visible again.
103       */
104     void dropFriends();
105
106     /**
107       * @brief Join new FriendLocationItem to this group.
108       *
109       * Given item is also hidden.
110       *
111       * @param item FriendLocationItem to be joined
112       */
113     void joinFriend(FriendLocationItem *item);
114
115 /*******************************************************************************
116  * SIGNALS
117  ******************************************************************************/
118 signals:
119     /**
120     * @brief Signal is emitted when l item is clicked.
121     *
122     * @param userIDs list of friends user IDs in the group
123     */
124     void locationItemClicked(const QList<QString> &userIDs);
125
126 /*******************************************************************************
127  * DATA MEMBERS
128  ******************************************************************************/
129 private:
130     QList<FriendLocationItem *> m_friends;  ///< List of joined FriendLocationItem items
131     QPointF m_mousePressPosition;           ///< Mouse press position
132     bool m_clickEvent;                      ///< Mouse click event flag
133 };
134
135 #endif // FRIENDGROUPITEM_H