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,
22 const int ACCURATE_LIMIT = 250; // this and lower values (in meters) are considered as accurate
25 #include <QGraphicsPixmapItem>
27 #include "../gps/gpscommon.h"
28 #include "mapcommon.h"
30 #include "gpslocationitem.h"
32 GPSLocationItem::GPSLocationItem()
33 : m_currentAccuracy(NOT_SET)
35 qDebug() << __PRETTY_FUNCTION__;
36 m_accuratePixmap = QPixmap(":/res/images/gps_pos_accurate.png");
37 m_coarsePixmap = QPixmap(":/res/images/gps_pos_coarse.png");
39 setPos(QPoint(UNDEFINED, UNDEFINED));
40 setZValue(OWN_LOCATION_ICON_Z_LEVEL);
41 setOffset(-m_accuratePixmap.width() / 2, -m_accuratePixmap.height() / 2);
42 setFlag(QGraphicsItem::ItemIgnoresTransformations);
45 void GPSLocationItem::updatePosition(QPoint scenePosition, qreal accuracy)
47 qDebug() << __PRETTY_FUNCTION__;
49 setPos(scenePosition);
51 if (accuracy != GPS_ACCURACY_UNDEFINED // accuracy must be defined
52 && accuracy <= ACCURATE_LIMIT // and smaller than limit
53 && m_currentAccuracy != ACCURATE) { // and accurate pixmap not yet set
54 setPixmap(m_accuratePixmap);
55 m_currentAccuracy = ACCURATE;
57 else if (m_currentAccuracy != COARSE) { // coarse pixmap not yet set
58 setPixmap(m_coarsePixmap);
59 m_currentAccuracy = COARSE;