Moved UpdateLocationDialog to be managed by MainWindow.
[situare] / src / ui / userinfo.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Jukka Saastamoinen - jukka.saastamoinen@ixonos.com
6        Jussi Laitinen - jussi.laitinen@ixonos.com
7        Katri Kaikkonen - katri.kaikkonen@ixonos.com
8        Henri Lampela - henri.lampela@ixonos.com
9        Ville Tiensuu - ville.tiensuu@ixonos.com
10
11    Situare is free software; you can redistribute it and/or
12    modify it under the terms of the GNU General Public License
13    version 2 as published by the Free Software Foundation.
14
15    Situare is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with Situare; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
23    USA.
24 */
25
26 #ifndef USERINFO_H
27 #define USERINFO_H
28
29 #include <QWidget>
30
31 #include "coordinates/geocoordinate.h"
32
33 class QLabel;
34
35 class ImageButton;
36
37 /**
38  * @brief UserInfo shows user's data in expandable item.
39  */
40 class UserInfo : public QWidget
41 {
42     Q_OBJECT
43
44 public:
45     /**
46      * @brief Constructor
47      *
48      * @param parent Parent
49      */
50     UserInfo(QWidget *parent = 0);
51
52     /**
53      * @brief Desctructor
54      * saves unsend user message to settings
55      *
56      */
57     ~UserInfo();
58
59 /*******************************************************************************
60 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
61 *******************************************************************************/
62 protected:
63     /**
64      * @brief Set current mouse position to mouse event position.
65      *
66      * @param event QMouseEvent mouse press event
67      */
68     void mousePressEvent(QMouseEvent *event);
69
70     /**
71      * @brief Call toggleHeight if mouse position is unchanged.
72      *
73      * Check if current mouse position is same as mouse release position.
74      * @param event QMouseEvent mouse release event
75      */
76     void mouseReleaseEvent(QMouseEvent *event);
77
78     /**
79      * @brief This function is called when the widget is drawn
80      *
81      * @param event Pointer to paint event
82      */
83     void paintEvent(QPaintEvent *event);
84
85 /******************************************************************************
86 * MEMBER FUNCTIONS AND SLOTS
87 ******************************************************************************/
88 public:
89     /**
90      * @brief Sets the users current address
91      *
92      * @param address Reference to users current address
93      */
94     void setAddress(const QString &address);
95
96     /**
97      * @brief Sets the users current coordinates
98      *
99      * @param coordinates Reference to users current coordinates
100      */
101     void setCoordinates(const GeoCoordinate &coordinates);
102
103     /**
104      * @brief Sets the user picture
105      *
106      * @param image Reference to user picture
107      */
108     void setProfileImage(const QPixmap &image);
109
110     /**
111      * @brief Sets the time of updated message
112      *
113      * @param time Reference to time when message was sent.
114      */
115     void setTime(const QString &time);
116
117     /**
118      * @brief Sets the user name
119      *
120      * @param name Reference to user name
121      */
122     void setUserName(const QString &name);
123
124 public slots:
125     /**
126      * @brief Sets the message text
127      *
128      * @param text Reference to user message
129      */
130     void setMessageText(const QString &text);
131
132 private:
133     /**
134      * @brief Set shortened or full-length text to labels.
135      *
136      * @param expanded true if full-length text is set, false otherwise
137      */
138     void setExpanded(bool expanded);
139
140 private slots:
141     /**
142      * @brief Slot for collapse user info
143      */
144     void collapse();
145
146     /**
147      * @brief Slot for find button click
148      */
149     void findButtonClicked();
150
151 /******************************************************************************
152 * SIGNALS
153 ******************************************************************************/
154 signals:
155     /**
156      * @brief Signal for finding user.
157      *
158      * @param coordinates user geo coordinates
159      */
160     void findUser(const GeoCoordinate &coordinates);
161
162 /******************************************************************************
163 * DATA MEMBERS
164 ******************************************************************************/
165 private:
166     bool m_expanded;                        ///< Item expanded state
167
168     QLabel *m_locationLabel;                ///< Location label
169     QLabel *m_nameLabel;                    ///< Name label
170     QLabel *m_statusTextLabel;              ///< Status text label
171     QLabel *m_updatedLabel;                 ///< Updated label
172
173     QPixmap m_backgroundBottomImage;        ///< Bottom background image
174     QPixmap m_backgroundMiddleImage;        ///< Middle background image
175     QPixmap m_backgroundTopImage;           ///< Top background image
176
177     QPoint m_mousePosition;                 ///< Current mouse press position
178
179     QString m_messageText;                  ///< User's message
180     QString m_userName;                     ///< User's name
181
182     GeoCoordinate m_coordinates;            ///< User current coordinates
183     ImageButton *m_avatar;                  ///< User find button
184 };
185
186 #endif // USERINFO_H