Merge commit 'origin/locationlistview' into friendlist_filtering_text_field
[situare] / src / ui / friendlistpanel.h
1 /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Kaj Wallin - kaj.wallin@ixonos.com
6         Henri Lampela - henri.lampela@ixonos.com
7         Pekka Nissinen - pekka.nissinen@ixonos.com
8         Jussi Laitinen - jussi.laitinen@ixonos.com
9         Sami Rämö - sami.ramo@ixonos.com
10
11     Situare is free software; you can redistribute it and/or
12     modify it under the terms of the GNU General Public License
13     version 2 as published by the Free Software Foundation.
14
15     Situare is distributed in the hope that it will be useful,
16     but WITHOUT ANY WARRANTY; without even the implied warranty of
17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18     GNU General Public License for more details.
19
20     You should have received a copy of the GNU General Public License
21     along with Situare; if not, write to the Free Software
22     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
23     USA.
24 */
25
26 #ifndef FRIENDLISTPANEL_H
27 #define FRIENDLISTPANEL_H
28
29 #include <QWidget>
30
31 class QLabel;
32 class QPushButton;
33
34 class FriendListItemDelegate;
35 class GeoCoordinate;
36 class FriendListView;
37 class User;
38
39 /**
40  * @brief Class for sliding friends list panel
41  *
42  * @author Kaj Wallin - kaj.wallin (at) ixonos.com
43  * @author Henri Lampela - henri.lampela (at) ixonos.com
44  * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
45  * @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
46  * @author Sami Rämö - sami.ramo (at) ixonos.com
47  */
48 class FriendListPanel : public QWidget
49 {
50     Q_OBJECT
51
52 public:
53     /**
54      * @brief Default constructor
55      *
56      * @param parent
57      */
58     FriendListPanel(QWidget *parent = 0);
59
60 /*******************************************************************************
61  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
62  ******************************************************************************/
63 protected:
64     /**
65     * @brief Re-implemented from QWidget::hideEvent()
66     *
67     * Calls updateKeyboardGrabbing().
68     *
69     * @param event
70     */
71     void hideEvent(QHideEvent *event);
72
73     /**
74     * @brief Re-implemented from QWidget::showEvent()
75     *
76     * Calls updateKeyboardGrabbing().
77     *
78     * @param event
79     */
80     void showEvent(QShowEvent *event);
81
82 /*******************************************************************************
83  * MEMBER FUNCTIONS AND SLOTS
84  ******************************************************************************/
85 public slots:
86     /**
87      * @brief Slot to update friend item's image
88      *
89      * @param user Friend
90      */
91     void friendImageReady(User *user);
92
93     /**
94      * @brief Slot to refresh friends list
95      *
96      * @param friendList
97      */
98     void friendInfoReceived(QList<User *> &friendList);
99
100 private:
101     /**
102     * @brief Set visibility for filtering related UI elements
103     *
104     * @param visible True if items should be visible, false if not
105     */
106     void setFilteringLayoutVisibility(bool visible);
107
108     /**
109     * @brief Takes care of grabbing and releasing the keyboard when required
110     *
111     * Keyboard is grabbed when MainWindow it the topmost window and FriendListPanel is visible.
112     * Releasing is done if the MainWindow is not the topmost window and/or FriendListPanel
113     * is invisible.
114     */
115     void updateKeyboardGrabbing();
116
117 private slots:
118     /**
119      * @brief Slot to clear friend list filter
120      */
121     void clearFriendListFilter();
122
123     /**
124     * @brief Slot for clearing the friend list filtering.
125     */
126     void clearFiltering();
127
128     /**
129     * @brief Set filtering UI elements visibility based on the filtering text value
130     *
131     * Filtering UI elements are invoked when the text becomes not empty and hidden when text
132     * becomes empty.
133     *
134     * @param text New text value
135     */
136     void filterTextChanged(const QString &text);
137
138     /**
139     * @brief Routes to selected friend.
140     *
141     * Emits routeToFriend if friend is selected from list.
142     */
143     void routeToSelectedFriend();
144
145     /**
146      * @brief Slot to show friends in list.
147      *
148      * Shows only friends that are on userIDs list
149      * @param userIDs list of user ID's
150      */
151     void showFriendsInList(const QList<QString> &userIDs);
152
153     /**
154     * @brief Called when topmost window is changed
155     *
156     * Does set m_mainWindowIsTopmost and calls updateKeyboardGrabbing()
157     *
158     * @param mainWindowIsTopmost True if MainWindow is the topmost one
159     */
160     void topmostWindowChanged(bool mainWindowIsTopmost);
161
162 /*******************************************************************************
163  * SIGNALS
164  ******************************************************************************/
165 signals:
166     /**
167      * @brief Signal for friend finding
168      *
169      * @param coordinates Target coordinate
170      */
171     void findFriend(const GeoCoordinate &coordinates);
172
173     /**
174     * @brief Signal for routing to friend.
175     *
176     * @param coordinates friend's geo coordinates
177     */
178     void routeToFriend(const GeoCoordinate &coordinates);
179
180     /**
181      * @brief Signal for requesting a panel to be opened
182      *
183      * @param widget Pointer to the widget that emitted the signal
184      */
185     void showPanelRequested(QWidget *widget);
186
187 /*******************************************************************************
188  * DATA MEMBERS
189  ******************************************************************************/
190 private:
191     bool m_mainWindowIsTopmost;         ///< Is the MainWindow the topmost one
192
193     QLabel *m_friendListLabel;          ///< Friend list label
194     
195     QLineEdit *m_filterField;           ///< Text field for the filter text
196     
197     QPushButton *m_clearFilterButton;   ///< Button to clear list filtering
198     QPushButton *m_filterClearButton;   ///< Button for clearing the filtering
199     QPushButton *m_routeButton;         ///< Button to route to friend
200
201     QWidget *m_friendListHeaderWidget;  ///< Friend list header widget
202
203     FriendListView *m_friendListView;   ///< Friend list view
204 };
205
206 #endif // FRIENDLISTPANEL_H