Added routing feature to friend and location list.
[situare] / src / ui / listview.h
index 0b64787..650175e 100644 (file)
@@ -32,6 +32,8 @@ class ListItem;
 *
 * ListView is used to show ListItems in list view. Items can be added, removed or
 * filtered.
+*
+* @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
 */
 class ListView : public QListWidget
 {
@@ -45,6 +47,13 @@ public:
     */
     ListView(QWidget *parent = 0);
 
+    /**
+    * @brief Destructor.
+    *
+    * Calls ListView::clearList().
+    */
+    ~ListView();
+
 /******************************************************************************
 * MEMBER FUNCTIONS AND SLOTS
 ******************************************************************************/
@@ -67,11 +76,11 @@ public:
     /**
     * @brief Clear unused items from view.
     *
-    * Clears items which are not in user ID's list from the view and items list.
+    * Clears items which are not in item ID's list from the view and items list.
     *
-    * @param userIDs list of new user ID's.
+    * @param itemIDs list of item ID's to keep in list view
     */
-    void clearUnused(const QStringList &userIDs);
+    void clearUnused(const QStringList &itemIDs);
 
     /**
     * @brief Clears filtering from list.
@@ -96,31 +105,62 @@ public:
     bool contains(const QString &userID);
 
     /**
-    * @brief Sets filter to list.
+    * @brief Filters list by item IDs.
     *
-    * Hide all items that are not in the userIDs list.
+    * Hide all items that are not in the itemIDs list.
     *
-    * @param userIDs user ID's to items that are shown
+    * @param itemIDs item ID's for items that are shown
     */
-    void filter(const QList<QString> &userIDs);
+    void filter(const QList<QString> &itemIDs);
+
+    /**
+    * @brief Filters list by text pattern.
+    *
+    * Filtering uses item names.
+    *
+    * @param pattern text pattern to filter
+    */
+    void filter(const QString &pattern);
 
     /**
     * @brief Takes item from view.
     *
     * Item is not deleted.
     *
-    * @param userID user's ID
+    * @param itemID item's ID
     * @return ListItem
     */
-    ListItem *takeListItemFromView(const QString &userID);
+    ListItem *takeListItemFromView(const QString &itemID);
 
     /**
-    * @brief Returns ListItem with userID.
+    * @brief Returns ListItem with itemID.
     *
-    * @param userID user's ID
+    * @param itemID item's ID
+    * @return ListItem
+    */
+    ListItem *listItem(const QString &itemID);
+
+    /**
+    * @brief Returns ListItem by index.
+    *
+    * @param index item's index
     * @return ListItem
     */
-    ListItem *listItem(const QString &userID);
+    ListItem *listItemAt(int index);
+
+    /**
+    * @brief Returns selected ListItem.
+    *
+    * @return ListItem if there is selected, 0 otherwise
+    */
+    ListItem *selectedItem();
+
+    /**
+    * @brief Sets selected item.
+    *
+    * @param item ListItem to select
+    */
+    void setSelectedItem(ListItem *item);
 
 protected slots:
     /**
@@ -128,25 +168,24 @@ protected slots:
     *
     * Toggles items selection state and emits listItemClicked signal.
     */
-    virtual void listItemClicked(QListWidgetItem *item);
+    virtual void listItemClicked(ListItem *item);
 
-/******************************************************************************
-* SIGNALS
-******************************************************************************/
-signals:
+private slots:
     /**
-    * @brief Signal is emitted when list item is clicked.
+    * @brief Slot for list item clicked.
     *
-    * @param coordinates item's coordinates
+    * Toggles items selection state and emits listItemClicked signal.
     */
-    void listItemClicked(const GeoCoordinate &coordinates);
+    void listItemClicked(QListWidgetItem *item);
+
 
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
 private:
-    ListItem *m_previousItem;               ///< Previously selected item
     QHash<QString, ListItem *> m_listItems; ///< List of items in this view. Key = user ID
+
+    ListItem *m_previousItem;               ///< Previously selected item
 };
 
 #endif // LISTVIEW_H