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 "messagelistitem.h"
28 #include "messagelistview.h"
29 #include "panelcommon.h"
30 #include "situareservice/message.h"
32 #include "messagepanel.h"
34 MessagePanel::MessagePanel(QWidget *parent)
37 qDebug() << __PRETTY_FUNCTION__;
39 // --- MAIN LAYOUT ---
40 QVBoxLayout *messageLayout = new QVBoxLayout;
41 messageLayout->setMargin(0);
42 messageLayout->setSpacing(0);
43 setLayout(messageLayout);
45 QVBoxLayout *listViewLayout = new QVBoxLayout;
46 listViewLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
47 PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
48 messageLayout->addLayout(listViewLayout);
50 ImageButton *refreshMessagesButton = new ImageButton(":/res/images/refresh.png",
51 ":/res/images/refresh_s.png",
53 connect(refreshMessagesButton, SIGNAL(clicked()),
54 this, SIGNAL(requestMessages()));
56 m_messageListView = new MessageListView(this);
57 m_messageListView->setItemDelegate(new ExtendedListItemDelegate(this));
58 listViewLayout->addWidget(m_messageListView);
60 m_genericButtonsLayout->addWidget(refreshMessagesButton);
63 void MessagePanel::anyPanelClosed()
65 qDebug() << __PRETTY_FUNCTION__;
67 m_messageListView->clearItemSelection();
70 void MessagePanel::hideEvent(QHideEvent *event)
72 qDebug() << __PRETTY_FUNCTION__;
74 QWidget::hideEvent(event);
76 m_messageListView->clearItemSelection();
79 void MessagePanel::populateMessageListView(QList<Message> &messages)
81 qDebug() << __PRETTY_FUNCTION__;
83 m_messageListView->clearList();
85 foreach (Message message, messages) {
86 MessageListItem *item = new MessageListItem();
87 item->setMessageData(message);
88 m_messageListView->addListItem(message.id(), item);
92 void MessagePanel::setImage(const QString &id, const QPixmap &image)
94 qDebug() << __PRETTY_FUNCTION__;
96 MessageListItem *item = dynamic_cast<MessageListItem*>(
97 m_messageListView->listItem(id));
100 item->setImage(image);