Added MeetPeoplePanel class.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Fri, 20 Aug 2010 12:57:00 +0000 (15:57 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Fri, 20 Aug 2010 12:57:00 +0000 (15:57 +0300)
images.qrc
src/src.pro
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/meetpeoplepanel.cpp [new file with mode: 0644]
src/ui/meetpeoplepanel.h [new file with mode: 0644]

index 11917e1..31d7570 100644 (file)
@@ -57,5 +57,8 @@
         <file>res/images/walk_icon_gray.png</file>
         <file>res/images/zoom_in.png</file>
         <file>res/images/zoom_out.png</file>
+        <file>res/images/meet_people.png</file>
+        <file>res/images/chat_button.png</file>
+        <file>res/images/chat_button_s.png</file>
     </qresource>
 </RCC>
index 07de0ac..c55c66c 100644 (file)
@@ -80,7 +80,8 @@ SOURCES += main.cpp \
     ui/routingpanel.cpp \
     ui/routewaypointlistitem.cpp \
     ui/routewaypointlistview.cpp \
-    user/user.cpp
+    user/user.cpp \
+    ui/meetpeoplepanel.cpp
 HEADERS += application.h \
     common.h \
     coordinates/geocoordinate.h \
@@ -158,7 +159,8 @@ HEADERS += application.h \
     ui/routingpanel.h \
     ui/routewaypointlistitem.h \
     ui/routewaypointlistview.h \
-    user/user.h
+    user/user.h \
+    ui/meetpeoplepanel.h
 QT += network \
     webkit
 
index 18c5f85..1c33499 100644 (file)
@@ -42,6 +42,7 @@
 #include "indicatorbuttonpanel.h"
 #include "logindialog.h"
 #include "mapscale.h"
+#include "meetpeoplepanel.h"
 #include "panelcommon.h"
 #include "routingpanel.h"
 #include "tabbedpanel.h"
@@ -293,6 +294,17 @@ void MainWindow::buildMapScale()
             m_mapScale, SLOT(updateMapResolution(qreal)));
 }
 
+void MainWindow::buildMeetPeoplePanel()
+{
+    m_meetPeoplePanel = new MeetPeoplePanel(this);
+
+    connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
+            m_meetPeoplePanel, SLOT(populateNearbyFriendListView(QList<User*>&)));
+
+    connect(this, SIGNAL(friendImageReady(User*)),
+            m_meetPeoplePanel, SLOT(friendImageReady(User*)));
+}
+
 void MainWindow::buildOsmLicense()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -316,11 +328,13 @@ void MainWindow::buildPanels()
     buildUserInfoPanel();
     buildFriendListPanel();
     buildRoutingPanel();
+    buildMeetPeoplePanel();
 
     m_tabbedPanel = new TabbedPanel(this);
     m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png"));
     m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png"));
-    m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
+    //m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
+    m_tabbedPanel->addTab(m_meetPeoplePanel, QIcon(":/res/images/meet_people.png"));
 
     connect(m_mapView, SIGNAL(viewResized(QSize)),
             m_tabbedPanel, SLOT(resizePanel(QSize)));
index 6d7d554..48f3837 100644 (file)
@@ -47,6 +47,7 @@ class GeoCoordinate;
 class MapScale;
 class MapScene;
 class MapView;
+class MeetPeoplePanel;
 class Route;
 class RoutingPanel;
 class TabbedPanel;
@@ -238,6 +239,11 @@ private:
     void buildManualLocationCrosshair();
 
     /**
+     * @brief Build meet people panel and connect slots
+     */
+    void buildMeetPeoplePanel();
+
+    /**
      * @brief Build map and connect slots
      */
     void buildMap();
@@ -689,6 +695,7 @@ private:
     IndicatorButtonPanel *m_indicatorButtonPanel;     ///< Instance of direction indicator button
     MapScale *m_mapScale;                   ///< Instance of the map scale
     MapView *m_mapView;                     ///< Instance of the map view
+    MeetPeoplePanel *m_meetPeoplePanel;     ///< Instance of MeetPeoplePanel
     NetworkCookieJar *m_cookieJar;          ///< Placeholder for QNetworkCookies
     RoutingPanel *m_routingPanel;           ///< Instance of routing panel
     TabbedPanel *m_tabbedPanel;             ///< Widget for tabbed panels
