2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Jussi Laitinen - jussi.laitinen@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23 #include <QVBoxLayout>
25 #include "extendedlistitemdelegate.h"
26 #include "imagebutton.h"
27 #include "notificationlistitem.h"
28 #include "notificationlistview.h"
29 #include "panelcommon.h"
30 #include "situareservice/notification.h"
32 #include "notificationpanel.h"
34 NotificationPanel::NotificationPanel(QWidget *parent)
37 qDebug() << __PRETTY_FUNCTION__;
39 // --- MAIN LAYOUT ---
40 QVBoxLayout *notificationLayout = new QVBoxLayout;
41 notificationLayout->setMargin(0);
42 notificationLayout->setSpacing(0);
43 setLayout(notificationLayout);
45 QVBoxLayout *listViewLayout = new QVBoxLayout;
46 listViewLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
47 PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
48 notificationLayout->addLayout(listViewLayout);
50 ImageButton *refreshNotificationsButton = new ImageButton(":/res/images/refresh.png",
51 ":/res/images/refresh_s.png",
53 connect(refreshNotificationsButton, SIGNAL(clicked()),
54 this, SIGNAL(requestNotifications()));
56 m_notificationListView = new NotificationListView(this);
57 m_notificationListView->setItemDelegate(new ExtendedListItemDelegate(this));
58 listViewLayout->addWidget(m_notificationListView);
60 m_genericButtonsLayout->addWidget(refreshNotificationsButton);
63 void NotificationPanel::anyPanelClosed()
65 qDebug() << __PRETTY_FUNCTION__;
67 m_notificationListView->clearItemSelection();
70 void NotificationPanel::hideEvent(QHideEvent *event)
72 qDebug() << __PRETTY_FUNCTION__;
74 QWidget::hideEvent(event);
76 m_notificationListView->clearItemSelection();
79 void NotificationPanel::populateNotificationListView(QList<Notification> ¬ifications)
81 qWarning() << __PRETTY_FUNCTION__;
83 m_notificationListView->clearList();
85 foreach (Notification notification, notifications) {
86 NotificationListItem *item = new NotificationListItem();
87 item->setNotificationData(notification);
88 m_notificationListView->addListItem(notification.id(), item);
92 void NotificationPanel::setImage(const QString &id, const QPixmap &image)
94 qWarning() << __PRETTY_FUNCTION__ << id;
96 NotificationListItem *item = dynamic_cast<NotificationListItem*>(
97 m_notificationListView->listItem(id));
100 qWarning() << __PRETTY_FUNCTION__ << "item!";
101 item->setImage(image);