backup
[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
10    Situare is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License
12    version 2 as published by the Free Software Foundation.
13
14    Situare is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with Situare; if not, write to the Free Software
21    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
22    USA.
23 */
24
25 #ifndef USERINFO_H
26 #define USERINFO_H
27
28 #include <QWidget>
29 #include "updatelocation/updatelocationdialog.h"
30
31 class ImageButton;
32
33 /**
34 * @brief UserInfo shows user's data in expandable item.
35 *
36 * @class UserInfo userinfo.h "ui/userinfo.h"
37 */
38 class UserInfo : public QWidget
39 {
40     Q_OBJECT
41 public:
42     /**
43     * @brief Constructor
44     *
45     * @param parent Parent
46     */
47     UserInfo(QWidget *parent=0);
48     ~UserInfo();
49
50 /*******************************************************************************
51 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
52 *******************************************************************************/
53 protected:
54     /**
55     * @brief Set current mouse position to mouse event position.
56     *
57     * @param event QMouseEvent mouse press event
58     */
59     void mousePressEvent(QMouseEvent *event);
60
61     /**
62     * @brief Call toggleHeight if mouse position is unchanged.
63     *
64     * Check if current mouse position is same as mouse release position.
65     * @param event QMouseEvent mouse release event
66     */
67     void mouseReleaseEvent(QMouseEvent *event);
68
69     /**
70     * @brief This function is called when the widget is drawn
71     *
72     * @param aPaintEvent Pointer to paint event
73     */
74     void paintEvent(QPaintEvent *aPaintEvent);
75
76 /******************************************************************************
77 * MEMBER FUNCTIONS AND SLOTS
78 ******************************************************************************/
79 public:
80     QString messageText() const;
81     /**
82     * @brief Sets the users current address
83     *
84     * @param address Reference to users current address
85     */
86     void setAddress(const QString &address);
87
88     /**
89     * @brief Sets the users current coordinates
90     *
91     * @param coordinates Reference to users current coordinates
92     */
93     void setCoordinates(const QPointF &coordinates);    
94
95     /**
96     * @brief Sets the user picture
97     *
98     * @param image Reference to user picture
99     */
100     void setProfileImage(const QPixmap &image);
101
102     /**
103     * @brief Sets the time of updated message
104     *
105     * @param time Reference to time when message was sent.
106     */
107     void setTime(const QString &time);
108
109    /**
110     * @brief Sets the user name
111     *
112     * @param name Reference to user name
113     */
114     void setUserName(const QString &name);
115
116 public slots:
117     void clearUpdateLocationDialogData();
118     /**
119     * @brief Sets the message text
120     *
121     * @param text Reference to user message
122     */
123     void setMessageText(const QString &text);
124     void backupUpdateLocationDialogData(const QString &status, const bool &publish);
125
126 private:
127     void restoreUnsendMessage();
128     /**
129     * @brief Set shortened or full-length text to labels.
130     *
131     * @param expanded true if full-length text is set, false otherwise
132     */
133     void setText(bool expanded);
134
135     /**
136     * @brief Set shortened texts from User data.
137     *
138     * Text length is defined by MAXIMUM_CHARS.
139     */
140     QString shortenText(const QLabel *label, const QString &text, int textMaxWidth);
141
142 private slots:
143     /**
144     * @brief Slot for find button click
145     */
146     void findButtonClicked();
147
148     /**
149     * @brief Slot function to forward messageUpdate launch signal
150     *
151     */
152     void messageUpdate();    
153
154 /******************************************************************************
155 * SIGNALS
156 ******************************************************************************/
157 signals:
158     /**
159     * @brief Signal for finding user.
160     *
161     * @param coordinates user geo coordinates
162     */
163     void findUser(const QPointF &coordinates);
164
165     /**
166     * @brief Signal for refreshing user data.
167     *
168     */
169     void refreshUserData();
170
171     /**
172     * @brief Signal for requesting reverseGeo from SituareEngine
173     *
174     */
175     void requestReverseGeo();
176
177     /**
178     * @brief Signals, when address data is ready
179     *
180     * @param address Street address
181     */
182     void reverseGeoReady(const QString &address);
183
184     /**
185     * @brief Signal for requestLocationUpdate from SituareEngine via MainWindow class
186     *
187     * @param status Status message
188     * @param publish Publish on Facebook
189     */
190     void statusUpdate(const QString &status, const bool &publish);
191     void messageUpdatedToSituare();
192     void messageSendingFailed(const QString &error);
193
194 /******************************************************************************
195 * DATA MEMBERS
196 ******************************************************************************/
197 private:
198     bool m_expanded;                    ///< Item expanded state
199     bool m_backupFacebookPublishPolicity; ///< Backup of publish on Facebook checkbox value
200     QLabel *m_locationLabel;            ///< Location label
201     QLabel *m_nameLabel;                ///< Name label
202     QLabel *m_statusTextLabel;          ///< Status text label
203     QLabel *m_updatedLabel;             ///< Updated label
204     QPixmap m_backgroundBottomImage;    ///< Bottom background image
205     QPixmap m_backgroundMiddleImage;    ///< Middle background image
206     QPixmap m_backgroundTopImage;       ///< Top background image
207     QPoint m_mousePosition;             ///< Current mouse press position
208     QPointF m_coordinates;              ///< User current coordinates
209     QString m_address;                  ///< Address from where the new message was sent
210     QString m_backupMessage;            ///< Backup of users message
211     QString m_messageText;              ///< User's message
212     QString m_time;                     ///< Time when the new message was sent
213     QString m_userName;                 ///< User's name
214     ImageButton *m_findButton;          ///< User find button
215     UpdateLocationDialog *m_messageDialog;  ///< Dialog for sending message and location
216 };
217
218 #endif // USERINFO_H