48b17acc8cd0b054765e89dfe478a751c594375c
[situare] / src / ui / listview.h
1 #ifndef LISTVIEW_H
2 #define LISTVIEW_H
3
4 #include <QListWidget>
5
6 class ListItem;
7
8 class ListView : public QListWidget
9 {
10     Q_OBJECT
11 public:
12     ListView(QWidget *parent = 0);
13
14 public:
15     /**
16     * @brief Add widget to view and widget list.
17     *
18     * @param key user ID
19     * @param widget widget to add to list
20     */
21     void addListItem(const QString &key, ListItem *item);
22
23     /**
24     * @brief Adds widget to view.
25     *
26     * @param item FriendListItem
27     */
28     void addListItemToView(ListItem *item);
29
30     /**
31     * @brief Clear unused widgets from view.
32     *
33     * Clears items which are not in user ID's list from the view and widget list.
34     *
35     * @param userIDs list of new user ID's.
36     */
37     void clearUnused(const QStringList &userIDs);
38
39     /**
40     * @brief Clears filtering from list.
41     *
42     * Calls show to all widgets.
43     */
44     void clearFilter();
45
46     void clearList();
47
48     /**
49     * @brief Checks if view contains widget with userID.
50     *
51     * @param userID user's ID
52     * @return true if view contains widget, false otherwise
53     */
54     bool contains(const QString &userID);
55
56     /**
57     * @brief Sets filter to list.
58     *
59     * Hide all widgets that are not in the userIDs list.
60     *
61     * @param userIDs user ID's to widgets that are shown
62     */
63     void filter(const QList<QString> &userIDs);
64
65     /**
66     * @brief Takes widget from view.
67     *
68     * Widget is not deleted.
69     *
70     * @param userID user's ID
71     * @return FriendListItem
72     */
73     ListItem *takeListItemFromView(const QString &userID);
74
75     /**
76     * @brief Returns FriendListItem with userID.
77     *
78     * @param userID user's ID
79     * @return FriendListItem
80     */
81     ListItem *listItem(const QString &userID);
82
83 signals:
84     void listItemClicked(const QString &id);
85     void listItemClicked(const QPointF &coordinates);
86
87 public slots:
88
89 private slots:
90
91     void listItemClicked(QListWidgetItem *item);
92
93 private:
94     ListItem *previousItem;
95     QHash<QString, ListItem *> m_listItems;  ///< List of items in this view. Key = user ID
96 };
97
98 #endif // LISTVIEW_H