Situare - A location system for Facebook
Copyright (C) 2010 Ixonos Plc. Authors:
+ Jukka Saastamoinen - jukka.saastamoinen@ixonos.com
Jussi Laitinen - jussi.laitinen@ixonos.com
+ Katri Kaikkonen - katri.kaikkonen@ixonos.com
+ Henri Lampela - henri.lampela@ixonos.com
+ Ville Tiensuu - ville.tiensuu@ixonos.com
Situare is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
#define USERINFO_H
#include <QWidget>
-#include <QTreeWidgetItem>
-#include <QListWidgetItem>
-#include "updatelocation/updatelocationdialog.h"
-#include "../user/user.h"
+#include "coordinates/geocoordinate.h"
+#include "updatelocation/updatelocationdialog.h"
-class QLabel;
+class ImageButton;
+/**
+ * @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
+ *
+ */
+ ~UserInfo();
/*******************************************************************************
* BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
*******************************************************************************/
protected:
/**
- * @brief This function is called when the widget is drawn
- *
- * @param aPaintEvent Pointer to paint event
- */
- void paintEvent(QPaintEvent *aPaintEvent);
- /**
- * @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
-// */
-// void mouseReleaseEvent(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
+ */
+ void mouseReleaseEvent(QMouseEvent *event);
+
+ /**
+ * @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 slots:
+public:
+ /**
+ * @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 GeoCoordinate &coordinates);
+
+ /**
+ * @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.
+ */
+ void setTime(const QString &time);
/**
- * @brief Sets the users current address
- *
- * @param addr Reference to users current address
- */
- void setAddress(const QString &addr);
+ * @brief Sets the user name
+ *
+ * @param name Reference to user name
+ */
+ void setUserName(const QString &name);
+
+public slots:
/**
- * @brief Sets the user picture
- *
- * @param avat Reference to user picture
- */
- void setAvatar(const QPixmap &image);
+ * @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
- */
+ * @brief Clears backups of message and publish on Facebook setting
+ */
+ void clearUpdateLocationDialogData();
+
+ /**
+ * @brief Sets the message text
+ *
+ * @param text Reference to user message
+ */
void setMessageText(const QString &text);
+
+private:
/**
- * @brief Sets the time of updated message
- *
- * @param tim Reference to time when message was sent.
- */
- void setTime(const QString &tim);
+ * @brief reads Unsend message from settings at startup
+ */
+ void restoreUnsendMessage();
+
/**
- * @brief Sets the user name
- *
- * @param usernam Reference to user name
- */
- void setUserName(const QString &name);
+ * @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 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 function to forward messageUpdate launch signal
- *
- */
+ * @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 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 texts from User data.
-// *
-// * Text length is defined by MAXIMUM_CHARS.
-// */
-// void shortenTexts();
- /**
- * @brief Slot function to forward friends status update signal
- *
- */
- void updateFriendsStatus();
+ /**
+ * @brief Slot function to get indication when dialog is finished
+ */
+ void updateLocationDialogFinished(int reason);
+
+/******************************************************************************
+* SIGNALS
+******************************************************************************/
signals:
/**
- * @brief Signal to launch manual message update dialog
- *
- */
- void launchMessageUpdate();
+ * @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
+ * @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.
+ */
+ void refreshUserData();
+
+ /**
+ * @brief Signal for requesting reverseGeo from SituareEngine
+ */
+ void requestReverseGeo();
+
+ /**
+ * @brief Signals, when address data is ready
+ *
+ * @param address Street address
+ */
+ void reverseGeoReady(const QString &address);
+
/**
- * @brief Signal to refresh friends statuses
- * @todo: Connect to friends lists when ready
- */
- void launchUpdateFriendsStatus();
+ * @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:
- QPixmap m_backgroundTopImage; ///< Top background image
- QPixmap m_backgroundMiddleImage; ///< Middle background image
- QPixmap m_backgroundBottomImage; ///< Bottom background image
- bool m_expanded; ///< Item expanded state
- QLabel *m_distanceLabel; ///< Distance to friend label
- QLabel *m_imageLabel; ///< Image label
- QLabel *m_locationLabel; ///< Location label
- QPoint m_mousePosition; ///< Current mouse press position
- QLabel *m_nameLabel; ///< Name label
- QString m_address;
- QString m_time;
- QString m_messageText;
- QString m_avatar;
- QString m_shortenedLocation; ///< Shortened location text
- QString m_shortenedName; ///< Shortened name text
- QString m_shortenedStatusText; ///< Shortened status text
- QString m_shortenedUpdated; ///< Shortened updated text
- QString m_userName;
- QLabel *m_statusTextLabel; ///< Status text label
- QLabel *m_updatedLabel; ///< Updated label
- UpdateLocationDialog *m_locationDialog; ///< Message dialog
+ 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
-const int BACKGROUND_TOP_HEIGHT = 20;
-const int BACKGROUND_BOTTOM_HEIGHT = 15;
-const QColor COLOR_GRAY = QColor(152, 152, 152); ///< Gray color
-const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal); ///< Normal font
-const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal); ///< Small font
-const int ICON_HEIGHT = 24; ///< Icon height
-const int ICON_WIDTH = 24; ///< Icon width
-const int IMAGE_HEIGHT = 60; ///< Friend image height
-const int IMAGE_WIDTH = 60; ///< Friend image width
-const int ITEM_MAX_HEIGHT = 1240; ///< Maximum height for item
-const int ITEM_MAX_WIDTH = 250; ///< Maximum width for item
-const int ITEM_MIN_HEIGHT = 141; ///< Minimum height for item
-const int ITEM_MIN_WIDTH = 250; ///< Minimum width for item
-const int MARGIN = 5; ///< Icon margin
-const int MOUSE_PRESS_AREA_WIDTH = 20; ///< Area width for item height toggling
-const int MOUSE_PRESS_AREA_HEIGHT = 20; ///< Area height for item height toggling
-/**
-* @var NAME_LABEL_MAX_WIDTH
-*
-* @brief Name label's maximum width
-*/
-const int NAME_LABEL_MAX_WIDTH = ITEM_MIN_WIDTH - 3*MARGIN - IMAGE_WIDTH;
-/**
-* @var LABEL_MAX_WIDTH
-*
-* @brief All label's maximum width
-*/
-const int LABEL_MAX_WIDTH = ITEM_MIN_WIDTH - 3*MARGIN - IMAGE_WIDTH - MARGIN - ICON_WIDTH;
+ 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
+};
#endif // USERINFO_H