Merge commit 'origin/locationlistview' into friendlist_filtering_text_field
[situare] / src / ui / friendlistpanel.cpp
index 5c0b033..99da131 100644 (file)
@@ -1,4 +1,4 @@
- /*
+/*
     Situare - A location system for Facebook
     Copyright (C) 2010  Ixonos Plc. Authors:
 
     along with Situare; if not, write to the Free Software
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
     USA.
- */
+*/
+
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QPushButton>
 
 #include "coordinates/geocoordinate.h"
 #include "friendlistitem.h"
@@ -50,6 +54,8 @@ FriendListPanel::FriendListPanel(QWidget *parent)
     m_friendListHeaderWidget->setLayout(filterLayout);
     m_friendListHeaderWidget->setAutoFillBackground(true);
 
+    m_routeButton = new QPushButton(tr("Route to friend"));
+
     QPalette labelPalette = m_friendListHeaderWidget->palette();
     labelPalette.setColor(QPalette::Background, Qt::black);
 
@@ -68,6 +74,7 @@ FriendListPanel::FriendListPanel(QWidget *parent)
     listViewLayout->setContentsMargins(PANEL_MARGIN_LEFT, 0, PANEL_MARGIN_RIGHT, 0);
     listViewLayout->addWidget(m_friendListView);
 
+    friendListPanelLayout->addWidget(m_routeButton);
     friendListPanelLayout->addWidget(m_friendListHeaderWidget);
     friendListPanelLayout->addLayout(listViewLayout);
 
@@ -77,8 +84,8 @@ FriendListPanel::FriendListPanel(QWidget *parent)
     connect(m_clearFilterButton, SIGNAL(clicked()),
             this, SLOT(clearFriendListFilter()));
 
-//    connect(this, SIGNAL(panelOpened()),
-//            this, SLOT(clearFriendListFilter()));
+    connect(m_routeButton, SIGNAL(clicked()),
+            this, SLOT(routeToSelectedFriend()));
 
     /// @todo remove old filterLayout when new panel are merged
 
@@ -189,6 +196,16 @@ void FriendListPanel::hideEvent(QHideEvent *event)
     clearFiltering();
 }
 
+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__;
@@ -229,9 +246,10 @@ void FriendListPanel::showFriendsInList(const QList<QString> &userIDs)
 
     m_friendListLabel->setText(tr("Selected: %1").arg(userIDs.count()));
 
-//    openPanel();
     m_friendListHeaderWidget->show();
     m_friendListView->filter(userIDs);
+
+    emit showPanelRequested(this);
 }
 
 void FriendListPanel::topmostWindowChanged(bool mainWindowIsTopmost)