added base class for own and friend locations. added new class for
[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
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.
10
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.
15
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,
19    USA.
20 */
21
22 #include <QDebug>
23 #include "friendlocationitem.h"
24 #include "mapengine.h"
25 #include "mapcommon.h"
26
27
28 FriendLocationItem::FriendLocationItem(const QPixmap &icon,
29                                        const QPointF &friendsLocation,
30                                        QObject *parent)
31 {
32     qDebug() << __PRETTY_FUNCTION__;
33
34     setPixmap(icon);
35     setPosition(QPointF( friendsLocation.x(), friendsLocation.y() ));
36     setZValue(FRIEND_LOCATION_ICON_Z_LEVEL);
37     setOffset(-icon.width()/2, -icon.height()/2);
38     setFlag(QGraphicsItem::ItemIgnoresTransformations);
39 }
40
41 void FriendLocationItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
42 {
43     qDebug() << __PRETTY_FUNCTION__;
44     Q_UNUSED(event);
45     qDebug() << "Friends Location is " << position().x() << "  " << position().y();
46     qDebug() << "Name of the friend is " << m_name->toAscii();
47     emit iconClicked(*m_name);
48 }
49
50 void FriendLocationItem::setIcon(const QPixmap &icon)
51 {
52     setPixmap(icon);
53 }
54
55 void FriendLocationItem::setName(const QString &name)
56 {
57     m_name = new QString(name);
58 }