96b83bfe2460f9ab214d042ffa42c78cedb423a3
[situare] / src / map / ownlocationitem.h
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
23 #ifndef OWNLOCATIONITEM_H
24 #define OWNLOCATIONITEM_H
25
26 #include <QGraphicsPixmapItem>
27
28 /**
29 * @brief Class that shows own location icon on the map
30 *
31 * @class OwnLocationItem ownlocationitem.h "map/ownlocationitem.h"
32 * @author Ville Tiensuu
33 */
34 class OwnLocationItem : public QGraphicsPixmapItem
35 {
36 public:
37     /**
38     * @brief Default constructor of OwnLocationItem.
39     *        Sets position to default location.
40     *        Loads and sets default pixmap that is show on the map.
41     *        Sets default Z-value to show icon on top of maps but under zoom buttons.
42     *        Sets offset so that achor of the picture is at the origin. this feature is
43     *        needed to center icon on the middle of the location.
44     *        Sets item to ignore transformations. this feature is needed to make icon on the map
45     *        immune to scaling
46     */
47     OwnLocationItem();
48
49     /**
50     * @brief Overloaded constructor for OwnLocationItem.
51     *        Otherwise same as default constructor, but position is set according to parameters.
52     *
53     * @param longitude Longitude coordinate of position.
54     * @param latitude Latitude coordinate of position.
55     */
56     OwnLocationItem(const qreal & longitude, const qreal & latitude);
57
58     /**
59     * @brief Overloaded constructor for OwnLocationItem.
60     *        Otherwise same as default constructor, but position is set according to parameter.
61     *
62     * @param ownPosition Position in QPoinF format
63     */
64     OwnLocationItem(const QPointF & ownPosition);
65
66     /*******************************************************************************
67     * MEMBER FUNCTIONS AND SLOTS
68     ******************************************************************************/
69     public:
70
71     /**
72     * @brief Hides OwnLocationItem so that it is invisible on the map
73     *
74     */
75     void hideOwnLocation();
76
77     /**
78     * @brief returns position of OwnLocationItem
79     *
80     * @return QPoint position of OwnLocationItem
81     */
82     QPoint position() const;
83
84     /**
85     * @brief sets position of OwnLocationItem as specified in parameter.
86     *        Position defines where icon is show on the map.
87     *
88     * @param newPosition Parameter that specifies new position.
89     */
90     void setPosition(const QPointF & newPosition);
91
92     /**
93     * @brief Sets OwnLocationItem to be visible on the map.
94     *        OwnLocationImte is visible by default, function is needed only when own location
95     *        needs to be set back visible after hideOwnLocation function call.
96     */
97     void showOwnLocation();
98 };
99
100 #endif // OWNLOCATIONITEM_H