Merge branch 'master' into context_driven_buttons, review
[situare] / src / ui / friendlistpanel.cpp
index 4b62e3f..99a2585 100644 (file)
@@ -6,6 +6,7 @@
         Henri Lampela - henri.lampela@ixonos.com
         Pekka Nissinen - pekka.nissinen@ixonos.com
         Sami Rämö - sami.ramo@ixonos.com
+        Jussi Laitinen - jussi.laitinen@ixonos.com
 
     Situare is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License
@@ -83,7 +84,7 @@ FriendListPanel::FriendListPanel(QWidget *parent)
             this, SIGNAL(findFriend(GeoCoordinate)));
 
     connect(m_friendListView, SIGNAL(listItemSelectionChanged()),
-            this, SLOT(setRouteButtonDisabled()));
+            this, SLOT(onListItemSelectionChanged()));
 
     // --- FOOTER, TEXT BASED FILTERING ---
     QHBoxLayout *footerLayout = new QHBoxLayout();
@@ -119,20 +120,28 @@ FriendListPanel::FriendListPanel(QWidget *parent)
 
     // --- CONTEXT BUTTONS ---
     m_routeButton = new ImageButton(":res/images/route_to_friend.png",
-                                    ":res/images/route_to_friend_s.png", "", this);
-    m_routeButton->setDisabled(true);
+                                    ":res/images/route_to_friend_s.png",
+                                    ":res/images/route_to_friend_d.png", this);
     connect(m_routeButton, SIGNAL(clicked()),
             this, SLOT(routeToSelectedFriend()));
 
+    m_showContactButton = new ImageButton(":res/images/contact_btn.png",
+                                          ":res/images/contact_btn_s.png",
+                                          ":res/images/contact_btn_d.png", this);
+    connect(m_showContactButton, SIGNAL(clicked()),
+            this, SLOT(requestSelectedFriendContactDialog()));
+
     m_clearGroupFilteringButton = new ImageButton(":res/images/filtered.png",
-                                                  ":res/images/filtered_s.png", "", this);
+                                                  ":res/images/filtered_s.png",
+                                                  ":res/images/filtered_d.png", this);
     m_clearGroupFilteringButton->setCheckable(true);
     m_clearGroupFilteringButton->setDisabled(true);
     connect(m_clearGroupFilteringButton, SIGNAL(clicked()),
             this, SLOT(clearFiltering()));
 
-    m_contextButtonLayout->addWidget(m_routeButton);
-    m_contextButtonLayout->addWidget(m_clearGroupFilteringButton);
+    m_itemButtonsLayout->addWidget(m_routeButton);
+    m_itemButtonsLayout->addWidget(m_showContactButton);
+    m_genericButtonsLayout->addWidget(m_clearGroupFilteringButton);
 }
 
 void FriendListPanel::anyPanelClosed()
@@ -145,7 +154,6 @@ void FriendListPanel::anyPanelClosed()
     clearFiltering();
 
     m_friendListView->clearItemSelection();
-    setRouteButtonDisabled();
 }
 
 void FriendListPanel::anyPanelOpened()
@@ -234,7 +242,19 @@ void FriendListPanel::hideEvent(QHideEvent *event)
     clearFiltering();
 
     m_friendListView->clearItemSelection();
-    setRouteButtonDisabled();
+}
+
+void FriendListPanel::requestSelectedFriendContactDialog()
+{
+     qDebug() << __PRETTY_FUNCTION__;
+
+     FriendListItem *item = dynamic_cast<FriendListItem *>(m_friendListView->selectedItem());
+
+     if (item) {
+         QString facebookId = item->facebookId();
+         if (!facebookId.isEmpty())
+             emit requestContactDialog(facebookId);
+     }
 }
 
 void FriendListPanel::routeToSelectedFriend()
@@ -268,13 +288,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__;
@@ -297,7 +310,7 @@ void FriendListPanel::showFriendsInList(const QList<QString> &userIDs)
 
     clearTextFiltering();
 
-    emit showPanelRequested(this);
+    emit openPanelRequested(this);
 }
 
 void FriendListPanel::topmostWindowChanged(bool mainWindowIsTopmost)