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"
35 * @brief FriendListItem shows friend data in expandable item.
37 * @class FriendListItem friendlistitem.h "ui/friendlistitem.h"
39 class FriendListItem : public QWidget
45 * @brief Construct FriendListItem.
47 * Initializes layouts and member variables. Sets stylesheet
49 * @param parent parent widget
51 FriendListItem(QWidget *parent = 0);
53 /*******************************************************************************
54 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
55 ******************************************************************************/
58 * @brief Set current mouse position to mouse event position.
60 * @param event QMouseEvent mouse press event
62 void mousePressEvent(QMouseEvent *event);
65 * @brief Call toggleHeight if mouse position is unchanged.
67 * Check if current mouse position is same as mouse release position.
68 * @param event QMouseEvent mouse release event
70 void mouseReleaseEvent(QMouseEvent *event);
73 * @brief Draws stylesheet used in this class.
75 * @param * QPaintEvent unused
77 void paintEvent(QPaintEvent *);
79 /******************************************************************************
80 * MEMBER FUNCTIONS AND SLOTS
81 ******************************************************************************/
84 * @brief Set data for this item.
86 * @param user User pointer
88 void setData(User *user);
92 * @brief Set shortened texts from User data.
94 * Text length is defined by MAXIMUM_CHARS.
99 * @brief Set shortened or full-length text to labels.
101 * @param expanded true if full-length text is set, false otherwise
103 void setText(bool expanded);
107 * @brief Slot for find button click
109 * @param coordinates friend's geo coordinates
111 void findButtonClicked();
113 /******************************************************************************
115 ******************************************************************************/
118 * @brief Signal for finding friend.
120 * @param coordinates friend's geo coordinates
122 void findFriend(const QPointF &coordinates);
124 /******************************************************************************
126 ******************************************************************************/
128 QPixmap m_backgroundTopImage; ///< Top background image
129 QPixmap m_backgroundMiddleImage; ///< Middle background image
130 QPixmap m_backgroundBottomImage; ///< Bottom background image
131 bool m_expanded; ///< Item expanded state
132 QLabel *m_distanceLabel; ///< Distance to friend label
133 ImageButton *m_findButton; ///< Friend find button
134 QLabel *m_imageLabel; ///< Image label
135 QLabel *m_locationLabel; ///< Location label
136 QPoint m_mousePosition; ///< Current mouse press position
137 QLabel *m_nameLabel; ///< Name label
138 QString m_shortenedLocation; ///< Shortened location text
139 QString m_shortenedName; ///< Shortened name text
140 QString m_shortenedStatusText; ///< Shortened status text
141 QString m_shortenedUpdated; ///< Shortened updated text
142 QLabel *m_statusTextLabel; ///< Status text label
143 QLabel *m_updatedLabel; ///< Updated label
144 User *m_user; ///< User data
147 const int BACKGROUND_TOP_HEIGHT = 20;
148 const int BACKGROUND_BOTTOM_HEIGHT = 15;
149 const QColor COLOR_GRAY = QColor(152, 152, 152); ///< Gray color
150 const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal); ///< Normal font
151 const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal); ///< Small font
152 const int ICON_HEIGHT = 24; ///< Icon height
153 const int ICON_WIDTH = 24; ///< Icon width
154 const int IMAGE_HEIGHT = 60; ///< Friend image height
155 const int IMAGE_WIDTH = 60; ///< Friend image width
156 const int ITEM_MAX_HEIGHT = 240; ///< Maximum height for item
157 const int ITEM_MAX_WIDTH = 368; ///< Maximum width for item
158 const int ITEM_MIN_HEIGHT = 141; ///< Minimum height for item
159 const int ITEM_MIN_WIDTH = 368; ///< Minimum width for item
160 const int MARGIN = 5; ///< Icon margin
161 const int MOUSE_PRESS_AREA_WIDTH = 20; ///< Area width for item height toggling
162 const int MOUSE_PRESS_AREA_HEIGHT = 20; ///< Area height for item height toggling
164 * @var NAME_LABEL_MAX_WIDTH
166 * @brief Name label's maximum width
168 const int NAME_LABEL_MAX_WIDTH = ITEM_MIN_WIDTH - 3*MARGIN - IMAGE_WIDTH;
170 * @var LABEL_MAX_WIDTH
172 * @brief All label's maximum width
174 const int LABEL_MAX_WIDTH = ITEM_MIN_WIDTH - 3*MARGIN - IMAGE_WIDTH - MARGIN - ICON_WIDTH;
176 #endif // FRIENDLISTITEM_H