00001 /* 00002 Situare - A location system for Facebook 00003 Copyright (C) 2010 Ixonos Plc. Authors: 00004 00005 Jussi Laitinen - jussi.laitinen@ixonos.com 00006 00007 Situare is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU General Public License 00009 version 2 as published by the Free Software Foundation. 00010 00011 Situare is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with Situare; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00019 USA. 00020 */ 00021 00022 #ifndef LISTVIEW_H 00023 #define LISTVIEW_H 00024 00025 #include <QHash> 00026 #include <QListWidget> 00027 00028 class GeoCoordinate; 00029 class ListItem; 00030 00039 class ListView : public QListWidget 00040 { 00041 Q_OBJECT 00042 00043 public: 00049 ListView(QWidget *parent = 0); 00050 00056 ~ListView(); 00057 00058 /****************************************************************************** 00059 * MEMBER FUNCTIONS AND SLOTS 00060 ******************************************************************************/ 00061 public: 00068 void addListItem(const QString &key, ListItem *item); 00069 00075 void addListItemToView(ListItem *item); 00076 00084 void clearUnused(const QStringList &itemIDs); 00085 00091 void clearFilter(); 00092 00096 void clearItemSelection(); 00097 00103 void clearList(); 00104 00111 bool contains(const QString &userID); 00112 00120 void filter(const QList<QString> &itemIDs); 00121 00129 void filter(const QString &pattern); 00130 00139 ListItem *takeListItemFromView(const QString &itemID); 00140 00147 ListItem *listItem(const QString &itemID); 00148 00155 ListItem *listItemAt(int index); 00156 00163 QHash<QString, ListItem *> listItems() const; 00164 00171 void prependListItem(const QString &key, ListItem *item); 00172 00176 void removeLastItem(); 00177 00183 ListItem *selectedItem(); 00184 00190 void setSelectedItem(ListItem *item); 00191 00192 protected slots: 00200 virtual bool listItemClicked(ListItem *clickedItem); 00201 00202 private slots: 00209 void listItemClicked(QListWidgetItem *item); 00210 00211 /****************************************************************************** 00212 * SIGNALS 00213 ******************************************************************************/ 00214 signals: 00218 void listItemSelectionChanged(); 00219 00220 /******************************************************************************* 00221 * DATA MEMBERS 00222 ******************************************************************************/ 00223 private: 00224 QHash<QString, ListItem *> m_listItems; 00225 00226 QList<QString> m_filteredItemIDs; 00227 00228 ListItem *m_currentItem; 00229 }; 00230 00231 #endif // LISTVIEW_H