Added show contact button to FriendListPanel. contact_dialog
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 25 Aug 2010 13:56:56 +0000 (16:56 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 25 Aug 2010 13:56:56 +0000 (16:56 +0300)
src/ui/friendlistpanel.cpp
src/ui/friendlistpanel.h

index aa3a3aa..f99bfa4 100644 (file)
@@ -65,6 +65,9 @@ FriendListPanel::FriendListPanel(QWidget *parent)
     m_routeButton = new QPushButton(tr("Route to friend"));
     m_routeButton->setDisabled(true);
 
+    m_showContactButton = new QPushButton(tr("Show contact"));
+    m_showContactButton->setDisabled(true);
+
     QPalette labelPalette = m_friendListHeaderWidget->palette();
     labelPalette.setColor(QPalette::Background, Qt::black);
 
@@ -84,6 +87,7 @@ FriendListPanel::FriendListPanel(QWidget *parent)
                                        PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
     listViewLayout->addWidget(m_friendListView);
 
+    friendListPanelLayout->addWidget(m_showContactButton);
     friendListPanelLayout->addWidget(m_routeButton);
     friendListPanelLayout->addWidget(m_friendListHeaderWidget);
     friendListPanelLayout->addLayout(listViewLayout);
@@ -98,7 +102,7 @@ FriendListPanel::FriendListPanel(QWidget *parent)
             this, SLOT(routeToSelectedFriend()));
 
     connect(m_friendListView, SIGNAL(listItemSelectionChanged()),
-            this, SLOT(setRouteButtonDisabled()));
+            this, SLOT(setSelectionButtonsDisabled()));
 
     /// @todo remove old filterLayout when new panel are merged
 
@@ -130,6 +134,9 @@ FriendListPanel::FriendListPanel(QWidget *parent)
 
     connect(qApp, SIGNAL(topmostWindowChanged(bool)),
             this, SLOT(topmostWindowChanged(bool)));
+
+    connect(m_showContactButton, SIGNAL(clicked()),
+            this, SLOT(requestSelectedFriendContactDialog()));
 }
 
 void FriendListPanel::anyPanelClosed()
@@ -142,7 +149,7 @@ void FriendListPanel::anyPanelClosed()
     clearFiltering();
 
     m_friendListView->clearItemSelection();
-    setRouteButtonDisabled();
+    setSelectionButtonsDisabled();
 }
 
 void FriendListPanel::anyPanelOpened()
@@ -229,18 +236,15 @@ void FriendListPanel::hideEvent(QHideEvent *event)
     clearFiltering();
 
     m_friendListView->clearItemSelection();
-    setRouteButtonDisabled();
+    setSelectionButtonsDisabled();
 }
 
-void FriendListPanel::routeToSelectedFriend()
+void FriendListPanel::requestSelectedFriendContactDialog()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
     FriendListItem *item = dynamic_cast<FriendListItem *>(m_friendListView->selectedItem());
 
-//    if (item)
-//        emit routeToFriend(item->coordinates());
-
     if (item) {
         QString facebookId = item->facebookId();
         if (!facebookId.isEmpty())
@@ -248,6 +252,16 @@ void FriendListPanel::routeToSelectedFriend()
     }
 }
 
+void FriendListPanel::routeToSelectedFriend()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    FriendListItem *item = dynamic_cast<FriendListItem *>(m_friendListView->selectedItem());
+
+    if (item)
+        emit routeToFriend(item->coordinates());
+}
+
 void FriendListPanel::setFilteringLayoutVisibility(bool visible)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -256,6 +270,16 @@ void FriendListPanel::setFilteringLayoutVisibility(bool visible)
     m_filterClearButton->setVisible(visible);
 }
 
+void FriendListPanel::setSelectionButtonsDisabled()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    bool isAnyItemSelected = m_friendListView->selectedItems().isEmpty();
+
+    m_routeButton->setDisabled(isAnyItemSelected);
+    m_showContactButton->setDisabled(isAnyItemSelected);
+}
+
 void FriendListPanel::updateKeyboardGrabbing()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -269,13 +293,6 @@ void FriendListPanel::updateKeyboardGrabbing()
     }
 }
 
-void FriendListPanel::setRouteButtonDisabled()
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    m_routeButton->setDisabled(m_friendListView->selectedItems().isEmpty());
-}
-
 void FriendListPanel::showEvent(QShowEvent *event)
 {
     qDebug() << __PRETTY_FUNCTION__;
index 280e22a..dfa270a 100644 (file)
@@ -169,11 +169,16 @@ private slots:
     void routeToSelectedFriend();
 
     /**
+    * @brief Requests selected friend's contact dialog.
+    */
+    void requestSelectedFriendContactDialog();
+
+    /**
     * @brief Sets route button disabled.
     *
     * Disabled if there isn't any list item selected.
     */
-    void setRouteButtonDisabled();
+    void setSelectionButtonsDisabled();
 
     /**
      * @brief Slot to show friends in list.
@@ -238,6 +243,7 @@ private:
     QPushButton *m_clearFilterButton;   ///< Button to clear list filtering
     QPushButton *m_filterClearButton;   ///< Button for clearing the filtering
     QPushButton *m_routeButton;         ///< Button to route to friend
+    QPushButton *m_showContactButton;   ///< Button to show contact dialog
 
     QWidget *m_friendListHeaderWidget;  ///< Friend list header widget