2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Jussi Laitinen - jussi.laitinen@ixonos.com
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.
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.
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,
26 #include <QListWidget>
32 * @brief View for ListItems.
34 * ListView is used to show ListItems in list view. Items can be added, removed or
37 * @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
39 class ListView : public QListWidget
47 * @param parent QWidget
49 ListView(QWidget *parent = 0);
54 * Calls ListView::clearList().
58 /******************************************************************************
59 * MEMBER FUNCTIONS AND SLOTS
60 ******************************************************************************/
63 * @brief Add item to view and item list.
66 * @param item item to add to view and list
68 void addListItem(const QString &key, ListItem *item);
71 * @brief Adds item to view.
73 * @param item FriendListItem
75 void addListItemToView(ListItem *item);
78 * @brief Clear unused items from view.
80 * Clears items which are not in item ID's list from the view and items list.
82 * @param itemIDs list of item ID's to keep in list view
84 void clearUnused(const QStringList &itemIDs);
87 * @brief Clears filtering from list.
89 * Clears m_filteredItemIDs and shows all items.
94 * @brief Deselects all selected items.
96 void clearItemSelection();
101 * Items are removed from view and item list.
106 * @brief Checks if view contains item with userID.
108 * @param userID user's ID
109 * @return true if view contains item, false otherwise
111 bool contains(const QString &userID);
114 * @brief Filters list by item IDs.
116 * Hide all items that are not in the itemIDs list.
118 * @param itemIDs item ID's for items that are shown
120 void filter(const QList<QString> &itemIDs);
123 * @brief Filters list by text pattern.
125 * Filtering uses item names. If filtering by item IDs is on, filters only those items.
127 * @param pattern text pattern to filter
129 void filter(const QString &pattern);
132 * @brief Takes item from view.
134 * Item is not deleted.
136 * @param itemID item's ID
139 ListItem *takeListItemFromView(const QString &itemID);
142 * @brief Returns ListItem with itemID.
144 * @param itemID item's ID
147 ListItem *listItem(const QString &itemID);
150 * @brief Returns ListItem by index.
152 * @param index item's index
155 ListItem *listItemAt(int index);
158 * @brief Returns all list items.
161 * @return list of ListItems
163 QHash<QString, ListItem *> listItems() const;
166 * @brief Prepends item to view and item list.
169 * @param item item to prepend to view and list
171 void prependListItem(const QString &key, ListItem *item);
174 * @brief Removes last ListItem in list.
176 void removeLastItem();
179 * @brief Returns selected ListItem.
181 * @return ListItem if there is selected, 0 otherwise
183 ListItem *selectedItem();
186 * @brief Sets selected item.
188 * @param item ListItem to select
190 void setSelectedItem(ListItem *item);
194 * @brief Slot for list item clicked.
196 * Toggles items selection state and emits listItemClicked signal.
197 * @param clickedItem clicked ListItem
198 * @return true if item was selected, false otherwise
200 virtual bool listItemClicked(ListItem *clickedItem);
204 * @brief Slot for list item clicked.
206 * Calls listItemClicked(ListItem *item)
207 * @param item QListWidgetItem
209 void listItemClicked(QListWidgetItem *item);
211 /******************************************************************************
213 ******************************************************************************/
216 * @brief Emitted when list item selection changes.
218 void listItemSelectionChanged();
220 /*******************************************************************************
222 ******************************************************************************/
224 QHash<QString, ListItem *> m_listItems; ///< List of items in this view. Key = user ID
226 QList<QString> m_filteredItemIDs; ///< List of filtered item IDs
228 ListItem *m_currentItem; ///< Previously selected item