Added comments to friendlistitem, friendlistview and listviewscreen.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Fri, 30 Apr 2010 07:41:27 +0000 (10:41 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Fri, 30 Apr 2010 07:41:27 +0000 (10:41 +0300)
src/ui/friendlistitem.cpp
src/ui/friendlistitem.h
src/ui/friendlistview.h
src/ui/listviewscreen.h

index 02c9236..fb834db 100644 (file)
 #include "friendlistitem.h"
 #include "user/user.h"
 
-const int IMAGE_WIDTH = 60;
-const int IMAGE_HEIGHT = 60;
-
-const int ITEM_MIN_WIDTH = 368;
-const int ITEM_MAX_WIDTH = 368;
-const int ITEM_MIN_HEIGHT = 141;
-const int ITEM_MAX_HEIGHT = 240;
-const int ICON_MARGIN = 5;
-
-const QString BACKGROUND_PATH = QString(":/res/images/list_item.png");
-const QString CLOCK_PATH = QString(":/res/images/clock.png");
-const QString ENVELOPE_PATH = QString(":/res/images/envelope.png");
-const QString COMPASS_PATH = QString(":/res/images/compass.png");
-
-const int MAXIMUM_CHARS = 32;
-
 FriendListItem::FriendListItem(QWidget *parent)
     : QWidget(parent)
     , m_expanded(false)
@@ -102,7 +86,6 @@ FriendListItem::FriendListItem(QWidget *parent)
     topLayout->addWidget(m_imageLabel);
     topLayout->addWidget(m_nameLabel);
 
-    QLabel *tmp = new QLabel(this);
     bottomLayout->addSpacerItem(new QSpacerItem(IMAGE_WIDTH, IMAGE_HEIGHT));
     bottomLayout->addWidget(m_infoWidget, 1);
 
@@ -133,7 +116,6 @@ void FriendListItem::setData(const User &user)
     m_updatedLabel->setText(m_shortenedUpdated);
     m_statusTextLabel->setText(m_shortenedStatusText);
     m_locationLabel->setText(m_shortenedLocation);
-    m_image = user.profileImageUrl().toString();
 
 }
 
index ac9e893..860bd7e 100644 (file)
 
 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
index c1a87e5..5ba2d79 100644 (file)
 #ifndef FRIENDLISTVIEW_H
 #define FRIENDLISTVIEW_H
 
-#include <QListWidget>
-#include <QTreeWidget>
-#include <QVBoxLayout>
 #include <QWidget>
+#include <QList>
 
+class QVBoxLayout;
 class QLabel;
 
+/**
+* @brief FriendListView shows items in list.
+*
+* @class FriendListView friendlistview.h "ui/friendlistview.h"
+*/
 class FriendListView : public QWidget
 {
     Q_OBJECT
 
 public:
+    /**
+    * @brief Constructor.
+    *
+    * @param parent parent widget
+    */
     FriendListView(QWidget *parent = 0);
 
+/******************************************************************************
+* MEMBER FUNCTIONS AND SLOTS
+******************************************************************************/
+public:
+    /**
+    * @brief Add widget to view and widget list.
+    *
+    * @param widget widget to add to list
+    */
     void addWidget(QWidget *widget);
+
+    /**
+    * @brief Clear view.
+    *
+    * Clears all items from the view and widget list.
+    */
     void clear();
 
+/******************************************************************************
+* DATA MEMBERS
+******************************************************************************/
 private:
-    QVBoxLayout *m_friendListLayout;
-    QList<QWidget *> widgets;
-    QLabel *m_loadLabel;
+    QVBoxLayout *m_friendListLayout;    ///< Layout for this view
+    QList<QWidget *> widgets;           ///< List of widgets in this view
 };
 
 #endif // FRIENDLISTVIEW_H
index c1a388c..336dc9c 100644 (file)
@@ -62,9 +62,20 @@ public slots:
     */
     void updateMessage();
 
+    /**
+    * @brief Slot for new user and friend data.
+    *
+    * @param user User object
+    * @param friends list of User objects
+    */
     void userDataChanged(User* user,QList<User*>& friends);
 
 signals:
+    /**
+    * @brief Signal for progress bar indicator toggling.
+    *
+    * @param state true if progress bar should be shown, false otherwise
+    */
     void toggleProgressIndicator(bool state);
 
 /*******************************************************************************
@@ -100,7 +111,7 @@ private:
     QPropertyAnimation *m_anim14;
     UpdateLocationDialog *m_locationDialog; ///< Message dialog
 
-    FriendListView *m_friendListView;
+    FriendListView *m_friendListView;   ///< Friend list view
 };
 
 #endif // LISTVIEWTAB_H