New notification panel.
[situare] / src / ui / meetpeoplepanel.cpp
1 #include <QDebug>
2 #include <QVBoxLayout>
3
4 #include "headerlistitemdelegate.h"
5 #include "personlistitem.h"
6 #include "extendedlistitemdelegate.h"
7 #include "personlistview.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_personListView = new PersonListView(this);
25     m_personListView->setItemDelegate(new ExtendedListItemDelegate(this));
26     connect(m_personListView, SIGNAL(listItemSelectionChanged()),
27             this, SLOT(onListItemSelectionChanged()));
28     connect(m_personListView, SIGNAL(personItemClicked(GeoCoordinate)),
29             this, SIGNAL(findPerson(GeoCoordinate)));
30
31     QVBoxLayout *listViewLayout = new QVBoxLayout;
32     listViewLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
33                                        PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
34     listViewLayout->addWidget(m_personListView);
35     meetPeopleLayout->addLayout(listViewLayout);
36
37     ImageButton *refreshInterestingPeopleButton = new ImageButton(":/res/images/refresh.png",
38                                                                   ":/res/images/refresh_s.png",
39                                                                   "", this);
40     connect(refreshInterestingPeopleButton, SIGNAL(clicked()),
41             this, SIGNAL(requestInterestingPeople()));
42
43     ImageButton *searchPeopleButton = new ImageButton(":/res/images/search.png",
44                                                       ":/res/images/search_s.png", "", this);
45     connect(searchPeopleButton, SIGNAL(clicked()),
46             this, SIGNAL(requestInterestingPeopleSearch()));
47
48     ImageButton *messageButton = new ImageButton(":/res/images/chat_btn.png",
49                                                  ":/res/images/chat_btn_s.png",
50                                                  ":/res/images/chat_btn_d.png", this);
51     connect(messageButton, SIGNAL(clicked()),
52             this, SLOT(openMessageDialog()));
53
54     m_genericButtonsLayout->addWidget(refreshInterestingPeopleButton);
55     m_genericButtonsLayout->addWidget(searchPeopleButton);
56     m_itemButtonsLayout->addWidget(messageButton);
57 }
58
59 void MeetPeoplePanel::setImage(const QString &id, const QPixmap &image)
60 {
61     qDebug() << __PRETTY_FUNCTION__;
62
63     PersonListItem *personItem = dynamic_cast<PersonListItem*>(m_personListView->listItem(id));
64     if (personItem)
65         personItem->setAvatarImage(image);
66 }
67
68 void MeetPeoplePanel::populateInterestingPeopleListView(QList<User> &interestingPeople)
69 {
70     qDebug() << __PRETTY_FUNCTION__ ;
71
72     m_personListView->clearList();
73
74     foreach (User interestingPerson, interestingPeople) {
75         PersonListItem *item = new PersonListItem();
76         item->setPersonData(interestingPerson);
77         m_personListView->addListItem(interestingPerson.userId(), item);
78     }
79
80     m_personListView->scrollToTop();
81 }