backup...
[situare] / src / ui / friendlistview.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 FRIENDLISTVIEW_H
23 #define FRIENDLISTVIEW_H
24
25 #include <QWidget>
26 #include <QHash>
27
28 class QVBoxLayout;
29 class QLabel;
30 class User;
31 class FriendListItem;
32
33 /**
34 * @brief FriendListView shows items in list.
35 *
36 */
37 class FriendListView : public QWidget
38 {
39     Q_OBJECT
40
41 public:
42     /**
43     * @brief Constructor.
44     *
45     * @param parent parent widget
46     */
47     FriendListView(QWidget *parent = 0);
48
49 /******************************************************************************
50 * MEMBER FUNCTIONS AND SLOTS
51 ******************************************************************************/
52 public:
53     /**
54     * @brief Add widget to view and widget list.
55     *
56     * @param key user ID
57     * @param widget widget to add to list
58     */
59     void addWidget(const QString &key, QWidget *widget);
60
61     /**
62     * @brief Clear unused widgets from view.
63     *
64     * Clears items which are not in user ID's list from the view and widget list.
65     *
66     * @param userIDs list of new user ID's.
67     */
68     void clearUnused(const QStringList &userIDs);
69
70     /**
71     * @brief Clears filtering from list.
72     *
73     * Calls show to all widgets.
74     */
75     void clearFilter();
76
77     /**
78     * @brief Checks if view contains widget with userID.
79     *
80     * @param userID user's ID
81     * @return true if view contains widget, false otherwise
82     */
83     bool contains(const QString &userID);
84
85     /**
86     * @brief Sets filter to list.
87     *
88     * Hide all widgets that are not in the userIDs list.
89     *
90     * @param userIDs user ID's to widgets that are shown
91     */
92     void filter(const QList<QString> &userIDs);
93
94     /**
95     * @brief Returns FriendListItem with userID.
96     *
97     * @param userID user's ID
98     * @return FriendListItem
99     */
100     FriendListItem *widget(const QString &userID);
101
102 /******************************************************************************
103 * DATA MEMBERS
104 ******************************************************************************/
105 private:
106     QVBoxLayout *m_friendListLayout;    ///< Layout for this view
107     QHash<QString, QWidget *> m_widgets;  ///< List of widgets in this view. Key = user ID
108 };
109
110 #endif // FRIENDLISTVIEW_H