Fixed bug #5688 New friends are not shown on the map
[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     *        Sets position to UNDEFINED.
48     *        Loads and sets default pixmap that is show on the map.
49     *        Sets default Z-value.
50     *        Sets offset so that achor of the picture is at the origin. this feature is
51     *        needed to center icon on the middle of the location.
52     *        Sets item to ignore transformations. this feature is needed to make icon on the map
53     *        immune to scaling
54     *
55     * @param icon Friends Facebook profile picture
56     * @param parent Parent
57     */
58     FriendLocationItem(const QPixmap &icon, QObject *parent = 0);
59
60 /*******************************************************************************
61 * MEMBER FUNCTIONS AND SLOTS
62 ******************************************************************************/
63 public:
64     /**
65       * @brief Is item part of any group
66       *
67       * @return True if item is part of group, otherwise false.
68       */
69     bool isPartOfGroup() const;
70
71     /**
72     * @brief getter for friends profile image URL
73     *
74     * @return QUrl friends profile images URL
75     */
76     QUrl profileImageUrl() const;
77
78     /**
79     * @brief sets profile image URL for friend
80     *
81     * @param url frieds profile image URL
82     */
83     void setProfileImageUrl(const QUrl &url);
84
85     /**
86       * @brief Set value for m_partOfGroup flag
87       *
88       * @param value New value
89       */
90     void setPartOfGroup(bool value);
91
92     /**
93     * @brief sets name for friend.
94     *
95     * @param userId friends user identity
96     */
97     void setUserId(const QString &userId);
98
99     /**
100     * @brief getter for m_userId
101     *
102     * @return QString friends user identity
103     */
104     QString userId() const;
105
106 protected:
107
108     /**
109     * @brief method that detects when friend icon is clicked
110     *
111     * @param event detects the mouse click (or touch in Maemo)
112     */
113      void mousePressEvent(QGraphicsSceneMouseEvent *event);
114
115  /*******************************************************************************
116  * SIGNALS
117  ******************************************************************************/
118 signals:
119
120    /**
121    * @brief signal is emitted when friends icon is clicked on the map
122    *
123    * @param m_userId friends user identity
124    */
125    void iconClicked(QString m_userId);
126
127 /*******************************************************************************
128 * DATA MEMBERS
129 ******************************************************************************/
130 private:
131     bool m_partOfGroup; ///< Flag to mark if item is part of any group
132     QString m_userId; ///< Friends user ID
133     QUrl m_profileImageUrl; ///< Friends Facebook profile image URL
134 };
135
136 #endif // FRIENDLOCATIONITEM_H