X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fui%2Ffriendlistitem.h;h=860bd7ee949318d84645fa07f267d50f5aabc740;hb=ffd4889f40bdf37c5864b2f87c6c36cc1a7eae00;hp=ac9e89368ad074c5a2d89dc2d889959fc43dc72a;hpb=2eff0bf8455cb4a3a3dee1b48c68a51e91794365;p=situare diff --git a/src/ui/friendlistitem.h b/src/ui/friendlistitem.h index ac9e893..860bd7e 100644 --- a/src/ui/friendlistitem.h +++ b/src/ui/friendlistitem.h @@ -30,53 +30,109 @@ class QLabel; +/** +* @brief FriendListItem shows friend data in expandable item. +* +* @class FriendListItem friendlistitem.h "ui/friendlistitem.h" +*/ class FriendListItem : public QWidget { Q_OBJECT public: + /** + * @brief Construct FriendListItem. + * + * Initializes layouts and member variables. Sets stylesheet + * for this class. + * @param parent parent widget + */ FriendListItem(QWidget *parent = 0); - void setData(const User &user); - +/******************************************************************************* + * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS + ******************************************************************************/ protected: + /** + * @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 Draws stylesheet used in this class. + * + * @param QPaintEvent unused + */ void paintEvent(QPaintEvent *); - void mousePressEvent(QMouseEvent *); - - void mouseReleaseEvent(QMouseEvent *); - /****************************************************************************** * MEMBER FUNCTIONS AND SLOTS ******************************************************************************/ +public: + /** + * @brief Set data for this item. + * + * @param user User object + */ + void setData(const User &user); private: - void toggleHeight(); - + /** + * @brief Set shortened texts from User data. + * + * Text length is defined by MAXIMUM_CHARS. + */ void shortenTexts(); -signals: - void changeState(); + /** + * @brief Toggle item height. + */ + void toggleHeight(); /****************************************************************************** * DATA MEMBERS ******************************************************************************/ private: - - QLabel *m_updatedLabel; - QLabel *m_statusTextLabel; - QLabel *m_locationLabel; - QLabel *m_imageLabel; - QLabel *m_nameLabel; - QString m_shortenedName; - QString m_shortenedUpdated; - QString m_shortenedStatusText; - QString m_shortenedLocation; - QString m_image; - bool m_expanded; - QPoint m_mousePosition; - QWidget *m_infoWidget; - User m_user; + static const int ICON_MARGIN = 5; ///< Icon margin + static const int IMAGE_HEIGHT = 60; ///< Friend image height + static const int IMAGE_WIDTH = 60; ///< Friend image width + + static const int ITEM_MAX_HEIGHT = 240; ///< Maximum height for item + static const int ITEM_MAX_WIDTH = 368; ///< Maximum width for item + static const int ITEM_MIN_HEIGHT = 141; ///< Minimum height for item + static const int ITEM_MIN_WIDTH = 368; ///< Minimum width for item + + static const int MAXIMUM_CHARS = 32; ///< Maximum character count for labels + + bool m_expanded; ///< Item expanded state + QLabel *m_imageLabel; ///< Image label + QWidget *m_infoWidget; ///< Info widget: updated, status text, location + QLabel *m_locationLabel; ///< Location label + QPoint m_mousePosition; ///< Current mouse press position + QLabel *m_nameLabel; ///< Name label + QString m_shortenedLocation; ///< Shortened location text + QString m_shortenedName; ///< Shortened name text + QString m_shortenedStatusText; ///< Shortened status text + QString m_shortenedUpdated; ///< Shortened updated text + QLabel *m_statusTextLabel; ///< Status text label + QLabel *m_updatedLabel; ///< Updated label + + User m_user; ///< User data }; +const QString BACKGROUND_PATH = ":/res/images/list_item.png"; ///< Background image path +const QString CLOCK_PATH = ":/res/images/clock.png"; ///< Clock image path +const QString ENVELOPE_PATH = ":/res/images/envelope.png"; ///< Envelope image path +const QString COMPASS_PATH = ":/res/images/compass.png"; ///< Compass image path + #endif // FRIENDLISTITEM_H