Added missing includes
[situare] / src / ui / friendlistpanel.h
index a10a6b5..685e73f 100644 (file)
@@ -5,6 +5,8 @@
         Kaj Wallin - kaj.wallin@ixonos.com
         Henri Lampela - henri.lampela@ixonos.com
         Pekka Nissinen - pekka.nissinen@ixonos.com
+        Jussi Laitinen - jussi.laitinen@ixonos.com
+        Sami Rämö - sami.ramo@ixonos.com
 
     Situare is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License
 #include <QWidget>
 
 class QLabel;
+class QLineEdit;
 class QPushButton;
 
 class FriendListItemDelegate;
 class GeoCoordinate;
-class ListView;
+class FriendListView;
 class User;
 
 /**
@@ -40,8 +43,8 @@ class User;
  * @author Kaj Wallin - kaj.wallin (at) ixonos.com
  * @author Henri Lampela - henri.lampela (at) ixonos.com
  * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
- *
- * @class FriendListPanel friendlistpanel.h "ui/friendlistpanel.h"
+ * @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
+ * @author Sami Rämö - sami.ramo (at) ixonos.com
  */
 class FriendListPanel : public QWidget
 {
@@ -56,6 +59,28 @@ public:
     FriendListPanel(QWidget *parent = 0);
 
 /*******************************************************************************
+ * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
+ ******************************************************************************/
+protected:
+    /**
+    * @brief Re-implemented from QWidget::hideEvent()
+    *
+    * Calls updateKeyboardGrabbing().
+    *
+    * @param event
+    */
+    void hideEvent(QHideEvent *event);
+
+    /**
+    * @brief Re-implemented from QWidget::showEvent()
+    *
+    * Calls updateKeyboardGrabbing().
+    *
+    * @param event
+    */
+    void showEvent(QShowEvent *event);
+
+/*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
 public slots:
@@ -73,43 +98,110 @@ public slots:
      */
     void friendInfoReceived(QList<User *> &friendList);
 
+private:
+    /**
+    * @brief Set visibility for filtering related UI elements
+    *
+    * @param visible True if items should be visible, false if not
+    */
+    void setFilteringLayoutVisibility(bool visible);
+
+    /**
+    * @brief Takes care of grabbing and releasing the keyboard when required
+    *
+    * Keyboard is grabbed when MainWindow it the topmost window and FriendListPanel is visible.
+    * Releasing is done if the MainWindow is not the topmost window and/or FriendListPanel
+    * is invisible.
+    */
+    void updateKeyboardGrabbing();
+
 private slots:
     /**
-     * @brief Slot to clear friend list filter.
+     * @brief Slot to clear friend list filter
      */
     void clearFriendListFilter();
 
     /**
+    * @brief Slot for clearing the friend list filtering.
+    */
+    void clearFiltering();
+
+    /**
+    * @brief Set filtering UI elements visibility based on the filtering text value
+    *
+    * Filtering UI elements are invoked when the text becomes not empty and hidden when text
+    * becomes empty.
+    *
+    * @param text New text value
+    */
+    void filterTextChanged(const QString &text);
+
+    /**
+    * @brief Routes to selected friend.
+    *
+    * Emits routeToFriend if friend is selected from list.
+    */
+    void routeToSelectedFriend();
+
+    /**
      * @brief Slot to show friends in list.
      *
-     * Shows only friends that are on userIDs list.
+     * Shows only friends that are on userIDs list
      * @param userIDs list of user ID's
      */
     void showFriendsInList(const QList<QString> &userIDs);
 
+    /**
+    * @brief Called when topmost window is changed
+    *
+    * Does set m_mainWindowIsTopmost and calls updateKeyboardGrabbing()
+    *
+    * @param mainWindowIsTopmost True if MainWindow is the topmost one
+    */
+    void topmostWindowChanged(bool mainWindowIsTopmost);
+
 /*******************************************************************************
  * SIGNALS
  ******************************************************************************/
 signals:
     /**
-     * @brief Signal for friend finding.
+     * @brief Signal for friend finding
      *
      * @param coordinates Target coordinate
      */
     void findFriend(const GeoCoordinate &coordinates);
 
+    /**
+    * @brief Signal for routing to friend.
+    *
+    * @param coordinates friend's geo coordinates
+    */
+    void routeToFriend(const GeoCoordinate &coordinates);
+
+    /**
+     * @brief Signal for requesting a panel to be opened
+     *
+     * @param widget Pointer to the widget that emitted the signal
+     */
+    void showPanelRequested(QWidget *widget);
+
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
 private:
-    QWidget *m_friendListHeaderWidget;  ///< Friend list header widget
+    bool m_mainWindowIsTopmost;         ///< Is the MainWindow the topmost one
 
     QLabel *m_friendListLabel;          ///< Friend list label
 
+    QLineEdit *m_filterField;           ///< Text field for the filter text
+
     QPushButton *m_clearFilterButton;   ///< Button to clear list filtering
+    QPushButton *m_filterClearButton;   ///< Button for clearing the filtering
+    QPushButton *m_routeButton;         ///< Button to route to friend
+
+    QWidget *m_friendListHeaderWidget;  ///< Friend list header widget
 
-    ListView *m_friendListView;                         ///< Friend list view
-    FriendListItemDelegate *m_friendListItemDelegate;   ///< Friend list item delegate
+    FriendListView *m_friendListView;   ///< Friend list view
 };
 
 #endif // FRIENDLISTPANEL_H