Fixed bug #5688 New friends are not shown on the map
[situare] / src / map / friendlocationitem.cpp
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 #include <QDebug>
24 #include "friendlocationitem.h"
25 #include "mapcommon.h"
26
27 FriendLocationItem::FriendLocationItem(const QPixmap &icon,
28                                        QObject *parent)
29     : BaseLocationItem(parent),
30       m_partOfGroup(false)
31 {
32     qDebug() << __PRETTY_FUNCTION__;
33
34     setPixmap(icon);
35     setPos(UNDEFINED, UNDEFINED);
36     setZValue(FRIEND_LOCATION_ICON_Z_LEVEL);
37     setOffset(-icon.width()/2, -icon.height()/2);
38 }
39
40 bool FriendLocationItem::isPartOfGroup() const
41 {
42     return m_partOfGroup;
43 }
44
45 void FriendLocationItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
46 {
47     qDebug() << __PRETTY_FUNCTION__;
48     Q_UNUSED(event);
49     qDebug() << "Friends user ID is " << m_userId.toAscii();
50     emit iconClicked(m_userId);
51 }
52
53 void FriendLocationItem::setPartOfGroup(bool value)
54 {
55     m_partOfGroup = value;
56
57     if (value)
58         hide();
59     else
60         show();
61 }
62
63 QString FriendLocationItem::userId() const
64 {
65     qDebug() << __PRETTY_FUNCTION__;
66     return m_userId;
67 }
68
69 void FriendLocationItem::setUserId(const QString &userId)
70 {
71     qDebug() << __PRETTY_FUNCTION__;
72     m_userId = userId;
73 }
74
75 void FriendLocationItem::setProfileImageUrl(const QUrl &url)
76 {
77     qDebug() << __PRETTY_FUNCTION__;
78     m_profileImageUrl = url;
79 }
80
81 QUrl FriendLocationItem::profileImageUrl() const
82 {
83     qDebug() << __PRETTY_FUNCTION__;
84     return m_profileImageUrl;
85 }
86