2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Jussi Laitinen - jussi.laitinen@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 #ifndef FRIENDLISTITEM_H
23 #define FRIENDLISTITEM_H
26 #include <QTreeWidgetItem>
27 #include <QListWidgetItem>
29 #include "user/user.h"
34 * @brief FriendListItem shows friend data in expandable item.
36 * @class FriendListItem friendlistitem.h "ui/friendlistitem.h"
38 class FriendListItem : public QWidget
44 * @brief Construct FriendListItem.
46 * Initializes layouts and member variables. Sets stylesheet
48 * @param parent parent widget
50 FriendListItem(QWidget *parent = 0);
52 /*******************************************************************************
53 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
54 ******************************************************************************/
57 * @brief Set current mouse position to mouse event position.
59 * @param event QMouseEvent mouse press event
61 void mousePressEvent(QMouseEvent *event);
64 * @brief Call toggleHeight if mouse position is unchanged.
66 * Check if current mouse position is same as mouse release position.
67 * @param event QMouseEvent mouse release event
69 void mouseReleaseEvent(QMouseEvent *event);
72 * @brief Draws stylesheet used in this class.
74 * @param QPaintEvent unused
76 void paintEvent(QPaintEvent *);
78 /******************************************************************************
79 * MEMBER FUNCTIONS AND SLOTS
80 ******************************************************************************/
83 * @brief Set data for this item.
85 * @param user User object
87 void setData(const User &user);
91 * @brief Set shortened texts from User data.
93 * Text length is defined by MAXIMUM_CHARS.
98 * @brief Toggle item height.
102 /******************************************************************************
104 ******************************************************************************/
106 static const int ICON_MARGIN = 5; ///< Icon margin
107 static const int IMAGE_HEIGHT = 60; ///< Friend image height
108 static const int IMAGE_WIDTH = 60; ///< Friend image width
110 static const int ITEM_MAX_HEIGHT = 240; ///< Maximum height for item
111 static const int ITEM_MAX_WIDTH = 368; ///< Maximum width for item
112 static const int ITEM_MIN_HEIGHT = 141; ///< Minimum height for item
113 static const int ITEM_MIN_WIDTH = 368; ///< Minimum width for item
115 static const int MAXIMUM_CHARS = 32; ///< Maximum character count for labels
117 bool m_expanded; ///< Item expanded state
118 QLabel *m_imageLabel; ///< Image label
119 QWidget *m_infoWidget; ///< Info widget: updated, status text, location
120 QLabel *m_locationLabel; ///< Location label
121 QPoint m_mousePosition; ///< Current mouse press position
122 QLabel *m_nameLabel; ///< Name label
123 QString m_shortenedLocation; ///< Shortened location text
124 QString m_shortenedName; ///< Shortened name text
125 QString m_shortenedStatusText; ///< Shortened status text
126 QString m_shortenedUpdated; ///< Shortened updated text
127 QLabel *m_statusTextLabel; ///< Status text label
128 QLabel *m_updatedLabel; ///< Updated label
130 User m_user; ///< User data
133 const QString BACKGROUND_PATH = ":/res/images/list_item.png"; ///< Background image path
134 const QString CLOCK_PATH = ":/res/images/clock.png"; ///< Clock image path
135 const QString ENVELOPE_PATH = ":/res/images/envelope.png"; ///< Envelope image path
136 const QString COMPASS_PATH = ":/res/images/compass.png"; ///< Compass image path
138 #endif // FRIENDLISTITEM_H