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,
25 #include <QListWidget>
31 * @brief View for ListItems.
33 * ListView is used to show ListItems in list view. Items can be added, removed or
36 * @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
38 class ListView : public QListWidget
46 * @param parent QWidget
48 ListView(QWidget *parent = 0);
53 * Calls ListView::clearList().
57 /******************************************************************************
58 * MEMBER FUNCTIONS AND SLOTS
59 ******************************************************************************/
62 * @brief Add item to view and item list.
65 * @param item item to add to view and list
67 void addListItem(const QString &key, ListItem *item);
70 * @brief Adds item to view.
72 * @param item FriendListItem
74 void addListItemToView(ListItem *item);
77 * @brief Clear unused items from view.
79 * Clears items which are not in item ID's list from the view and items list.
81 * @param itemIDs list of item ID's to keep in list view
83 void clearUnused(const QStringList &itemIDs);
86 * @brief Clears filtering from list.
88 * Clears m_filteredItemIDs and shows all items.
92 void clearItemSelection();
97 * Items are removed from view and item list.
102 * @brief Checks if view contains item with userID.
104 * @param userID user's ID
105 * @return true if view contains item, false otherwise
107 bool contains(const QString &userID);
110 * @brief Filters list by item IDs.
112 * Hide all items that are not in the itemIDs list.
114 * @param itemIDs item ID's for items that are shown
116 void filter(const QList<QString> &itemIDs);
119 * @brief Filters list by text pattern.
121 * Filtering uses item names. If filtering by item IDs is on, filters only those items.
123 * @param pattern text pattern to filter
125 void filter(const QString &pattern);
128 * @brief Takes item from view.
130 * Item is not deleted.
132 * @param itemID item's ID
135 ListItem *takeListItemFromView(const QString &itemID);
138 * @brief Returns ListItem with itemID.
140 * @param itemID item's ID
143 ListItem *listItem(const QString &itemID);
146 * @brief Returns ListItem by index.
148 * @param index item's index
151 ListItem *listItemAt(int index);
154 * @brief Returns selected ListItem.
156 * @return ListItem if there is selected, 0 otherwise
158 ListItem *selectedItem();
161 * @brief Sets selected item.
163 * @param item ListItem to select
165 void setSelectedItem(ListItem *item);
169 * @brief Slot for list item clicked.
171 * Toggles items selection state and emits listItemClicked signal.
172 * @return true if item was selected, false otherwise
174 virtual bool listItemClicked(ListItem *item);
178 * @brief Slot for list item clicked.
180 * Calls listItemClicked(ListItem *item)
182 void listItemClicked(QListWidgetItem *item);
184 /*******************************************************************************
186 ******************************************************************************/
188 QHash<QString, ListItem *> m_listItems; ///< List of items in this view. Key = user ID
190 QList<QString> m_filteredItemIDs; ///< List of filtered item IDs
192 ListItem *m_previousItem; ///< Previously selected item