Review & fixes
[situare] / src / ui / friendlistpanel.h
index 502dbdd..49d0ccb 100644 (file)
 #ifndef FRIENDLISTPANEL_H
 #define FRIENDLISTPANEL_H
 
-#include <QtGui>
+#include <QWidget>
 
 class QLabel;
-class QWidget;
+class QLineEdit;
+class QPushButton;
 
 class FriendListItemDelegate;
 class GeoCoordinate;
@@ -64,7 +65,7 @@ protected:
     /**
     * @brief Re-implemented from QWidget::hideEvent()
     *
-    * Calls updateKeyboardGrabbing().
+    * Calls updateKeyboardGrabbing() and clearFriendGroupFiltering().
     *
     * @param event
     */
@@ -99,7 +100,7 @@ public slots:
 
 private:
     /**
-    * @brief Set visibility for filtering related UI elements
+    * @brief Set visibility for filtering text field and clearing button
     *
     * @param visible True if items should be visible, false if not
     */
@@ -108,75 +109,124 @@ private:
     /**
     * @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.
+    * Keyboard is grabbed when MainWindow it the topmost window, panel tab is open and
+    * FriendListPanel is visible. Releasing is done if the MainWindow is not the topmost window
+    * or panel tab is not open or FriendListPanel is invisible.
     */
     void updateKeyboardGrabbing();
 
 private slots:
     /**
-     * @brief Slot to clear friend list filter.
-     */
-    void clearFriendListFilter();
+    * @brief Called when any of the panel tabs is closed
+    *
+    * Does call clearFriendGroupFiltering().
+    *
+    * Calls updateKeyboardGrabbing() for releasing the grabbing when FriendListPanel is closed, not
+    * changed to other panel. In this case the hideEvent() is not triggered.
+    */
+    void anyPanelClosed();
 
     /**
-    * @brief Slot for clearing the friend list filtering.
+    * @brief Called when any of the panel tabs is opened
+    *
+    * Calls updateKeyboardGrabbing() for grabbing the keyboard when FriendListPanel is closed and
+    * is the last selected tab. In this case the showEvent() is not triggered.
+    */
+    void anyPanelOpened();
+
+    /**
+    * @brief Slot for clearing the filtering
+    *
+    * Clears friend group (or single friend) filtering and calls clearTextFiltering().
     */
     void clearFiltering();
 
     /**
-    * @brief Set filtering UI elements visibility based on the filtering text value
+    * @brief Slot for clearing the text based filtering.
+    *
+    * Does clear only the text based filtering. Friend group based filtering is not affected.
+    */
+    void clearTextFiltering();
+
+    /**
+    * @brief Updates the filtering when filtering text value is changed
     *
     * Filtering UI elements are invoked when the text becomes not empty and hidden when text
     * becomes empty.
     *
+    * Sets the new filtering text.
+    *
     * @param text New text value
     */
     void filterTextChanged(const QString &text);
 
     /**
-    * @brief Called when topmost window is changed
+    * @brief Routes to selected friend.
     *
-    * Does set m_mainWindowIsTopmost and calls updateKeyboardGrabbing()
-    *
-    * @param mainWindowIsTopmost True if MainWindow is the topmost one
+    * Emits routeToFriend if friend is selected from list.
     */
-    void topmostWindowChanged(bool mainWindowIsTopmost);
+    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:
     bool m_mainWindowIsTopmost;         ///< Is the MainWindow the topmost one
+    bool m_somePanelIsOpen;             ///< Is any panel tab open
 
     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
 
     FriendListView *m_friendListView;   ///< Friend list view
-
 };
 
 #endif // FRIENDLISTPANEL_H