2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Sami Rämö - sami.ramo@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
26 #include <QGraphicsSceneMouseEvent>
29 #include "friendlocationitem.h"
30 #include "friendgroupitem.h"
31 #include "mapcommon.h"
34 FriendGroupItem::FriendGroupItem(FriendLocationItem *item)
37 qDebug() << __PRETTY_FUNCTION__;
39 setPixmap(QPixmap(":/res/images/friend_group.png"));
41 setOffset(-pixmap().width() / 2, -pixmap().height() / 2);
42 setZValue(FriendLocationItemZValue);
48 void FriendGroupItem::dropFriends()
50 qDebug() << __PRETTY_FUNCTION__;
52 foreach (FriendLocationItem *friendItem, m_friends) {
53 friendItem->setPartOfGroup(false);
59 void FriendGroupItem::joinFriend(FriendLocationItem *item)
61 qDebug() << __PRETTY_FUNCTION__;
63 m_friends.append(item);
64 item->setPartOfGroup(true);
67 void FriendGroupItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
70 qDebug() << __PRETTY_FUNCTION__;
74 icon.addPixmap(pixmap());
75 painter->drawPixmap(offset(), icon.pixmap(pixmap().size(), QIcon::Selected,
78 QGraphicsPixmapItem::paint(painter, option, widget);
81 painter->setPen(Qt::white);
82 painter->setFont(NOKIA_FONT_SMALL);
83 painter->drawText(QRect(GROUP_ITEM_FRIENDS_COUNT_X, GROUP_ITEM_FRIENDS_COUNT_Y,
84 GROUP_ITEM_FRIENDS_COUNT_WIDTH, GROUP_ITEM_FRIENDS_COUNT_HEIGHT),
85 Qt::AlignCenter, QString::number(m_friends.count()));
88 void FriendGroupItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
90 qDebug() << __PRETTY_FUNCTION__;
93 if ((event->pos() - m_mousePressPosition).manhattanLength() > PRESS_MANHATTAN_LENGTH) {
100 void FriendGroupItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
102 qDebug() << __PRETTY_FUNCTION__;
104 m_mousePressPosition = event->pos();
109 void FriendGroupItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
113 qDebug() << __PRETTY_FUNCTION__;
116 m_clickEvent = false;
117 QList<QString> userIDs;
119 foreach (FriendLocationItem *item, m_friends)
120 userIDs.append(item->userId());
122 emit locationItemClicked(userIDs);