2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Kaj Wallin - kaj.wallin@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,
22 #include "friendlistpanel.h"
23 #include "friendlistview.h"
24 #include "friendlistitem.h"
25 #include "panelcommon.h"
27 FriendListPanel::FriendListPanel(QWidget *parent)
30 qDebug() << __PRETTY_FUNCTION__;
31 m_friendsPanelVBox = new QVBoxLayout(this);
32 m_friendsPanelVBox->setMargin(0);
33 m_friendsPanelVBox->setSpacing(0);
34 this->setLayout(m_friendsPanelVBox);
35 m_friendsPanelExpandButton = new QPushButton("Friends", this);
36 m_friendsPanelVBox->addWidget(m_friendsPanelExpandButton);
38 m_friendListView = new FriendListView(this);
39 QScrollArea *friendListScroll = new QScrollArea(this);
40 friendListScroll->setWidget(m_friendListView);
41 friendListScroll->setWidgetResizable(true);
42 friendListScroll->viewport()->setAutoFillBackground(false);
43 friendListScroll->widget()->setAutoFillBackground(false);
45 m_friendsPanelVBox->addWidget(friendListScroll);
47 m_friendsPanelStateMachine = new QStateMachine(this);
48 m_friendsPanelStateClosed = new QState(m_friendsPanelStateMachine);
49 m_friendsPanelStateClosed->assignProperty(this, "pos", QPoint(
50 FRIENDPANEL_CLOSED_X, PANEL_TOP_Y));
51 m_friendsPanelStateMachine->setInitialState(m_friendsPanelStateClosed);
53 m_friendsPanelStateOpened = new QState(m_friendsPanelStateMachine);
54 m_friendsPanelStateOpened->assignProperty(this, "pos", QPoint(
55 FRIENDPANEL_OPENED_X, PANEL_TOP_Y));
57 m_friendsPanelTransitionOpen = m_friendsPanelStateClosed->addTransition(
58 m_friendsPanelExpandButton, SIGNAL(clicked()), m_friendsPanelStateOpened);
59 m_friendsPanelTransitionOpen->addAnimation(new QPropertyAnimation(this, "pos"));
61 m_friendsPanelTransitionClose = m_friendsPanelStateOpened->addTransition(
62 m_friendsPanelExpandButton, SIGNAL(clicked()), m_friendsPanelStateClosed);
63 m_friendsPanelTransitionClose->addAnimation(new QPropertyAnimation(this, "pos"));
65 m_friendsPanelStateMachine->start();
68 QList<User *> friendList;
69 for (int i = 0; i < 10; ++i) {
70 User *user = new User(QString("Address"), QPointF(12.22, 23.33), QString("Name Name Name Naem"),
71 QString("Hello world! Hello world! Hello world! Hello world! "),
72 QUrl(), QString("2 days ago"), false, QString("id"), QString("km"),
74 user->setProfileImage(QPixmap("res/images/face.gif"));
75 friendList.append(user);
77 friendInfoReceived(friendList);
79 this->setObjectName("UserPanel");
80 //this->setStyleSheet(QString("#UserPanel{background-image: url(:/res/images/personal_info_bckgrnd.png)}"));
82 this->setAutoFillBackground(true);
83 QPalette pal = palette();
84 pal.setColor(QPalette::Background, QColor(0, 0, 0, 128));
88 void FriendListPanel::friendInfoReceived(QList<User *> &friendList)
90 qDebug() << __PRETTY_FUNCTION__;
92 m_friendListView->clear();
94 foreach (User *user, friendList) {
95 FriendListItem *item = new FriendListItem(m_friendListView);
97 m_friendListView->addWidget(item);
98 FriendListItem *item2 = new FriendListItem(m_friendListView);
100 m_friendListView->addWidget(item2);
101 FriendListItem *item3 = new FriendListItem(m_friendListView);
102 item3->setData(user);
103 m_friendListView->addWidget(item3);
104 FriendListItem *item4 = new FriendListItem(m_friendListView);
105 item4->setData(user);
106 m_friendListView->addWidget(item4);
110 void FriendListPanel::reDrawFriendsPanel(int width, int height)
112 qDebug() << __PRETTY_FUNCTION__;
113 this->resize(FRIENDPANEL_WIDTH,height + MARGIN_CORRECTION);
114 m_friendsPanelStateClosed->assignProperty(this, "pos", QPoint(
115 width-PANEL_PEEK_AMOUNT, PANEL_TOP_Y));
116 m_friendsPanelStateOpened->assignProperty(this, "pos", QPoint(
117 width - FRIENDPANEL_WIDTH + MARGIN_CORRECTION, PANEL_TOP_Y));
118 this->move(width-PANEL_PEEK_AMOUNT, PANEL_TOP_Y);
121 void FriendListPanel::paintEvent(QPaintEvent *)
126 QStylePainter painter(this);
127 style()->drawPrimitive(QStyle::PE_Widget, &option, &painter, this);