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
8 Situare is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
12 Situare is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Situare; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23 #include <QGraphicsScene>
24 #include <QGraphicsView>
25 #include <QGraphicsWidget>
26 #include <QtGui/QVBoxLayout>
27 #include <QGraphicsProxyWidget>
28 #include <QStateMachine>
29 #include "listviewscreen.h"
30 #include "situareuser.h"
32 #include <QtGui/QGraphicsTransform>
33 #include <QtGui/QGraphicsRotation>
35 const int INFOTAB_Y_LOC_STATE1 = 71;
36 const int INFOTAB_X_LOC_STATE2 = 59;
37 const int INFOTAB_Y_LOC_STATE2 = 71;
38 const int LEFTBAR_X_LOC = 0;
39 const int LEFTBAR_Y_LOC = 0;
40 const int SLIDING_BAR_X_LOC_STATE1 = 0;
41 const int SLIDING_BAR_Y_LOC_STATE1 = 0;
42 const int BACKGROUND_X_LOC_STATE1 = 400;
43 const int BACKGROUND_Y_LOC_STATE1 = 0;
44 const int RIGHTARROW_X_LOC_STATE1 = 9;
45 const int RIGHTARROW_Y_LOC_STATE1 = 205;
46 const int LEFTARROW_X_LOC_STATE1 = 9;
47 const int LEFTARROW_Y_LOC_STATE1 = 205;
48 const int PROXYWIDGET_X_LOC_STATE1 = 59;
49 const int PROXYWIDGET_Y_LOC_STATE1 = 71;
50 const int SLIDING_BAR_X_LOC_STATE2 = 376;
51 const int SLIDING_BAR_Y_LOC_STATE2 = 0;
52 const int BACKGROUND_X_LOC_STATE2 = 0;
53 const int BACKGROUND_Y_LOC_STATE2 = 0;
54 const int RIGHTARROW_X_LOC_STATE2 = 385;
55 const int RIGHTARROW_Y_LOC_STATE2 = 205;
56 const int LEFTARROW_X_LOC_STATE2 = 385;
57 const int LEFTARROW_Y_LOC_STATE2 = 205;
58 const int PROXYWIDGET_X_LOC_STATE2 = 59;
59 const int PROXYWIDGET_Y_LOC_STATE2 = 71;
62 ListViewScreen::ListViewScreen(QWidget *parent)
66 m_leftSideBar = new Pixmap(QPixmap(":/res/images/side_bar_left.png"));
67 m_slidingLeftSideBar = new Pixmap(QPixmap(":/res/images/sliding_bar_left.png"));
68 m_personalInfoBackGround = new Pixmap(QPixmap(":/res/images/personal_info_bckgrnd.png"));
69 m_arrowLeft = new Pixmap(QPixmap(":/res/images/arrow_left.png"));
70 m_arrowRight = new Pixmap(QPixmap(":/res/images/arrow_right.png"));
71 m_personalInfo = new InfoTab;
72 m_personalInfo->setAvatar(QPixmap(":/res/images/situare_user.jpg"));
73 m_personalInfo->setUserName("Fred Facebook");
74 m_personalInfo->setMessageText("Hello Maemo Situare !");
75 m_personalInfo->setTime("1 hour ago");
76 m_personalInfo->setAddress("Kiviharjunlenkki 1E, 91910 Oulu");
78 qDebug() << "InfoTab width: " << m_personalInfo->width();
79 qDebug() << "InfoTab heigth: " << m_personalInfo->height();
81 m_locationDialog = new UpdateLocationDialog(this);
82 m_widgetProxy = new QGraphicsProxyWidget();
83 m_widgetProxy->setWidget(m_personalInfo);
85 QGraphicsScene *scene= new QGraphicsScene(this);
86 scene->setBackgroundBrush(Qt::white);
87 scene->addItem(m_personalInfoBackGround);
88 scene->addItem(m_widgetProxy);
89 scene->addItem(m_leftSideBar);
90 scene->addItem(m_slidingLeftSideBar);
91 scene->addItem(m_arrowRight);
92 scene->addItem(m_arrowLeft);
93 m_leftSideBar->setPos(0,0);
95 QGraphicsView *view = new QGraphicsView(scene);
96 view->setAlignment(Qt::AlignLeft|Qt::AlignTop);
97 view->setSceneRect(0,0,7000,3000);
98 view->centerOn(QPointF(0,0));
99 view->setFrameStyle(0);
100 view->setAlignment(Qt::AlignLeft | Qt::AlignTop);
101 view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
102 view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
104 QStateMachine *machine = new QStateMachine(this);
105 machine->setGlobalRestorePolicy(QStateMachine::RestoreProperties);
107 QState *state1 = new QState(machine);
108 QState *state2 = new QState(machine);
109 machine->setInitialState(state1);
112 state1->assignProperty(m_widgetProxy,"pos",QPointF(-m_personalInfo->width(),
113 INFOTAB_Y_LOC_STATE1));
114 state1->assignProperty(m_slidingLeftSideBar,"pos",
115 QPointF(SLIDING_BAR_X_LOC_STATE1,SLIDING_BAR_Y_LOC_STATE1));
116 state1->assignProperty(m_personalInfoBackGround,"pos",
117 QPointF(-BACKGROUND_X_LOC_STATE1,BACKGROUND_Y_LOC_STATE1));
118 state1->assignProperty(m_arrowRight,"pos", QPointF(RIGHTARROW_X_LOC_STATE1,
119 RIGHTARROW_Y_LOC_STATE1));
120 state1->assignProperty(m_arrowLeft,"pos", QPointF(LEFTARROW_X_LOC_STATE2,
121 LEFTARROW_Y_LOC_STATE2));
122 state1->assignProperty(m_arrowRight,"visible", true);
123 state1->assignProperty(m_arrowLeft,"visible", false);
126 state2->assignProperty(m_widgetProxy,"pos",QPointF(INFOTAB_X_LOC_STATE2,INFOTAB_Y_LOC_STATE2));
127 state2->assignProperty(m_slidingLeftSideBar,"pos",QPointF(SLIDING_BAR_X_LOC_STATE2,
128 SLIDING_BAR_Y_LOC_STATE2));
129 state2->assignProperty(m_personalInfoBackGround,"pos",QPointF(BACKGROUND_X_LOC_STATE2,
130 BACKGROUND_Y_LOC_STATE2));
131 state2->assignProperty(m_arrowRight,"pos", QPointF(RIGHTARROW_X_LOC_STATE2,
132 RIGHTARROW_Y_LOC_STATE2));
133 state2->assignProperty(m_arrowLeft,"pos", QPointF(LEFTARROW_X_LOC_STATE2,
134 LEFTARROW_Y_LOC_STATE2));
135 state2->assignProperty(m_arrowRight,"visible", false);
136 state2->assignProperty(m_arrowLeft,"visible", true);
138 m_trans1 = state1->addTransition(m_slidingLeftSideBar,SIGNAL(clicked()),state2);
139 m_anim1 = new QPropertyAnimation(m_widgetProxy,"pos");
140 m_anim2 = new QPropertyAnimation(m_slidingLeftSideBar,"pos");
141 m_anim3 = new QPropertyAnimation(m_personalInfoBackGround,"pos");
142 m_anim4 = new QPropertyAnimation(m_arrowRight,"pos");
143 m_anim5 = new QPropertyAnimation(m_arrowLeft,"pos");
144 m_anim6 = new QPropertyAnimation(m_arrowRight,"visible");
145 m_anim7 = new QPropertyAnimation(m_arrowLeft,"visible");
146 m_trans1->addAnimation(m_anim1);
147 m_trans1->addAnimation(m_anim2);
148 m_trans1->addAnimation(m_anim3);
149 m_trans1->addAnimation(m_anim4);
150 m_trans1->addAnimation(m_anim5);
151 m_trans1->addAnimation(m_anim6);
152 m_trans1->addAnimation(m_anim7);
154 m_trans2 = state2->addTransition(m_slidingLeftSideBar,SIGNAL(clicked()),state1);
155 m_anim8 = new QPropertyAnimation(m_widgetProxy,"pos");
156 m_anim9 = new QPropertyAnimation(m_slidingLeftSideBar,"pos");
157 m_anim10 = new QPropertyAnimation(m_personalInfoBackGround,"pos");
158 m_anim11 = new QPropertyAnimation(m_arrowRight,"pos");
159 m_anim12 = new QPropertyAnimation(m_arrowLeft,"pos");
160 m_anim13 = new QPropertyAnimation(m_arrowRight,"visible");
161 m_anim14 = new QPropertyAnimation(m_arrowLeft,"visible");
162 m_trans2->addAnimation(m_anim8);
163 m_trans2->addAnimation(m_anim9);
164 m_trans2->addAnimation(m_anim10);
165 m_trans2->addAnimation(m_anim11);
166 m_trans2->addAnimation(m_anim12);
167 m_trans2->addAnimation(m_anim13);
168 m_trans2->addAnimation(m_anim14);
171 m_vbox = new QVBoxLayout(this);
172 m_vbox->addWidget(view);
173 m_vbox->setMargin(0);
175 connect(m_personalInfo,SIGNAL(launchMessageUpdate()),this,SLOT(updateMessage()));
178 ListViewScreen::~ListViewScreen()
180 delete m_personalInfo;
181 delete m_leftSideBar;
182 delete m_slidingLeftSideBar;
183 delete m_personalInfoBackGround;
205 void ListViewScreen::updateMessage()
207 qDebug() << __PRETTY_FUNCTION__;
208 m_locationDialog->exec();