Added userinfo
[situare] / src / ui / userinfo.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Jussi Laitinen - jussi.laitinen@ixonos.com
6
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.
10
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.
15
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,
19    USA.
20 */
21
22 #ifndef USERINFO_H
23 #define USERINFO_H
24
25 #include <QWidget>
26 #include <QTreeWidgetItem>
27 #include <QListWidgetItem>
28 #include "updatelocation/updatelocationdialog.h"
29
30 #include "../user/user.h"
31
32 class QLabel;
33
34 class UserInfo : public QWidget
35 {
36     Q_OBJECT
37 public:
38     /**
39     * @brief Constructor
40     *
41     * @param parent Parent
42     */
43     UserInfo(QWidget *parent=0);
44
45 /*******************************************************************************
46 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
47 *******************************************************************************/
48 protected:
49     /**
50     * @brief This function is called when the widget is drawn
51     *
52     * @param aPaintEvent Pointer to paint event
53     */
54     void paintEvent(QPaintEvent *aPaintEvent);
55     /**
56     * @brief Set current mouse position to mouse event position.
57     *
58     * @param event QMouseEvent mouse press event
59     */
60     void mousePressEvent(QMouseEvent *event);
61 //    /**
62 //    * @brief Call toggleHeight if mouse position is unchanged.
63 //    *
64 //    * Check if current mouse position is same as mouse release position.
65 //    * @param event QMouseEvent mouse release event
66 //    */
67 //    void mouseReleaseEvent(QMouseEvent *event);
68
69 /******************************************************************************
70 * MEMBER FUNCTIONS AND SLOTS
71 ******************************************************************************/
72 public slots:
73
74
75     /**
76     * @brief Sets the users current address
77     *
78     * @param addr Reference to users current address
79     */
80     void setAddress(const QString &addr);
81     /**
82     * @brief Sets the user picture
83     *
84     * @param avat Reference to user picture
85     */
86     void setAvatar(const QPixmap &image);
87     /**
88     * @brief Sets the message text
89     *
90     * @param text Reference to user message
91     */
92     void setMessageText(const QString &text);
93     /**
94     * @brief Sets the time of updated message
95     *
96     * @param tim Reference to time when message was sent.
97     */
98     void setTime(const QString &tim);
99     /**
100     * @brief Sets the user name
101     *
102     * @param usernam Reference to user name
103     */
104     void setUserName(const QString &name);
105 private slots:
106     /**
107     * @brief Slot function to forward messageUpdate launch signal
108     *
109     */
110     void messageUpdate();
111 //    /**
112 //    * @brief Set shortened or full-length text to labels.
113 //    *
114 //    * @param expanded true if full-length text is set, false otherwise
115 //    */
116 //    void setText(bool expanded);
117 //    /**
118 //    * @brief Set shortened texts from User data.
119 //    *
120 //    * Text length is defined by MAXIMUM_CHARS.
121 //    */
122 //    void shortenTexts();
123     /**
124     * @brief Slot function to forward friends status update signal
125     *
126     */
127     void updateFriendsStatus();
128
129 signals:
130     /**
131     * @brief Signal to launch manual message update dialog
132     *
133     */
134     void launchMessageUpdate();
135     /**
136     * @brief Signal to refresh friends statuses
137     * @todo: Connect to friends lists when ready
138     */
139     void launchUpdateFriendsStatus();
140
141 /******************************************************************************
142 * DATA MEMBERS
143 ******************************************************************************/
144 private:
145     QPixmap m_backgroundTopImage;   ///< Top background image
146     QPixmap m_backgroundMiddleImage;   ///< Middle background image
147     QPixmap m_backgroundBottomImage;   ///< Bottom background image
148     bool m_expanded;                ///< Item expanded state
149     QLabel *m_distanceLabel;        ///< Distance to friend label
150     QLabel *m_imageLabel;           ///< Image label
151     QLabel *m_locationLabel;        ///< Location label
152     QPoint m_mousePosition;         ///< Current mouse press position
153     QLabel *m_nameLabel;            ///< Name label
154     QString m_address;
155     QString m_time;
156     QString m_messageText;
157     QString m_avatar;
158     QString m_shortenedLocation;    ///< Shortened location text
159     QString m_shortenedName;        ///< Shortened name text
160     QString m_shortenedStatusText;  ///< Shortened status text
161     QString m_shortenedUpdated;     ///< Shortened updated text
162     QString m_userName;
163     QLabel *m_statusTextLabel;      ///< Status text label
164     QLabel *m_updatedLabel;         ///< Updated label
165     UpdateLocationDialog *m_locationDialog; ///< Message dialog
166
167 };
168
169 const int BACKGROUND_TOP_HEIGHT = 20;
170 const int BACKGROUND_BOTTOM_HEIGHT = 15;
171 const QColor COLOR_GRAY = QColor(152, 152, 152);    ///< Gray color
172 const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal);    ///< Normal font
173 const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal);     ///< Small font
174 const int ICON_HEIGHT = 24;     ///< Icon height
175 const int ICON_WIDTH = 24;       ///< Icon width
176 const int IMAGE_HEIGHT = 60; ///< Friend image height
177 const int IMAGE_WIDTH = 60;  ///< Friend image width
178 const int ITEM_MAX_HEIGHT = 1240; ///< Maximum height for item
179 const int ITEM_MAX_WIDTH = 250;  ///< Maximum width for item
180 const int ITEM_MIN_HEIGHT = 141; ///< Minimum height for item
181 const int ITEM_MIN_WIDTH = 250;  ///< Minimum width for item
182 const int MARGIN = 5;   ///< Icon margin
183 const int MOUSE_PRESS_AREA_WIDTH = 20;  ///< Area width for item height toggling
184 const int MOUSE_PRESS_AREA_HEIGHT = 20; ///< Area height for item height toggling
185 /**
186 * @var NAME_LABEL_MAX_WIDTH
187 *
188 * @brief Name label's maximum width
189 */
190 const int NAME_LABEL_MAX_WIDTH = ITEM_MIN_WIDTH - 3*MARGIN - IMAGE_WIDTH;
191 /**
192 * @var LABEL_MAX_WIDTH
193 *
194 * @brief All label's maximum width
195 */
196 const int LABEL_MAX_WIDTH = ITEM_MIN_WIDTH - 3*MARGIN - IMAGE_WIDTH - MARGIN - ICON_WIDTH;
197
198 #endif // USERINFO_H