Added notification panel.
[situare] / src / ui / meetpeoplepanel.cpp
1 #include <QDebug>
2 #include <QVBoxLayout>
3
4 #include "headerlistitemdelegate.h"
5 #include "friendlistitem.h"
6 #include "friendlistitemdelegate.h"
7 #include "friendlistview.h"
8 #include "imagebutton.h"
9 #include "panelcommon.h"
10 #include "user/user.h"
11
12 #include "meetpeoplepanel.h"
13
14 MeetPeoplePanel::MeetPeoplePanel(QWidget *parent)
15     : PanelBase(parent)
16 {
17     qDebug() << __PRETTY_FUNCTION__;
18
19     QVBoxLayout *meetPeopleLayout = new QVBoxLayout;
20     meetPeopleLayout->setMargin(0);
21     meetPeopleLayout->setSpacing(0);
22     setLayout(meetPeopleLayout);
23
24     m_interestingPeopleListView = new FriendListView(this);
25     m_interestingPeopleListView->setItemDelegate(new FriendListItemDelegate(this));
26     connect(m_interestingPeopleListView, SIGNAL(listItemSelectionChanged()),
27             this, SLOT(onListItemSelectionChanged()));
28
29     QVBoxLayout *listViewLayout = new QVBoxLayout;
30     listViewLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
31                                        PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
32     listViewLayout->addWidget(m_interestingPeopleListView);
33     meetPeopleLayout->addLayout(listViewLayout);
34
35     ImageButton *refreshInterestingPeopleButton = new ImageButton(":/res/images/refresh.png",
36                                                                   ":/res/images/refresh_s.png",
37                                                                   "", this);
38     connect(refreshInterestingPeopleButton, SIGNAL(clicked()),
39             this, SIGNAL(requestInterestingPeople()));
40
41     ImageButton *searchPeopleButton = new ImageButton(":/res/images/search.png",
42                                                       ":/res/images/search_s.png", "", this);
43     connect(searchPeopleButton, SIGNAL(clicked()),
44             this, SIGNAL(requestInterestingPeopleSearch()));
45
46     ImageButton *messageButton = new ImageButton(":/res/images/chat_btn.png",
47                                                  ":/res/images/chat_btn_s.png",
48                                                  ":/res/images/chat_btn_d.png", this);
49     connect(messageButton, SIGNAL(clicked()),
50             this, SLOT(openMessageDialog()));
51
52     m_genericButtonsLayout->addWidget(refreshInterestingPeopleButton);
53     m_genericButtonsLayout->addWidget(searchPeopleButton);
54     m_itemButtonsLayout->addWidget(messageButton);
55 }
56
57 void MeetPeoplePanel::personImageReady(User *person)
58 {
59     qDebug() << __PRETTY_FUNCTION__;
60
61     FriendListItem *personItem =
62             static_cast<FriendListItem*>(m_interestingPeopleListView->listItem(person->userId()));
63
64     if (personItem)
65         personItem->setAvatarImage(person->profileImage());
66 }
67
68 void MeetPeoplePanel::populateInterestingPeopleListView(QList<User *> &interestingPeople)
69 {
70     qDebug() << __PRETTY_FUNCTION__ ;
71
72     m_interestingPeopleListView->clearList();
73
74     foreach (User *interestingPerson, interestingPeople) {
75         FriendListItem *item = new FriendListItem();
76         item->setUserData(interestingPerson);
77         m_interestingPeopleListView->addListItem(interestingPerson->userId(), item);
78     }
79
80     m_interestingPeopleListView->scrollToTop();
81 }