2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Ville Tiensuu - ville.tiensuu@ixonos.com
6 Sami Rämö - sami.ramo@ixonos.com
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.
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.
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,
24 #include <QGraphicsSceneMouseEvent>
26 #include "friendlocationitem.h"
27 #include "mapcommon.h"
29 FriendLocationItem::FriendLocationItem(const QString &userId,
31 : BaseLocationItem(parent),
34 m_mousePressPosition(QPoint(0, 0)),
37 qDebug() << __PRETTY_FUNCTION__;
39 setPos(UNDEFINED, UNDEFINED);
40 setZValue(FRIEND_LOCATION_ICON_Z_LEVEL);
43 bool FriendLocationItem::isPartOfGroup() const
45 qDebug() << __PRETTY_FUNCTION__;
50 void FriendLocationItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
52 qDebug() << __PRETTY_FUNCTION__;
54 m_mousePressPosition = event->pos();
59 void FriendLocationItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
61 qDebug() << __PRETTY_FUNCTION__;
64 if ((event->pos() - m_mousePressPosition).manhattanLength() > PRESS_MANHATTAN_LENGTH) {
71 void FriendLocationItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
73 qDebug() << __PRETTY_FUNCTION__;
79 QList<QString> userIDs;
80 userIDs.append(m_userId);
82 emit locationItemClicked(userIDs);
88 void FriendLocationItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
91 qDebug() << __PRETTY_FUNCTION__;
95 icon.addPixmap(pixmap());
96 painter->drawPixmap(offset(), icon.pixmap(pixmap().size(), QIcon::Selected,
99 BaseLocationItem::paint(painter, option, widget);
103 void FriendLocationItem::setPartOfGroup(bool value)
105 qDebug() << __PRETTY_FUNCTION__;
107 m_partOfGroup = value;
115 QString FriendLocationItem::userId() const
117 qDebug() << __PRETTY_FUNCTION__;
122 void FriendLocationItem::setProfileImage(const QPixmap image, const QUrl &url)
124 qDebug() << __PRETTY_FUNCTION__;
127 setOffset(-image.width()/2, -image.height()/2);
128 m_profileImageUrl = url;
131 QUrl FriendLocationItem::profileImageUrl() const
133 qDebug() << __PRETTY_FUNCTION__;
135 return m_profileImageUrl;