backup before changing update dialog to be a data member of UserInfo
[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
49 /*******************************************************************************
50 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
51 *******************************************************************************/
52 protected:
53     /**
54     * @brief Set current mouse position to mouse event position.
55     *
56     * @param event QMouseEvent mouse press event
57     */
58     void mousePressEvent(QMouseEvent *event);
59
60     /**
61     * @brief Call toggleHeight if mouse position is unchanged.
62     *
63     * Check if current mouse position is same as mouse release position.
64     * @param event QMouseEvent mouse release event
65     */
66     void mouseReleaseEvent(QMouseEvent *event);
67
68     /**
69     * @brief This function is called when the widget is drawn
70     *
71     * @param aPaintEvent Pointer to paint event
72     */
73     void paintEvent(QPaintEvent *aPaintEvent);
74
75 /******************************************************************************
76 * MEMBER FUNCTIONS AND SLOTS
77 ******************************************************************************/
78 public:
79     QString messageText() const;
80     /**
81     * @brief Sets the users current address
82     *
83     * @param address Reference to users current address
84     */
85     void setAddress(const QString &address);
86
87     /**
88     * @brief Sets the users current coordinates
89     *
90     * @param coordinates Reference to users current coordinates
91     */
92     void setCoordinates(const QPointF &coordinates);    
93
94     /**
95     * @brief Sets the user picture
96     *
97     * @param image Reference to user picture
98     */
99     void setProfileImage(const QPixmap &image);
100
101     /**
102     * @brief Sets the time of updated message
103     *
104     * @param time Reference to time when message was sent.
105     */
106     void setTime(const QString &time);
107
108    /**
109     * @brief Sets the user name
110     *
111     * @param name Reference to user name
112     */
113     void setUserName(const QString &name);
114
115 public slots:
116     void deleteUserData();
117     /**
118     * @brief Sets the message text
119     *
120     * @param text Reference to user message
121     */
122     void setMessageText(const QString &text);
123     void updateUserData(const QString &status, const bool &publish);
124
125 private:
126     /**
127     * @brief Set shortened or full-length text to labels.
128     *
129     * @param expanded true if full-length text is set, false otherwise
130     */
131     void setText(bool expanded);
132
133     /**
134     * @brief Set shortened texts from User data.
135     *
136     * Text length is defined by MAXIMUM_CHARS.
137     */
138     QString shortenText(const QLabel *label, const QString &text, int textMaxWidth);
139
140 private slots:
141     /**
142     * @brief Slot for find button click
143     */
144     void findButtonClicked();
145
146     /**
147     * @brief Slot function to forward messageUpdate launch signal
148     *
149     */
150     void messageUpdate();    
151
152 /******************************************************************************
153 * SIGNALS
154 ******************************************************************************/
155 signals:
156     /**
157     * @brief Signal for finding user.
158     *
159     * @param coordinates user geo coordinates
160     */
161     void findUser(const QPointF &coordinates);
162
163     /**
164     * @brief Signal for refreshing user data.
165     *
166     */
167     void refreshUserData();
168
169     /**
170     * @brief Signal for requesting reverseGeo from SituareEngine
171     *
172     */
173     void requestReverseGeo();
174
175     /**
176     * @brief Signals, when address data is ready
177     *
178     * @param address Street address
179     */
180     void reverseGeoReady(const QString &address);
181
182     /**
183     * @brief Signal for requestLocationUpdate from SituareEngine via MainWindow class
184     *
185     * @param status Status message
186     * @param publish Publish on Facebook
187     */
188     void statusUpdate(const QString &status, const bool &publish);
189     void messageUpdatedToSituare();
190     void messageSendingFailed(const QString &error);
191
192 /******************************************************************************
193 * DATA MEMBERS
194 ******************************************************************************/
195 private:
196     bool m_expanded;                    ///< Item expanded state
197     QLabel *m_locationLabel;            ///< Location label
198     QLabel *m_nameLabel;                ///< Name label
199     QLabel *m_statusTextLabel;          ///< Status text label
200     QLabel *m_updatedLabel;             ///< Updated label
201     QPixmap m_backgroundBottomImage;    ///< Bottom background image
202     QPixmap m_backgroundMiddleImage;    ///< Middle background image
203     QPixmap m_backgroundTopImage;       ///< Top background image
204     QPoint m_mousePosition;             ///< Current mouse press position
205     QPointF m_coordinates;              ///< User current coordinates
206     QString m_address;                  ///< Address from where the new message was sent.
207     QString m_messageText;              ///< User's message
208     QString m_time;                     ///< Time when the new message was sent
209     QString m_userName;                 ///< User's name
210     ImageButton *m_findButton;          ///< User find button
211 };
212
213 #endif // USERINFO_H