67081c9df9b9d813d4a1b5da27f2455bb7928892
[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     /**
104     * @brief method that detects when friend icon is clicked
105     *
106     * @param event detects the mouse click (or touch in Maemo)
107     */
108      void mousePressEvent(QGraphicsSceneMouseEvent *event);
109
110  /*******************************************************************************
111  * SIGNALS
112  ******************************************************************************/
113 signals:
114
115    /**
116    * @brief signal is emitted when friends image is clicked on the map
117    *
118    * @param m_userId friends user identity
119    */
120    void friendItemClicked(QString m_userId);
121
122 /*******************************************************************************
123 * DATA MEMBERS
124 ******************************************************************************/
125 private:
126     bool m_partOfGroup; ///< Flag to mark if item is part of any group
127     const QString m_userId; ///< Friends user ID. Can't be changed afterwards
128     QUrl m_profileImageUrl; ///< Friends Facebook profile image URL
129 };
130
131 #endif // FRIENDLOCATIONITEM_H