Finalised the classes for panels
[situare] / src / ui / friendlistpanel.cpp
1  /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Kaj Wallin - kaj.wallin@ixonos.com
6
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.
10
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.
15
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,
19     USA.
20  */
21
22 #include "friendlistpanel.h"
23 #include "friendlistview.h"
24 #include "friendlistitem.h"
25 #include "panelcommon.h"
26 #include "panelsliderbar.h"
27
28 FriendListPanel::FriendListPanel(QWidget *parent)
29     : QWidget(parent)
30 {
31     qDebug() << __PRETTY_FUNCTION__;
32     m_friendsPanelVBox = new QVBoxLayout(this);
33     setLayout(m_friendsPanelVBox);
34
35 //    m_friendListView = new FriendListView(this);
36 //    QScrollArea *friendListScroll = new QScrollArea(this);
37 //    friendListScroll->setWidget(m_friendListView);
38 //    friendListScroll->setWidgetResizable(true);
39 //    friendListScroll->viewport()->setAutoFillBackground(false);
40 //    m_friendsPanelVBox->addWidget(friendListScroll);
41
42     setAutoFillBackground(true);
43     QPalette pal = palette();
44     pal.setColor(QPalette::Background, QColor(0, 0, 0, 128));
45     setPalette(pal);
46
47     m_friendsPanelSlidingBar = new PanelSliderBar(this, RIGHT);
48     m_friendsPanelSlidingBar->move(TOP_CORNER_X, PANEL_TOP_Y);
49
50     m_friendsPanelStateMachine = new QStateMachine(this);
51     m_friendsPanelStateClosed = new QState(m_friendsPanelStateMachine);
52     m_friendsPanelStateClosed->assignProperty(this, "pos", QPoint(
53             FRIENDPANEL_CLOSED_X, PANEL_TOP_Y));
54     m_friendsPanelStateMachine->setInitialState(m_friendsPanelStateClosed);
55
56     m_friendsPanelStateOpened = new QState(m_friendsPanelStateMachine);
57     m_friendsPanelStateOpened->assignProperty(this, "pos", QPoint(
58             FRIENDPANEL_OPENED_X, PANEL_TOP_Y));
59
60     m_friendsPanelTransitionOpen = m_friendsPanelStateClosed->addTransition(
61             m_friendsPanelSlidingBar, SIGNAL(clicked()), m_friendsPanelStateOpened);
62     m_friendsPanelTransitionOpen->addAnimation(new QPropertyAnimation(this, "pos", this));
63
64     m_friendsPanelTransitionClose = m_friendsPanelStateOpened->addTransition(
65             m_friendsPanelSlidingBar, SIGNAL(clicked()), m_friendsPanelStateClosed);
66     m_friendsPanelTransitionClose->addAnimation(new QPropertyAnimation(this, "pos", this));
67
68     m_friendsPanelStateMachine->start();
69     setObjectName("FriendsPanel");
70 }
71
72 //void FriendListPanel::friendInfoReceived(QList<User *> &friendList)
73 //{
74 //    qDebug() << __PRETTY_FUNCTION__;
75
76 //    m_friendListView->clear();
77
78 //    foreach (User *user, friendList) {
79 //        FriendListItem *item = new FriendListItem(m_friendListView);
80 //        item->setData(user);
81 //        m_friendListView->addWidget(item);
82 //    }
83 //}
84
85 void FriendListPanel::reDrawFriendsPanel(int width, int height)
86 {
87     qDebug() << __PRETTY_FUNCTION__;
88     resize(FRIENDPANEL_WIDTH,height + MARGIN_CORRECTION);
89     m_friendsPanelStateClosed->assignProperty(this, "pos", QPoint(
90             width - PANEL_PEEK_AMOUNT, PANEL_TOP_Y));
91     m_friendsPanelStateOpened->assignProperty(this, "pos", QPoint(
92             width - FRIENDPANEL_WIDTH + MARGIN_CORRECTION, PANEL_TOP_Y));
93     move(width - PANEL_PEEK_AMOUNT, PANEL_TOP_Y);
94 }