2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Kaj Wallin - kaj.wallin@ixonos.com
6 Jukka Saastamoinen jukka.saastamoinen@ixonos.com
7 Jussi Laitinen jussi.laitinen@ixonos.com
9 Situare is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 version 2 as published by the Free Software Foundation.
13 Situare is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Situare; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24 #include <QGraphicsScene>
25 #include <QGraphicsView>
26 #include <QGraphicsWidget>
27 #include <QtGui/QVBoxLayout>
28 #include <QGraphicsProxyWidget>
29 #include <QStateMachine>
30 #include <QtGui/QGraphicsTransform>
31 #include <QtGui/QGraphicsRotation>
33 #include <QScrollArea>
35 #include "listviewscreen.h"
36 #include "friendlistview.h"
37 #include "friendlistitem.h"
38 #include "user/user.h"
39 #include "situareuser.h"
40 #include "mainwindow.h"
42 const int INFOTAB_Y_LOC_STATE1 = 71;
43 const int INFOTAB_X_LOC_STATE2 = 59;
44 const int INFOTAB_Y_LOC_STATE2 = 71;
45 const int LEFTBAR_X_LOC = 0;
46 const int LEFTBAR_Y_LOC = 0;
47 const int SLIDING_BAR_X_LOC_STATE1 = 0;
48 const int SLIDING_BAR_Y_LOC_STATE1 = 0;
49 const int BACKGROUND_X_LOC_STATE1 = 400;
50 const int BACKGROUND_Y_LOC_STATE1 = 0;
51 const int RIGHTARROW_X_LOC_STATE1 = 9;
52 const int RIGHTARROW_Y_LOC_STATE1 = 205;
53 const int LEFTARROW_X_LOC_STATE1 = 9;
54 const int LEFTARROW_Y_LOC_STATE1 = 205;
55 const int PROXYWIDGET_X_LOC_STATE1 = 59;
56 const int PROXYWIDGET_Y_LOC_STATE1 = 71;
57 const int SLIDING_BAR_X_LOC_STATE2 = 376;
58 const int SLIDING_BAR_Y_LOC_STATE2 = 0;
59 const int BACKGROUND_X_LOC_STATE2 = 0;
60 const int BACKGROUND_Y_LOC_STATE2 = 0;
61 const int RIGHTARROW_X_LOC_STATE2 = 385;
62 const int RIGHTARROW_Y_LOC_STATE2 = 205;
63 const int LEFTARROW_X_LOC_STATE2 = 385;
64 const int LEFTARROW_Y_LOC_STATE2 = 205;
65 const int PROXYWIDGET_X_LOC_STATE2 = 59;
66 const int PROXYWIDGET_Y_LOC_STATE2 = 71;
68 ListViewScreen::ListViewScreen(QWidget *parent)
72 m_friendListView = new FriendListView(this);
73 QScrollArea *friendListScroll = new QScrollArea(this);
74 friendListScroll->setWidget(m_friendListView);
75 friendListScroll->setWidgetResizable(true);
78 m_leftSideBar = new Pixmap(QPixmap(":/res/images/side_bar_left.png"));
79 m_slidingLeftSideBar = new Pixmap(QPixmap(":/res/images/sliding_bar_left.png"));
80 m_personalInfoBackGround = new Pixmap(QPixmap(":/res/images/personal_info_bckgrnd.png"));
81 m_arrowLeft = new Pixmap(QPixmap(":/res/images/arrow_left.png"));
82 m_arrowRight = new Pixmap(QPixmap(":/res/images/arrow_right.png"));
83 m_personalInfo = new InfoTab;
84 m_personalInfo->setAvatar(QPixmap(":/res/images/situare_user.jpg"));
85 m_personalInfo->setUserName("Fred Facebook");
86 m_personalInfo->setMessageText("Hello Maemo Situare !");
87 m_personalInfo->setTime("1 hour ago");
88 m_personalInfo->setAddress("Kiviharjunlenkki 1E, 91910 Oulu");
90 qDebug() << "InfoTab width: " << m_personalInfo->width();
91 qDebug() << "InfoTab heigth: " << m_personalInfo->height();
93 m_locationDialog = new UpdateLocationDialog(this);
94 m_widgetProxy = new QGraphicsProxyWidget();
95 m_widgetProxy->setWidget(m_personalInfo);
97 QGraphicsScene *scene= new QGraphicsScene(this);
98 scene->setBackgroundBrush(Qt::black);
99 scene->addItem(m_personalInfoBackGround);
100 scene->addItem(m_widgetProxy);
101 scene->addItem(m_leftSideBar);
102 scene->addItem(m_slidingLeftSideBar);
103 scene->addItem(m_arrowRight);
104 scene->addItem(m_arrowLeft);
106 m_leftSideBar->setPos(0,0);
108 QGraphicsView *view = new QGraphicsView(scene);
109 view->setAlignment(Qt::AlignLeft|Qt::AlignTop);
110 view->setSceneRect(0,0,7000,3000);
111 view->centerOn(QPointF(0,0));
112 view->setFrameStyle(0);
113 view->setAlignment(Qt::AlignLeft | Qt::AlignTop);
114 view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
115 view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
116 view->setBackgroundBrush(Qt::black);
119 QStateMachine *machine = new QStateMachine(this);
120 machine->setGlobalRestorePolicy(QStateMachine::RestoreProperties);
122 QState *state1 = new QState(machine);
123 QState *state2 = new QState(machine);
124 machine->setInitialState(state1);
127 state1->assignProperty(m_widgetProxy,"pos",QPointF(-m_personalInfo->width(),
128 INFOTAB_Y_LOC_STATE1));
129 state1->assignProperty(m_slidingLeftSideBar,"pos",
130 QPointF(SLIDING_BAR_X_LOC_STATE1,SLIDING_BAR_Y_LOC_STATE1));
131 state1->assignProperty(m_personalInfoBackGround,"pos",
132 QPointF(-BACKGROUND_X_LOC_STATE1,BACKGROUND_Y_LOC_STATE1));
133 state1->assignProperty(m_arrowRight,"pos", QPointF(RIGHTARROW_X_LOC_STATE1,
134 RIGHTARROW_Y_LOC_STATE1));
135 state1->assignProperty(m_arrowLeft,"pos", QPointF(LEFTARROW_X_LOC_STATE2,
136 LEFTARROW_Y_LOC_STATE2));
137 state1->assignProperty(m_arrowRight,"visible", true);
138 state1->assignProperty(m_arrowLeft,"visible", false);
141 state2->assignProperty(m_widgetProxy,"pos",QPointF(INFOTAB_X_LOC_STATE2,INFOTAB_Y_LOC_STATE2));
142 state2->assignProperty(m_slidingLeftSideBar,"pos",QPointF(SLIDING_BAR_X_LOC_STATE2,
143 SLIDING_BAR_Y_LOC_STATE2));
144 state2->assignProperty(m_personalInfoBackGround,"pos",QPointF(BACKGROUND_X_LOC_STATE2,
145 BACKGROUND_Y_LOC_STATE2));
146 state2->assignProperty(m_arrowRight,"pos", QPointF(RIGHTARROW_X_LOC_STATE2,
147 RIGHTARROW_Y_LOC_STATE2));
148 state2->assignProperty(m_arrowLeft,"pos", QPointF(LEFTARROW_X_LOC_STATE2,
149 LEFTARROW_Y_LOC_STATE2));
150 state2->assignProperty(m_arrowRight,"visible", false);
151 state2->assignProperty(m_arrowLeft,"visible", true);
153 m_trans1 = state1->addTransition(m_slidingLeftSideBar,SIGNAL(clicked()),state2);
154 m_anim1 = new QPropertyAnimation(m_widgetProxy,"pos");
155 m_anim2 = new QPropertyAnimation(m_slidingLeftSideBar,"pos");
156 m_anim3 = new QPropertyAnimation(m_personalInfoBackGround,"pos");
157 m_anim4 = new QPropertyAnimation(m_arrowRight,"pos");
158 m_anim5 = new QPropertyAnimation(m_arrowLeft,"pos");
159 m_anim6 = new QPropertyAnimation(m_arrowRight,"visible");
160 m_anim7 = new QPropertyAnimation(m_arrowLeft,"visible");
161 m_trans1->addAnimation(m_anim1);
162 m_trans1->addAnimation(m_anim2);
163 m_trans1->addAnimation(m_anim3);
164 m_trans1->addAnimation(m_anim4);
165 m_trans1->addAnimation(m_anim5);
166 m_trans1->addAnimation(m_anim6);
167 m_trans1->addAnimation(m_anim7);
169 m_trans2 = state2->addTransition(m_slidingLeftSideBar,SIGNAL(clicked()),state1);
170 m_anim8 = new QPropertyAnimation(m_widgetProxy,"pos");
171 m_anim9 = new QPropertyAnimation(m_slidingLeftSideBar,"pos");
172 m_anim10 = new QPropertyAnimation(m_personalInfoBackGround,"pos");
173 m_anim11 = new QPropertyAnimation(m_arrowRight,"pos");
174 m_anim12 = new QPropertyAnimation(m_arrowLeft,"pos");
175 m_anim13 = new QPropertyAnimation(m_arrowRight,"visible");
176 m_anim14 = new QPropertyAnimation(m_arrowLeft,"visible");
177 m_trans2->addAnimation(m_anim8);
178 m_trans2->addAnimation(m_anim9);
179 m_trans2->addAnimation(m_anim10);
180 m_trans2->addAnimation(m_anim11);
181 m_trans2->addAnimation(m_anim12);
182 m_trans2->addAnimation(m_anim13);
183 m_trans2->addAnimation(m_anim14);
186 m_vbox = new QHBoxLayout(this);
187 m_vbox->addWidget(view);
188 m_vbox->addWidget(friendListScroll);
189 m_vbox->setMargin(0);
191 connect(m_personalInfo,SIGNAL(launchMessageUpdate()),
192 this,SIGNAL(launchUpdateDialog()));
193 connect(m_personalInfo,SIGNAL(launchUpdateFriendsStatus()),
194 this, SIGNAL(updateFriendsData()));
195 setObjectName("List view");
198 ListViewScreen::~ListViewScreen()
200 delete m_personalInfo;
201 delete m_leftSideBar;
202 delete m_slidingLeftSideBar;
203 delete m_personalInfoBackGround;
225 void ListViewScreen::userDataReceived(User *user)
227 qDebug() << __PRETTY_FUNCTION__;
229 m_personalInfo->setUserName(user->name());
230 m_personalInfo->setAvatar(user->profileImage());
231 m_personalInfo->setMessageText(user->note());
232 m_personalInfo->setAddress(user->address());
233 m_personalInfo->setTime(user->timestamp());
236 void ListViewScreen::friendInfoReceived(QList<User *> &friendList)
238 qDebug() << __PRETTY_FUNCTION__;
240 m_friendListView->clear();
242 foreach (User *user, friendList) {
243 FriendListItem *item = new FriendListItem(m_friendListView);
245 m_friendListView->addWidget(item);