diff --git a/src/ui/meetpeoplepanel.cpp b/src/ui/meetpeoplepanel.cpp
new file mode 100644 (file)
index 0000000..1dfeb2d
--- /dev/null
@@ -0,0 +1,72 @@
+#include <QDebug>
+#include <QVBoxLayout>
+
+#include "friendlistitem.h"
+#include "friendlistitemdelegate.h"
+#include "friendlistview.h"
+#include "imagebutton.h"
+#include "panelcommon.h"
+#include "user/user.h"
+
+#include "meetpeoplepanel.h"
+
+MeetPeoplePanel::MeetPeoplePanel(QWidget *parent)
+    : PanelBase(parent)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    QVBoxLayout *meetPeopleLayout = new QVBoxLayout;
+    meetPeopleLayout->setMargin(0);
+    meetPeopleLayout->setSpacing(0);
+    setLayout(meetPeopleLayout);
+
+    m_nearbyFriendListView = new FriendListView(this);
+    m_nearbyFriendListView->setItemDelegate(new FriendListItemDelegate(this));
+
+    QVBoxLayout *listViewLayout = new QVBoxLayout;
+    listViewLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
+                                       PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
+    listViewLayout->addWidget(m_nearbyFriendListView);
+    meetPeopleLayout->addLayout(listViewLayout);
+
+    ImageButton *searchPeopleButton = new ImageButton(0, ":/res/images/search.png",
+                                                             ":/res/images/search_s.png");
+    m_contextButtonList.append(searchPeopleButton);
+
+    m_chatButton = new ImageButton(0, ":/res/images/chat_button", ":/res/images/chat_button_s.png");
+    m_contextButtonList.append(m_chatButton);
+
+    connect(m_nearbyFriendListView, SIGNAL(listItemSelectionChanged()),
+            this, SLOT(setChatButtonDisabled()));
+}
+
+void MeetPeoplePanel::friendImageReady(User *user)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    FriendListItem *item =
+            static_cast<FriendListItem*>(m_nearbyFriendListView->listItem(user->userId()));
+
+    if (item)
+        item->setAvatarImage(user->profileImage());
+}
+
+void MeetPeoplePanel::populateNearbyFriendListView(QList<User *> &nearbyFriendList)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    foreach (User *nearbyFriend, nearbyFriendList) {
+        FriendListItem *item = new FriendListItem();
+        item->setUserData(nearbyFriend);
+        m_nearbyFriendListView->addListItem(nearbyFriend->userId(), item);
+    }
+
+    m_nearbyFriendListView->scrollToTop();
+}
+
+void MeetPeoplePanel::setChatButtonDisabled()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_chatButton->setDisabled(m_nearbyFriendListView->selectedItems().isEmpty());
+}
diff --git a/src/ui/meetpeoplepanel.h b/src/ui/meetpeoplepanel.h
new file mode 100644 (file)
index 0000000..29c55c9
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef MEETPEOPLEPANEL_H
+#define MEETPEOPLEPANEL_H
+
+#include "panelbase.h"
+
+class FriendListView;
+class ImageButton;
+class User;
+
+class MeetPeoplePanel : public PanelBase
+{
+    Q_OBJECT
+
+public:
+    /**
+     * @brief Default constructor
+     *
+     * @param parent
+     */
+    MeetPeoplePanel(QWidget *parent = 0);
+
+private slots:
+    /**
+     * @brief Slot to update friend item's image
+     *
+     * @param user Friend
+     */
+    void friendImageReady(User *user);
+
+    /**
+    * @brief Populates nearby friends list view.
+    *
+    * @param nearbyFriendList list of nearby friends
+    */
+    void populateNearbyFriendListView(QList<User *> &nearbyFriendList);
+
+    /**
+    * @brief Sets chat button disabled.
+    *
+    * Disabled if there isn't any list item selected.
+    */
+    void setChatButtonDisabled();
+
+private:
+    ImageButton *m_chatButton;              ///< Chat button
+
+    FriendListView *m_nearbyFriendListView; ///< Nearby friend list view
+};
+
+#endif // MEETPEOPLEPANEL_H