Connected filtering text field with the lists filtering functionality
[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 <QtGui>
30
31 class QLabel;
32 class QWidget;
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 Used for grabbing the keyboard after the text field is fully initiated.
66     *
67     * @param event
68     */
69     void showEvent(QShowEvent *event);
70
71 /*******************************************************************************
72  * MEMBER FUNCTIONS AND SLOTS
73  ******************************************************************************/
74 public slots:
75     /**
76      * @brief Slot to update friend item's image
77      *
78      * @param user Friend
79      */
80     void friendImageReady(User *user);
81
82     /**
83      * @brief Slot to refresh friends list
84      *
85      * @param friendList
86      */
87     void friendInfoReceived(QList<User *> &friendList);
88
89 private:
90     /**
91     * @brief Set visibility for filtering related UI elements
92     *
93     * @param visible True if items should be visible, false if not
94     */
95     void setFilteringLayoutVisible(bool visible);
96
97 private slots:
98     /**
99      * @brief Slot to clear friend list filter.
100      */
101     void clearFriendListFilter();
102
103     /**
104     * @brief Slot for clearing the friend list filtering.
105     */
106     void clearFiltering();
107
108     /**
109     * @brief Set filtering UI elements visibility based on the filtering text value
110     *
111     * Filtering UI elements are invoked when the text becomes not empty and hidden when text
112     * becomes empty.
113     *
114     * @param text New text value
115     */
116     void filterTextChanged(const QString &text);
117
118     /**
119      * @brief Slot to show friends in list.
120      *
121      * Shows only friends that are on userIDs list.
122      * @param userIDs list of user ID's
123      */
124     void showFriendsInList(const QList<QString> &userIDs);
125
126 /*******************************************************************************
127  * SIGNALS
128  ******************************************************************************/
129 signals:
130     /**
131      * @brief Signal for friend finding.
132      *
133      * @param coordinates Target coordinate
134      */
135     void findFriend(const GeoCoordinate &coordinates);
136
137 /*******************************************************************************
138  * DATA MEMBERS
139  ******************************************************************************/
140 private:
141     QLabel *m_friendListLabel;          ///< Friend list label
142     QLineEdit *m_filterField;           ///< Text field for the filter text
143     QPushButton *m_clearFilterButton;   ///< Button to clear list filtering
144     QPushButton *m_filterClearButton;   ///< Button for clearing the filtering
145     QWidget *m_friendListHeaderWidget;  ///< Friend list header widget
146
147     FriendListView *m_friendListView;   ///< Friend list view
148
149 };
150
151 #endif // FRIENDLISTPANEL_H