Updated tests cases matching the new tabs
[situare] / src / map / gpslocationitem.h
1 /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Sami Rämö - sami.ramo@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 #ifndef GPSLOCATIONITEM_H
23 #define GPSLOCATIONITEM_H
24
25 #include <QGraphicsItem>
26
27 /**
28   * @brief Class for indicating current position and accuracy accuired from GPS on the map.
29   *
30   * Actual position spot image is a child item of this class and this class handles drawing the
31   * accuracy ring. GPS fix accuracy is indicated by the radius of the circle around the position
32   * item.
33   */
34 class GPSLocationItem : public QGraphicsItem
35 {
36 public:
37     /**
38       * @brief Constructor
39       */
40     GPSLocationItem();
41
42 /*******************************************************************************
43  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
44  ******************************************************************************/
45 public:
46     /**
47     * @brief Implements the bounding rect
48     *
49     * @returns Bounding rect of the item
50     */
51     QRectF boundingRect() const;
52
53     /**
54     * @brief Implements the painter
55     */
56     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
57
58 /*******************************************************************************
59  * MEMBER FUNCTIONS AND SLOTS
60  ******************************************************************************/
61 public:
62     /**
63       * @brief Enable / disable item
64       *
65       * Actual enabling is done when next position update is received, so the old value before
66       * hiding the item is not used.
67       *
68       * @param enable True if item should be enabled, otherwise false
69       */
70     void setEnabled(bool enable);
71
72     /**
73       * @brief Update position item
74       *
75       * @param scenePosition Scene position
76       * @param accuracy Accuracy of the GPS fix
77       * @param sceneResolution Scene horizontal resolution at given coordinate latitude level
78       */
79     void updateItem(QPointF scenePosition, qreal accuracy, qreal sceneResolution);
80
81 private:
82     /**
83     * @brief Set new radius for the accuracy ring
84     *
85     * Calls setBoundingRect() if the radius changes
86     *
87     * @param accuracy Accuracy (in meters)
88     * @param sceneResolution Scene resolution (meters/pixel)
89     */
90     void setAccuracyRingRadius(qreal accuracy, qreal sceneResolution);
91
92     /**
93     * @brief Sets new bounding rect for this item based on the accuracy ring radius
94     *
95     * @param radius Radius of the accuracy ring
96     */
97     void setBoundingRect(qreal radius);
98
99 /*******************************************************************************
100  * DATA MEMBERS
101  ******************************************************************************/
102 private:
103     bool m_showOnNextUpdate;    ///< should the item be shown when next update arrives
104
105     qreal m_radius;             ///< accuracy ring radius in scene pixels
106
107     QGraphicsPixmapItem *m_pixmapItem;  ///< red led item
108
109     QRectF m_boundingRect;              ///< item's bounding rect
110 };
111
112 #endif // GPSLOCATIONITEM_H