2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
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
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.
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.
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,
31 #include "coordinates/geocoordinate.h"
32 #include "updatelocation/updatelocationdialog.h"
37 * @brief UserInfo shows user's data in expandable item.
39 class UserInfo : public QWidget
47 * @param parent Parent
49 UserInfo(QWidget *parent = 0);
53 * saves unsend user message to settings
58 /*******************************************************************************
59 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
60 *******************************************************************************/
63 * @brief Set current mouse position to mouse event position.
65 * @param event QMouseEvent mouse press event
67 void mousePressEvent(QMouseEvent *event);
70 * @brief Call toggleHeight if mouse position is unchanged.
72 * Check if current mouse position is same as mouse release position.
73 * @param event QMouseEvent mouse release event
75 void mouseReleaseEvent(QMouseEvent *event);
78 * @brief This function is called when the widget is drawn
80 * @param event Pointer to paint event
82 void paintEvent(QPaintEvent *event);
84 /******************************************************************************
85 * MEMBER FUNCTIONS AND SLOTS
86 ******************************************************************************/
89 * @brief Sets the users current address
91 * @param address Reference to users current address
93 void setAddress(const QString &address);
96 * @brief Sets the users current coordinates
98 * @param coordinates Reference to users current coordinates
100 void setCoordinates(const GeoCoordinate &coordinates);
103 * @brief Sets the user picture
105 * @param image Reference to user picture
107 void setProfileImage(const QPixmap &image);
110 * @brief Sets the time of updated message
112 * @param time Reference to time when message was sent.
114 void setTime(const QString &time);
117 * @brief Sets the user name
119 * @param name Reference to user name
121 void setUserName(const QString &name);
125 * @brief Saves status message and Facebook publish setting
127 * @param status message that user sends. Message is stored to m_backupMessage data member
128 * @param publish setting that determines whether the user status message is published on
129 * Facebook. This value is stored to m_backupFacebookPublishPolicity data member.
131 void backupUpdateLocationDialogData(const QString &status, bool publish);
134 * @brief Clears backups of message and publish on Facebook setting
136 void clearUpdateLocationDialogData();
139 * @brief Sets the message text
141 * @param text Reference to user message
143 void setMessageText(const QString &text);
147 * @brief reads Unsend message from settings at startup
149 void restoreUnsendMessage();
152 * @brief Set shortened or full-length text to labels.
154 * @param expanded true if full-length text is set, false otherwise
156 void setExpanded(bool expanded);
159 * @brief Elides long text
161 * @param label get the fontmetrics from the label
162 * @param text long text to be shortened
163 * @param textMaxWidth label width
164 * @returns shortened text
166 QString shortenText(const QLabel *label, const QString &text, int textMaxWidth);
169 * @brief Split too long words.
171 * Splits long word to several by adding extra spaces
173 * @param word long word to be splitted
174 * @returns splitted word
176 QString splitWord(const QString &word) const;
180 * @brief Slot for collapse user info
185 * @brief Slot for find button click
187 void findButtonClicked();
190 * @brief Slot function to forward messageUpdate launch signal
192 void messageUpdate();
195 * @brief Slot function to get indication when dialog is finished
197 void updateLocationDialogFinished(int reason);
199 /******************************************************************************
201 ******************************************************************************/
204 * @brief Signal for finding user.
206 * @param coordinates user geo coordinates
208 void findUser(const GeoCoordinate &coordinates);
211 * @brief Signal that used to inform user that his message/location update tp Situare server
213 * This signal is originally sended from UserInfo
214 * @param message message for notification
215 * @param modal true if modal notification otherwice false
217 void notificateUpdateFailing(const QString &message, bool modal);
220 * @brief Signal for requesting reverseGeo from SituareEngine
222 void requestReverseGeo();
225 * @brief Signals, when address data is ready
227 * @param address Street address
229 void reverseGeoReady(const QString &address);
232 * @brief Signal for requestLocationUpdate from SituareEngine via MainWindow class
234 * @param status Status message
235 * @param publish Publish on Facebook
237 void statusUpdate(const QString &status, const bool &publish);
239 /******************************************************************************
241 ******************************************************************************/
243 bool m_backupFacebookPublishPolicity; ///< Backup of publish on Facebook checkbox value
244 bool m_expanded; ///< Item expanded state
246 QLabel *m_locationLabel; ///< Location label
247 QLabel *m_nameLabel; ///< Name label
248 QLabel *m_statusTextLabel; ///< Status text label
249 QLabel *m_updatedLabel; ///< Updated label
251 QPixmap m_backgroundBottomImage; ///< Bottom background image
252 QPixmap m_backgroundMiddleImage; ///< Middle background image
253 QPixmap m_backgroundTopImage; ///< Top background image
255 QPoint m_mousePosition; ///< Current mouse press position
257 QString m_address; ///< Address from where the new message was sent
258 QString m_backupMessage; ///< Backup of users message
259 QString m_messageText; ///< User's message
260 QString m_time; ///< Time when the new message was sent
261 QString m_userName; ///< User's name
263 GeoCoordinate m_coordinates; ///< User current coordinates
264 ImageButton *m_avatar; ///< User find button
265 UpdateLocationDialog *m_updateLocation; ///< Update location dialog