Updated userinfo and userinfopanel classes. Added corresponding signals.
[situare] / src / ui / userinfo.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Jukka Saastamoinen - jukka.saastamoinen@ixonos.com
6        Jussi Laitinen - jussi.laitinen@ixonos.com
7        Katri Kaikkonen - katri.kaikkonen@ixonos.com
8        Henri Lampela - henri.lampela@ixonos.com
9
10    Situare is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License
12    version 2 as published by the Free Software Foundation.
13
14    Situare is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with Situare; if not, write to the Free Software
21    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
22    USA.
23 */
24
25 #ifndef USERINFO_H
26 #define USERINFO_H
27
28 #include <QWidget>
29 #include "updatelocation/updatelocationdialog.h"
30
31 class UserInfo : public QWidget
32 {
33     Q_OBJECT
34 public:
35     /**
36     * @brief Constructor
37     *
38     * @param parent Parent
39     */
40     UserInfo(QWidget *parent=0);
41
42 /*******************************************************************************
43 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
44 *******************************************************************************/
45 protected:
46     /**
47     * @brief Set current mouse position to mouse event position.
48     *
49     * @param event QMouseEvent mouse press event
50     */
51     void mousePressEvent(QMouseEvent *event);
52     /**
53     * @brief Call toggleHeight if mouse position is unchanged.
54     *
55     * Check if current mouse position is same as mouse release position.
56     * @param event QMouseEvent mouse release event
57     */
58     void mouseReleaseEvent(QMouseEvent *event);
59     /**
60     * @brief This function is called when the widget is drawn
61     *
62     * @param aPaintEvent Pointer to paint event
63     */
64     void paintEvent(QPaintEvent *aPaintEvent);
65
66 /******************************************************************************
67 * MEMBER FUNCTIONS AND SLOTS
68 ******************************************************************************/
69 public:
70     /**
71     * @brief Sets the users current address
72     *
73     * @param addr Reference to users current address
74     */
75     void setAddress(const QString &addr);
76
77     /**
78     * @brief Sets the user picture
79     *
80     * @param avat Reference to user picture
81     */
82     void setAvatar(const QPixmap &image);
83
84     /**
85     * @brief Sets the message text
86     *
87     * @param text Reference to user message
88     */
89     void setMessageText(const QString &text);
90
91     /**
92     * @brief Sets the time of updated message
93     *
94     * @param tim Reference to time when message was sent.
95     */
96     void setTime(const QString &tim);
97
98    /**
99     * @brief Sets the user name
100     *
101     * @param usernam Reference to user name
102     */
103     void setUserName(const QString &name);
104
105 private:
106     /**
107     * @brief Set shortened or full-length text to labels.
108     *
109     * @param expanded true if full-length text is set, false otherwise
110     */
111     void setText(bool expanded);
112
113     /**
114     * @brief Set shortened texts from User data.
115     *
116     * Text length is defined by MAXIMUM_CHARS.
117     */
118     QString shortenText(const QLabel *label, const QString &text, int textMaxWidth);
119
120 private slots:
121     /**
122     * @brief Slot function to forward messageUpdate launch signal
123     *
124     */
125     void messageUpdate();
126
127 /******************************************************************************
128 * SIGNALS
129 ******************************************************************************/
130 signals:
131     /**
132     * @brief Signal for refreshing user data.
133     *
134     */
135     void refreshUserData();
136
137     /**
138     * @brief Signal for requesting reverseGeo from SituareEngine
139     *
140     */
141     void requestReverseGeo();
142
143     /**
144     * @brief Signals, when address data is ready
145     *
146     * @param address Street address
147     */
148     void reverseGeoReady(const QString &address);
149
150     /**
151     * @brief Signal for requestLocationUpdate from SituareEngine via MainWindow class
152     *
153     * @param status Status message
154     * @param publish Publish on Facebook
155     */
156     void statusUpdate(const QString &status, const bool &publish);
157
158 /******************************************************************************
159 * DATA MEMBERS
160 ******************************************************************************/
161 private:
162     bool m_expanded;                    ///< Item expanded state
163     QLabel *m_imageLabel;               ///< Image label
164     QLabel *m_locationLabel;            ///< Location label
165     QLabel *m_nameLabel;                ///< Name label
166     QLabel *m_statusTextLabel;          ///< Status text label
167     QLabel *m_updatedLabel;             ///< Updated label
168     QPixmap m_backgroundBottomImage;    ///< Bottom background image
169     QPixmap m_backgroundMiddleImage;    ///< Middle background image
170     QPixmap m_backgroundTopImage;       ///< Top background image
171     QPoint m_mousePosition;             ///< Current mouse press position
172     QString m_address;                  ///< Address from where the new message was sent.
173     QString m_messageText;              ///< User's message
174     QString m_time;                     ///< Time when the new message was sent
175     QString m_userName;                 ///< User's name
176
177 };
178
179 #endif // USERINFO_H