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 "mainwindow.h"
41 const int INFOTAB_Y_LOC_STATE1 = 71;
42 const int INFOTAB_X_LOC_STATE2 = 59;
43 const int INFOTAB_Y_LOC_STATE2 = 71;
44 const int LEFTBAR_X_LOC = 0;
45 const int LEFTBAR_Y_LOC = 0;
46 const int SLIDING_BAR_X_LOC_STATE1 = 0;
47 const int SLIDING_BAR_Y_LOC_STATE1 = 0;
48 const int BACKGROUND_X_LOC_STATE1 = 400;
49 const int BACKGROUND_Y_LOC_STATE1 = 0;
50 const int RIGHTARROW_X_LOC_STATE1 = 9;
51 const int RIGHTARROW_Y_LOC_STATE1 = 205;
52 const int LEFTARROW_X_LOC_STATE1 = 9;
53 const int LEFTARROW_Y_LOC_STATE1 = 205;
54 const int PROXYWIDGET_X_LOC_STATE1 = 59;
55 const int PROXYWIDGET_Y_LOC_STATE1 = 71;
56 const int SLIDING_BAR_X_LOC_STATE2 = 376;
57 const int SLIDING_BAR_Y_LOC_STATE2 = 0;
58 const int BACKGROUND_X_LOC_STATE2 = 0;
59 const int BACKGROUND_Y_LOC_STATE2 = 0;
60 const int RIGHTARROW_X_LOC_STATE2 = 385;
61 const int RIGHTARROW_Y_LOC_STATE2 = 205;
62 const int LEFTARROW_X_LOC_STATE2 = 385;
63 const int LEFTARROW_Y_LOC_STATE2 = 205;
64 const int PROXYWIDGET_X_LOC_STATE2 = 59;
65 const int PROXYWIDGET_Y_LOC_STATE2 = 71;
67 ListViewScreen::ListViewScreen(QWidget *parent)
71 m_friendListView = new FriendListView(this);
72 QScrollArea *friendListScroll = new QScrollArea(this);
73 friendListScroll->setWidget(m_friendListView);
74 friendListScroll->setWidgetResizable(true);
77 m_leftSideBar = new Pixmap(QPixmap(":/res/images/side_bar_left.png"));
78 m_slidingLeftSideBar = new Pixmap(QPixmap(":/res/images/sliding_bar_left.png"));
79 m_personalInfoBackGround = new Pixmap(QPixmap(":/res/images/personal_info_bckgrnd.png"));
80 m_arrowLeft = new Pixmap(QPixmap(":/res/images/arrow_left.png"));
81 m_arrowRight = new Pixmap(QPixmap(":/res/images/arrow_right.png"));
82 m_personalInfo = new InfoTab;
83 m_personalInfo->setAvatar(QPixmap(":/res/images/situare_user.jpg"));
84 m_personalInfo->setUserName("Fred Facebook");
85 m_personalInfo->setMessageText("Hello Maemo Situare !");
86 m_personalInfo->setTime("1 hour ago");
87 m_personalInfo->setAddress("Kiviharjunlenkki 1E, 91910 Oulu");
89 qDebug() << "InfoTab width: " << m_personalInfo->width();
90 qDebug() << "InfoTab heigth: " << m_personalInfo->height();
92 m_locationDialog = new UpdateLocationDialog(this);
93 m_widgetProxy = new QGraphicsProxyWidget();
94 m_widgetProxy->setWidget(m_personalInfo);
96 QGraphicsScene *scene= new QGraphicsScene(this);
97 scene->setBackgroundBrush(Qt::black);
98 scene->addItem(m_personalInfoBackGround);
99 scene->addItem(m_widgetProxy);
100 scene->addItem(m_leftSideBar);
101 scene->addItem(m_slidingLeftSideBar);
102 scene->addItem(m_arrowRight);
103 scene->addItem(m_arrowLeft);
105 m_leftSideBar->setPos(0,0);
107 QGraphicsView *view = new QGraphicsView(scene);
108 view->setAlignment(Qt::AlignLeft|Qt::AlignTop);
109 view->setSceneRect(0,0,7000,3000);
110 view->centerOn(QPointF(0,0));
111 view->setFrameStyle(0);
112 view->setAlignment(Qt::AlignLeft | Qt::AlignTop);
113 view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
114 view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
115 view->setBackgroundBrush(Qt::black);
118 QStateMachine *machine = new QStateMachine(this);
119 machine->setGlobalRestorePolicy(QStateMachine::RestoreProperties);
121 QState *state1 = new QState(machine);
122 QState *state2 = new QState(machine);
123 machine->setInitialState(state1);
126 state1->assignProperty(m_widgetProxy,"pos",QPointF(-m_personalInfo->width(),
127 INFOTAB_Y_LOC_STATE1));
128 state1->assignProperty(m_slidingLeftSideBar,"pos",
129 QPointF(SLIDING_BAR_X_LOC_STATE1,SLIDING_BAR_Y_LOC_STATE1));
130 state1->assignProperty(m_personalInfoBackGround,"pos",
131 QPointF(-BACKGROUND_X_LOC_STATE1,BACKGROUND_Y_LOC_STATE1));
132 state1->assignProperty(m_arrowRight,"pos", QPointF(RIGHTARROW_X_LOC_STATE1,
133 RIGHTARROW_Y_LOC_STATE1));
134 state1->assignProperty(m_arrowLeft,"pos", QPointF(LEFTARROW_X_LOC_STATE2,
135 LEFTARROW_Y_LOC_STATE2));
136 state1->assignProperty(m_arrowRight,"visible", true);
137 state1->assignProperty(m_arrowLeft,"visible", false);
140 state2->assignProperty(m_widgetProxy,"pos",QPointF(INFOTAB_X_LOC_STATE2,INFOTAB_Y_LOC_STATE2));
141 state2->assignProperty(m_slidingLeftSideBar,"pos",QPointF(SLIDING_BAR_X_LOC_STATE2,
142 SLIDING_BAR_Y_LOC_STATE2));
143 state2->assignProperty(m_personalInfoBackGround,"pos",QPointF(BACKGROUND_X_LOC_STATE2,
144 BACKGROUND_Y_LOC_STATE2));
145 state2->assignProperty(m_arrowRight,"pos", QPointF(RIGHTARROW_X_LOC_STATE2,
146 RIGHTARROW_Y_LOC_STATE2));
147 state2->assignProperty(m_arrowLeft,"pos", QPointF(LEFTARROW_X_LOC_STATE2,
148 LEFTARROW_Y_LOC_STATE2));
149 state2->assignProperty(m_arrowRight,"visible", false);
150 state2->assignProperty(m_arrowLeft,"visible", true);
152 m_trans1 = state1->addTransition(m_slidingLeftSideBar,SIGNAL(clicked()),state2);
153 m_anim1 = new QPropertyAnimation(m_widgetProxy,"pos");
154 m_anim2 = new QPropertyAnimation(m_slidingLeftSideBar,"pos");
155 m_anim3 = new QPropertyAnimation(m_personalInfoBackGround,"pos");
156 m_anim4 = new QPropertyAnimation(m_arrowRight,"pos");
157 m_anim5 = new QPropertyAnimation(m_arrowLeft,"pos");
158 m_anim6 = new QPropertyAnimation(m_arrowRight,"visible");
159 m_anim7 = new QPropertyAnimation(m_arrowLeft,"visible");
160 m_trans1->addAnimation(m_anim1);
161 m_trans1->addAnimation(m_anim2);
162 m_trans1->addAnimation(m_anim3);
163 m_trans1->addAnimation(m_anim4);
164 m_trans1->addAnimation(m_anim5);
165 m_trans1->addAnimation(m_anim6);
166 m_trans1->addAnimation(m_anim7);
168 m_trans2 = state2->addTransition(m_slidingLeftSideBar,SIGNAL(clicked()),state1);
169 m_anim8 = new QPropertyAnimation(m_widgetProxy,"pos");
170 m_anim9 = new QPropertyAnimation(m_slidingLeftSideBar,"pos");
171 m_anim10 = new QPropertyAnimation(m_personalInfoBackGround,"pos");
172 m_anim11 = new QPropertyAnimation(m_arrowRight,"pos");
173 m_anim12 = new QPropertyAnimation(m_arrowLeft,"pos");
174 m_anim13 = new QPropertyAnimation(m_arrowRight,"visible");
175 m_anim14 = new QPropertyAnimation(m_arrowLeft,"visible");
176 m_trans2->addAnimation(m_anim8);
177 m_trans2->addAnimation(m_anim9);
178 m_trans2->addAnimation(m_anim10);
179 m_trans2->addAnimation(m_anim11);
180 m_trans2->addAnimation(m_anim12);
181 m_trans2->addAnimation(m_anim13);
182 m_trans2->addAnimation(m_anim14);
185 m_vbox = new QHBoxLayout(this);
186 m_vbox->addWidget(view);
187 m_vbox->addWidget(friendListScroll);
188 m_vbox->setMargin(0);
190 connect(m_personalInfo,SIGNAL(launchMessageUpdate()),
191 this,SIGNAL(launchUpdateDialog()));
192 connect(m_personalInfo,SIGNAL(launchUpdateFriendsStatus()),
193 this, SIGNAL(updateFriendsData()));
194 setObjectName("List view");
197 ListViewScreen::~ListViewScreen()
199 delete m_personalInfo;
200 delete m_leftSideBar;
201 delete m_slidingLeftSideBar;
202 delete m_personalInfoBackGround;
224 void ListViewScreen::userDataReceived(User *user)
226 qDebug() << __PRETTY_FUNCTION__;
228 m_personalInfo->setUserName(user->name());
229 m_personalInfo->setAvatar(user->profileImage());
230 m_personalInfo->setMessageText(user->note());
231 m_personalInfo->setAddress(user->address());
232 m_personalInfo->setTime(user->timestamp());
235 void ListViewScreen::friendInfoReceived(QList<User *> &friendList)
237 qDebug() << __PRETTY_FUNCTION__;
239 m_friendListView->clear();
241 foreach (User *user, friendList) {
242 FriendListItem *item = new FriendListItem(m_friendListView);
244 m_friendListView->addWidget(item);