Minor changes to userinfo. Remove word wrap from name label and rename button
[situare] / src / ui / userinfo.h
index 17f1181..14be1cf 100644 (file)
 #define USERINFO_H
 
 #include <QWidget>
+
+#include "coordinates/geocoordinate.h"
 #include "updatelocation/updatelocationdialog.h"
 
 class ImageButton;
 
 /**
-* @brief UserInfo shows user's data in expandable item.
-*
-* @class UserInfo userinfo.h "ui/userinfo.h"
-*/
+ * @brief UserInfo shows user's data in expandable item.
+ */
 class UserInfo : public QWidget
 {
     Q_OBJECT
+
 public:
     /**
-    * @brief Constructor
-    *
-    * @param parent Parent
-    */
-    UserInfo(QWidget *parent=0);
+     * @brief Constructor
+     *
+     * @param parent Parent
+     */
+    UserInfo(QWidget *parent = 0);
 
     /**
-    * @brief Desctructor
-    * saves unsend user message to settings
-    *
-    */
+     * @brief Desctructor
+     * saves unsend user message to settings
+     *
+     */
     ~UserInfo();
 
 /*******************************************************************************
@@ -59,136 +60,140 @@ public:
 *******************************************************************************/
 protected:
     /**
-    * @brief Set current mouse position to mouse event position.
-    *
-    * @param event QMouseEvent mouse press event
-    */
+     * @brief Set current mouse position to mouse event position.
+     *
+     * @param event QMouseEvent mouse press event
+     */
     void mousePressEvent(QMouseEvent *event);
 
     /**
-    * @brief Call toggleHeight if mouse position is unchanged.
-    *
-    * Check if current mouse position is same as mouse release position.
-    * @param event QMouseEvent mouse release event
-    */
+     * @brief Call toggleHeight if mouse position is unchanged.
+     *
+     * Check if current mouse position is same as mouse release position.
+     * @param event QMouseEvent mouse release event
+     */
     void mouseReleaseEvent(QMouseEvent *event);
 
     /**
-    * @brief This function is called when the widget is drawn
-    *
-    * @param aPaintEvent Pointer to paint event
-    */
-    void paintEvent(QPaintEvent *aPaintEvent);
+     * @brief This function is called when the widget is drawn
+     *
+     * @param event Pointer to paint event
+     */
+    void paintEvent(QPaintEvent *event);
 
 /******************************************************************************
 * MEMBER FUNCTIONS AND SLOTS
 ******************************************************************************/
 public:
     /**
-    * @brief Sets the users current address
-    *
-    * @param address Reference to users current address
-    */
+     * @brief Sets the users current address
+     *
+     * @param address Reference to users current address
+     */
     void setAddress(const QString &address);
 
     /**
-    * @brief Sets the users current coordinates
-    *
-    * @param coordinates Reference to users current coordinates
-    */
-    void setCoordinates(const QPointF &coordinates);    
+     * @brief Sets the users current coordinates
+     *
+     * @param coordinates Reference to users current coordinates
+     */
+    void setCoordinates(const GeoCoordinate &coordinates);
 
     /**
-    * @brief Sets the user picture
-    *
-    * @param image Reference to user picture
-    */
+     * @brief Sets the user picture
+     *
+     * @param image Reference to user picture
+     */
     void setProfileImage(const QPixmap &image);
 
     /**
-    * @brief Sets the time of updated message
-    *
-    * @param time Reference to time when message was sent.
-    */
+     * @brief Sets the time of updated message
+     *
+     * @param time Reference to time when message was sent.
+     */
     void setTime(const QString &time);
 
-   /**
-    * @brief Sets the user name
-    *
-    * @param name Reference to user name
-    */
+    /**
+     * @brief Sets the user name
+     *
+     * @param name Reference to user name
+     */
     void setUserName(const QString &name);
 
 public slots:
-
     /**
-    * @brief Clears backups of message and publish on Facebook setting
-    */
-    void clearUpdateLocationDialogData();
-
-    /**
-    * @brief Saves status message and Facebook publish setting
-    *
-    * @param status message that user sends. Message is stored to m_backupMessage data member
-    * @param publish setting that determines whether the user status message is published on
-    *        Facebook. This value is stored to m_backupFacebookPublishPolicity data member.
-    */
+     * @brief Saves status message and Facebook publish setting
+     *
+     * @param status message that user sends. Message is stored to m_backupMessage data member
+     * @param publish setting that determines whether the user status message is published on
+     *        Facebook. This value is stored to m_backupFacebookPublishPolicity data member.
+     */
     void backupUpdateLocationDialogData(const QString &status, bool publish);
 
     /**
-    * @brief Sets the message text
-    *
-    * @param text Reference to user message
-    */
-    void setMessageText(const QString &text);
-
+     * @brief Clears backups of message and publish on Facebook setting
+     */
+    void clearUpdateLocationDialogData();
 
     /**
-    * @brief Emits signal to inform user about failed message/location update.
-    *        Contains logic to send signal only after failed message/location update.
-    *
-    * @param errorMessage from Situare server. Message is not used in this function
-    */
-    void verifyMessageUpdateFailure(const QString &errorMessage);
+     * @brief Sets the message text
+     *
+     * @param text Reference to user message
+     */
+    void setMessageText(const QString &text);
 
 private:
-
     /**
-    * @brief reads Unsend message from settings at startup
-    *
-    */
+     * @brief reads Unsend message from settings at startup
+     */
     void restoreUnsendMessage();
 
     /**
-    * @brief Set shortened or full-length text to labels.
-    *
-    * @param expanded true if full-length text is set, false otherwise
-    */
-    void setText(bool expanded);
+     * @brief Set shortened or full-length text to labels.
+     *
+     * @param expanded true if full-length text is set, false otherwise
+     */
+    void setExpanded(bool expanded);
 
     /**
-    * @brief Set shortened texts from User data.
-    *
-    * Text length is defined by MAXIMUM_CHARS.
-    */
+     * @brief Elides long text
+     *
+     * @param label get the fontmetrics from the label
+     * @param text long text to be shortened
+     * @param textMaxWidth label width
+     * @returns shortened text
+     */
     QString shortenText(const QLabel *label, const QString &text, int textMaxWidth);
 
+    /**
+     * @brief Split too long words.
+     *
+     * Splits long word to several by adding extra spaces
+     *
+     * @param word long word to be splitted
+     * @returns splitted word
+     */
+    QString splitWord(const QString &word) const;
+
 private slots:
     /**
-    * @brief Slot for find button click
-    */
+     * @brief Slot for collapse user info
+     */
+    void collapse();
+
+    /**
+     * @brief Slot for find button click
+     */
     void findButtonClicked();
 
     /**
-    * @brief Slot function to forward messageUpdate launch signal
-    *
-    */
-    void messageUpdate();    
+     * @brief Slot function to forward messageUpdate launch signal
+     */
+    void messageUpdate();
 
     /**
-    * @brief Slot function to get indication when dialog is finished
-    *
-    */
+     * @brief Slot function to get indication when dialog is finished
+     */
     void updateLocationDialogFinished(int reason);
 
 /******************************************************************************
@@ -196,74 +201,72 @@ private slots:
 ******************************************************************************/
 signals:
     /**
-    * @brief Signal for finding user.
-    *
-    * @param coordinates user geo coordinates
-    */
-    void findUser(const QPointF &coordinates);
-
-    /**
-    * @brief Signal that informs that user's message/location failed to update on Situare server
-    *        This signal is originally sended from SituareService with name error
-    *        Signal is renamed on MainWindow
-    */
-    void messageSendingFailed(const QString &error);
+     * @brief Signal for finding user.
+     *
+     * @param coordinates user geo coordinates
+     */
+    void findUser(const GeoCoordinate &coordinates);
 
     /**
-    * @brief Signal that used to inform user that his message/location update tp Situare server
-    *        was failed.
-    *        This signal is originally sended from UserInfo
-    */
-    void notificateUpdateFailing(const QString &message);
+     * @brief Signal that used to inform user that his message/location update tp Situare server
+     *        was failed.
+     *        This signal is originally sended from UserInfo
+     * @param message message for notification
+     * @param modal true if modal notification otherwice false
+     */
+    void notificateUpdateFailing(const QString &message, bool modal);
 
     /**
-    * @brief Signal for refreshing user data.
-    *
-    */
+     * @brief Signal for refreshing user data.
+     */
     void refreshUserData();
 
     /**
-    * @brief Signal for requesting reverseGeo from SituareEngine
-    *
-    */
+     * @brief Signal for requesting reverseGeo from SituareEngine
+     */
     void requestReverseGeo();
 
     /**
-    * @brief Signals, when address data is ready
-    *
-    * @param address Street address
-    */
+     * @brief Signals, when address data is ready
+     *
+     * @param address Street address
+     */
     void reverseGeoReady(const QString &address);
 
     /**
-    * @brief Signal for requestLocationUpdate from SituareEngine via MainWindow class
-    *
-    * @param status Status message
-    * @param publish Publish on Facebook
-    */
+     * @brief Signal for requestLocationUpdate from SituareEngine via MainWindow class
+     *
+     * @param status Status message
+     * @param publish Publish on Facebook
+     */
     void statusUpdate(const QString &status, const bool &publish);
+
 /******************************************************************************
 * DATA MEMBERS
 ******************************************************************************/
 private:
-    bool m_backupFacebookPublishPolicity; ///< Backup of publish on Facebook checkbox value
-    bool m_expanded;                    ///< Item expanded state   
-    bool m_messageUpdateVerified;       ///< Place for message/location update check
-    QLabel *m_locationLabel;            ///< Location label
-    QLabel *m_nameLabel;                ///< Name label
-    QLabel *m_statusTextLabel;          ///< Status text label
-    QLabel *m_updatedLabel;             ///< Updated label
-    QPixmap m_backgroundBottomImage;    ///< Bottom background image
-    QPixmap m_backgroundMiddleImage;    ///< Middle background image
-    QPixmap m_backgroundTopImage;       ///< Top background image
-    QPoint m_mousePosition;             ///< Current mouse press position
-    QPointF m_coordinates;              ///< User current coordinates
-    QString m_address;                  ///< Address from where the new message was sent
-    QString m_backupMessage;            ///< Backup of users message
-    QString m_messageText;              ///< User's message
-    QString m_time;                     ///< Time when the new message was sent
-    QString m_userName;                 ///< User's name
-    ImageButton *m_findButton;          ///< User find button   
+    bool m_backupFacebookPublishPolicity;   ///< Backup of publish on Facebook checkbox value
+    bool m_expanded;                        ///< Item expanded state
+
+    QLabel *m_locationLabel;                ///< Location label
+    QLabel *m_nameLabel;                    ///< Name label
+    QLabel *m_statusTextLabel;              ///< Status text label
+    QLabel *m_updatedLabel;                 ///< Updated label
+
+    QPixmap m_backgroundBottomImage;        ///< Bottom background image
+    QPixmap m_backgroundMiddleImage;        ///< Middle background image
+    QPixmap m_backgroundTopImage;           ///< Top background image
+
+    QPoint m_mousePosition;                 ///< Current mouse press position
+
+    QString m_address;                      ///< Address from where the new message was sent
+    QString m_backupMessage;                ///< Backup of users message
+    QString m_messageText;                  ///< User's message
+    QString m_time;                         ///< Time when the new message was sent
+    QString m_userName;                     ///< User's name
+
+    GeoCoordinate m_coordinates;            ///< User current coordinates
+    ImageButton *m_avatar;                  ///< User find button
     UpdateLocationDialog *m_updateLocation; ///< Update location dialog
 };