Added mouse press and release methods to FriendGroupItem and
[situare] / src / map / friendlocationitem.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Ville Tiensuu - ville.tiensuu@ixonos.com
6        Sami Rämö - sami.ramo@ixonos.com
7
8    Situare is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License
10    version 2 as published by the Free Software Foundation.
11
12    Situare is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with Situare; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20    USA.
21 */
22
23 #ifndef FRIENDLOCATIONITEM_H
24 #define FRIENDLOCATIONITEM_H
25
26
27 #include <QObject>
28 #include <QUrl>
29
30 #include "baselocationitem.h"
31
32 /**
33 * @brief Class that shows friends location icons on the map
34 *
35 * @class FriendLocationItem friendlocationitem.h "map/friendlocationitem.h"
36 * @author Ville Tiensuu.
37 * @author Sami Rämö - sami.ramo@ixonos.com
38 */
39 class FriendLocationItem : public BaseLocationItem
40 {
41     Q_OBJECT
42
43 public:
44
45     /**
46     * @brief Constructor of FriendLocationItem
47     *
48     * Sets user ID
49     * Sets position to UNDEFINED.
50     * Sets default Z-value.
51     * Sets item to ignore transformations. this feature is needed to make icon on the map
52     * immune to scaling
53     *
54     * @param userId Used ID of the friend
55     * @param parent Parent
56     */
57     FriendLocationItem(const QString &userId, QObject *parent = 0);
58
59 /*******************************************************************************
60 * MEMBER FUNCTIONS AND SLOTS
61 ******************************************************************************/
62 public:
63     /**
64       * @brief Is item part of any group
65       *
66       * @return True if item is part of group, otherwise false.
67       */
68     bool isPartOfGroup() const;
69
70     /**
71     * @brief getter for friends profile image URL
72     *
73     * @return QUrl friends profile images URL
74     */
75     QUrl profileImageUrl() const;
76
77     /**
78     * @brief Set profile image and it's URL for friend
79     *
80     * Also offset is set matching new image dimensions.
81     *
82     * @param image New profile image
83     * @param url URL of the new profile image
84     */
85     void setProfileImage(const QPixmap image, const QUrl &url);
86
87     /**
88       * @brief Set value for m_partOfGroup flag
89       *
90       * @param value New value
91       */
92     void setPartOfGroup(bool value);
93
94     /**
95     * @brief getter for m_userId
96     *
97     * @return QString friends user identity
98     */
99     QString userId() const;
100
101 protected:
102     /**
103     * @brief method that detects when friend icon is clicked
104     *
105     * @param event detects the mouse click (or touch in Maemo)
106     */
107     void mousePressEvent(QGraphicsSceneMouseEvent *event);
108
109     /**
110     * @brief method that detects when friend icon press is released
111     *
112     * @param event detects the mouse release event (or touch in Maemo)
113     */
114     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
115
116  /*******************************************************************************
117   * SIGNALS
118   ******************************************************************************/
119  signals:
120      /**
121      * @brief Signal is emitted when l item is clicked.
122      *
123      * @param userIDs list of friends user IDs in the group
124      */
125      void locationItemClicked(const QList<QString> &userIDs);
126
127 /*******************************************************************************
128 * DATA MEMBERS
129 ******************************************************************************/
130 private:
131     bool m_partOfGroup; ///< Flag to mark if item is part of any group
132     const QString m_userId; ///< Friends user ID. Can't be changed afterwards
133     QUrl m_profileImageUrl; ///< Friends Facebook profile image URL
134     QPoint m_mousePressPosition; ///< Mouse press position
135 };
136
137 #endif // FRIENDLOCATIONITEM_H