Merge branch 'master' into userinfo
[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     /**
54     * @brief Call toggleHeight if mouse position is unchanged.
55     *
56     * Check if current mouse position is same as mouse release position.
57     * @param event QMouseEvent mouse release event
58     */
59     void mouseReleaseEvent(QMouseEvent *event);
60
61     /**
62     * @brief This function is called when the widget is drawn
63     *
64     * @param aPaintEvent Pointer to paint event
65     */
66     void paintEvent(QPaintEvent *aPaintEvent);
67
68 /******************************************************************************
69 * MEMBER FUNCTIONS AND SLOTS
70 ******************************************************************************/
71 public:
72     /**
73     * @brief Sets the users current address
74     *
75     * @param addr Reference to users current address
76     */
77     void setAddress(const QString &address);
78
79     /**
80     * @brief Sets the user picture
81     *
82     * @param avat Reference to user picture
83     */
84     void setProfileImage(const QPixmap &image);
85
86     /**
87     * @brief Sets the message text
88     *
89     * @param text Reference to user message
90     */
91     void setMessageText(const QString &text);
92
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 &time);
99
100    /**
101     * @brief Sets the user name
102     *
103     * @param usernam Reference to user name
104     */
105     void setUserName(const QString &name);
106
107 private:
108     /**
109     * @brief Set shortened or full-length text to labels.
110     *
111     * @param expanded true if full-length text is set, false otherwise
112     */
113     void setText(bool expanded);
114
115     /**
116     * @brief Set shortened texts from User data.
117     *
118     * Text length is defined by MAXIMUM_CHARS.
119     */
120     QString shortenText(const QLabel *label, const QString &text, int textMaxWidth);
121
122 private slots:
123     /**
124     * @brief Slot function to forward messageUpdate launch signal
125     *
126     */
127     void messageUpdate();
128
129 /******************************************************************************
130 * SIGNALS
131 ******************************************************************************/
132 signals:
133     /**
134     * @brief Signal for refreshing user data.
135     *
136     */
137     void refreshUserData();
138
139     /**
140     * @brief Signal for requesting reverseGeo from SituareEngine
141     *
142     */
143     void requestReverseGeo();
144
145     /**
146     * @brief Signals, when address data is ready
147     *
148     * @param address Street address
149     */
150     void reverseGeoReady(const QString &address);
151
152     /**
153     * @brief Signal for requestLocationUpdate from SituareEngine via MainWindow class
154     *
155     * @param status Status message
156     * @param publish Publish on Facebook
157     */
158     void statusUpdate(const QString &status, const bool &publish);
159
160 /******************************************************************************
161 * DATA MEMBERS
162 ******************************************************************************/
163 private:
164     bool m_expanded;                    ///< Item expanded state
165     QLabel *m_imageLabel;               ///< Image label
166     QLabel *m_locationLabel;            ///< Location label
167     QLabel *m_nameLabel;                ///< Name label
168     QLabel *m_statusTextLabel;          ///< Status text label
169     QLabel *m_updatedLabel;             ///< Updated label
170     QPixmap m_backgroundBottomImage;    ///< Bottom background image
171     QPixmap m_backgroundMiddleImage;    ///< Middle background image
172     QPixmap m_backgroundTopImage;       ///< Top background image
173     QPoint m_mousePosition;             ///< Current mouse press position
174     QString m_address;                  ///< Address from where the new message was sent.
175     QString m_messageText;              ///< User's message
176     QString m_time;                     ///< Time when the new message was sent
177     QString m_userName;                 ///< User's name
178
179 };
180
181 #endif // USERINFO_H