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();
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);
107 QGraphicsProxyWidget *scrollProxy = new QGraphicsProxyWidget();
108 scrollProxy->setWidget(friendListScroll);
109 scrollProxy->setZValue(m_personalInfoBackGround->zValue() - 3);
110 scrollProxy->setMinimumSize(790 - 400, 480 - 56);
111 scene->addItem(scrollProxy);
112 scrollProxy->setPos(410, 0);
115 m_leftSideBar->setPos(0,0);
117 QGraphicsView *view = new QGraphicsView(scene);
118 view->setAlignment(Qt::AlignLeft|Qt::AlignTop);
119 view->setSceneRect(0,0,7000,3000);
120 view->centerOn(QPointF(0,0));
121 view->setFrameStyle(0);
122 view->setAlignment(Qt::AlignLeft | Qt::AlignTop);
123 view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
124 view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
125 view->setBackgroundBrush(Qt::black);
128 QStateMachine *machine = new QStateMachine(this);
129 machine->setGlobalRestorePolicy(QStateMachine::RestoreProperties);
131 QState *state1 = new QState(machine);
132 QState *state2 = new QState(machine);
133 machine->setInitialState(state1);
136 state1->assignProperty(m_widgetProxy,"pos",QPointF(-m_personalInfo->width(),
137 INFOTAB_Y_LOC_STATE1));
138 state1->assignProperty(m_slidingLeftSideBar,"pos",
139 QPointF(SLIDING_BAR_X_LOC_STATE1,SLIDING_BAR_Y_LOC_STATE1));
140 state1->assignProperty(m_personalInfoBackGround,"pos",
141 QPointF(-BACKGROUND_X_LOC_STATE1,BACKGROUND_Y_LOC_STATE1));
142 state1->assignProperty(m_arrowRight,"pos", QPointF(RIGHTARROW_X_LOC_STATE1,
143 RIGHTARROW_Y_LOC_STATE1));
144 state1->assignProperty(m_arrowLeft,"pos", QPointF(LEFTARROW_X_LOC_STATE2,
145 LEFTARROW_Y_LOC_STATE2));
146 state1->assignProperty(m_arrowRight,"visible", true);
147 state1->assignProperty(m_arrowLeft,"visible", false);
150 state2->assignProperty(m_widgetProxy,"pos",QPointF(INFOTAB_X_LOC_STATE2,INFOTAB_Y_LOC_STATE2));
151 state2->assignProperty(m_slidingLeftSideBar,"pos",QPointF(SLIDING_BAR_X_LOC_STATE2,
152 SLIDING_BAR_Y_LOC_STATE2));
153 state2->assignProperty(m_personalInfoBackGround,"pos",QPointF(BACKGROUND_X_LOC_STATE2,
154 BACKGROUND_Y_LOC_STATE2));
155 state2->assignProperty(m_arrowRight,"pos", QPointF(RIGHTARROW_X_LOC_STATE2,
156 RIGHTARROW_Y_LOC_STATE2));
157 state2->assignProperty(m_arrowLeft,"pos", QPointF(LEFTARROW_X_LOC_STATE2,
158 LEFTARROW_Y_LOC_STATE2));
159 state2->assignProperty(m_arrowRight,"visible", false);
160 state2->assignProperty(m_arrowLeft,"visible", true);
162 m_trans1 = state1->addTransition(m_slidingLeftSideBar,SIGNAL(clicked()),state2);
163 m_anim1 = new QPropertyAnimation(m_widgetProxy,"pos");
164 m_anim2 = new QPropertyAnimation(m_slidingLeftSideBar,"pos");
165 m_anim3 = new QPropertyAnimation(m_personalInfoBackGround,"pos");
166 m_anim4 = new QPropertyAnimation(m_arrowRight,"pos");
167 m_anim5 = new QPropertyAnimation(m_arrowLeft,"pos");
168 m_anim6 = new QPropertyAnimation(m_arrowRight,"visible");
169 m_anim7 = new QPropertyAnimation(m_arrowLeft,"visible");
170 m_trans1->addAnimation(m_anim1);
171 m_trans1->addAnimation(m_anim2);
172 m_trans1->addAnimation(m_anim3);
173 m_trans1->addAnimation(m_anim4);
174 m_trans1->addAnimation(m_anim5);
175 m_trans1->addAnimation(m_anim6);
176 m_trans1->addAnimation(m_anim7);
178 m_trans2 = state2->addTransition(m_slidingLeftSideBar,SIGNAL(clicked()),state1);
179 m_anim8 = new QPropertyAnimation(m_widgetProxy,"pos");
180 m_anim9 = new QPropertyAnimation(m_slidingLeftSideBar,"pos");
181 m_anim10 = new QPropertyAnimation(m_personalInfoBackGround,"pos");
182 m_anim11 = new QPropertyAnimation(m_arrowRight,"pos");
183 m_anim12 = new QPropertyAnimation(m_arrowLeft,"pos");
184 m_anim13 = new QPropertyAnimation(m_arrowRight,"visible");
185 m_anim14 = new QPropertyAnimation(m_arrowLeft,"visible");
186 m_trans2->addAnimation(m_anim8);
187 m_trans2->addAnimation(m_anim9);
188 m_trans2->addAnimation(m_anim10);
189 m_trans2->addAnimation(m_anim11);
190 m_trans2->addAnimation(m_anim12);
191 m_trans2->addAnimation(m_anim13);
192 m_trans2->addAnimation(m_anim14);
195 m_vbox = new QVBoxLayout(this);
196 m_vbox->addWidget(view);
197 m_vbox->setMargin(0);
199 connect(m_personalInfo,SIGNAL(launchMessageUpdate()),
200 this,SIGNAL(launchUpdateDialog()));
201 connect(m_personalInfo,SIGNAL(launchUpdateFriendsStatus()),
202 this, SIGNAL(updateFriendsData()));
203 setObjectName("List view");
206 ListViewScreen::~ListViewScreen()
208 delete m_personalInfo;
209 delete m_leftSideBar;
210 delete m_slidingLeftSideBar;
211 delete m_personalInfoBackGround;
233 void ListViewScreen::userDataChanged(User *user, QList<User *> &friends)
235 qDebug() << __PRETTY_FUNCTION__;
237 emit toggleProgressIndicator(false);
239 m_personalInfo->setUserName(user->name());
240 m_personalInfo->setAvatar(user->profileImage());
241 m_personalInfo->setMessageText(user->note());
242 m_personalInfo->setAddress(user->address());
243 m_personalInfo->setTime(user->timestamp());
245 m_friendListView->clear();
247 foreach (User *user, friends) {
248 FriendListItem *item = new FriendListItem(m_friendListView);
250 m_friendListView->addWidget(item);