Renamed method parameters in ListView.
[situare] / src / ui / listview.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 LISTVIEW_H
23 #define LISTVIEW_H
24
25 #include <QListWidget>
26
27 class GeoCoordinate;
28 class ListItem;
29
30 /**
31 * @brief View for ListItems.
32 *
33 * ListView is used to show ListItems in list view. Items can be added, removed or
34 * filtered.
35 */
36 class ListView : public QListWidget
37 {
38     Q_OBJECT
39
40 public:
41     /**
42     * @brief Constructor.
43     *
44     * @param parent QWidget
45     */
46     ListView(QWidget *parent = 0);
47
48     /**
49     * @brief Destructor.
50     *
51     * Calls ListView::clearList().
52     */
53     ~ListView();
54
55 /******************************************************************************
56 * MEMBER FUNCTIONS AND SLOTS
57 ******************************************************************************/
58 public:
59     /**
60     * @brief Add item to view and item list.
61     *
62     * @param key user ID
63     * @param item item to add to view and list
64     */
65     void addListItem(const QString &key, ListItem *item);
66
67     /**
68     * @brief Adds item to view.
69     *
70     * @param item FriendListItem
71     */
72     void addListItemToView(ListItem *item);
73
74     /**
75     * @brief Clear unused items from view.
76     *
77     * Clears items which are not in item ID's list from the view and items list.
78     *
79     * @param itemIDs list of item ID's to keep in list view
80     */
81     void clearUnused(const QStringList &itemIDs);
82
83     /**
84     * @brief Clears filtering from list.
85     *
86     * Shows all items.
87     */
88     void clearFilter();
89
90     /**
91     * @brief Clears list.
92     *
93     * Items are removed from view and item list.
94     */
95     void clearList();
96
97     /**
98     * @brief Checks if view contains item with userID.
99     *
100     * @param userID user's ID
101     * @return true if view contains item, false otherwise
102     */
103     bool contains(const QString &userID);
104
105     /**
106     * @brief Filters list by item IDs.
107     *
108     * Hide all items that are not in the itemIDs list.
109     *
110     * @param itemIDs item ID's for items that are shown
111     */
112     void filter(const QList<QString> &itemIDs);
113
114     /**
115     * @brief Filters list by text pattern.
116     *
117     * Filtering uses item names.
118     *
119     * @param pattern text pattern to filter
120     */
121     void filter(const QString &pattern);
122
123     /**
124     * @brief Takes item from view.
125     *
126     * Item is not deleted.
127     *
128     * @param itemID item's ID
129     * @return ListItem
130     */
131     ListItem *takeListItemFromView(const QString &itemID);
132
133     /**
134     * @brief Returns ListItem with itemID.
135     *
136     * @param itemID item's ID
137     * @return ListItem
138     */
139     ListItem *listItem(const QString &itemID);
140
141 private:
142
143 protected slots:
144     /**
145     * @brief Slot for list item clicked.
146     *
147     * Toggles items selection state and emits listItemClicked signal.
148     */
149     virtual void listItemClicked(QListWidgetItem *item);
150
151 /*******************************************************************************
152  * DATA MEMBERS
153  ******************************************************************************/
154 private:
155     QHash<QString, ListItem *> m_listItems; ///< List of items in this view. Key = user ID
156
157     ListItem *m_previousItem;               ///< Previously selected item
158 };
159
160 #endif // LISTVIEW_H