b93c4ef936e4166fc174ea5fdef6e4d8d4d17086
[situare] / src / ui / listviewscreen.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       Jukka Saastamoinen jukka.saastamoinen@ixonos.com
7
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.
11
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.
16
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,
20    USA.
21 */
22
23 #include <QGraphicsScene>
24 #include <QGraphicsWidget>
25 #include <QGraphicsView>
26 #include <QtGui/QVBoxLayout>
27 #include <QStateMachine>
28 #include "listviewscreen.h"
29 #include "pixmap.h"
30
31 ListViewScreen::ListViewScreen(QWidget *parent)
32    : QWidget(parent)
33 {
34     Pixmap *infoTab = new Pixmap(QPixmap(":/resources/dummy_personal_infotab_background.png")); //350x300 pix
35     Pixmap *userPic = new Pixmap(QPixmap(":/resources/facebook_user_64.png")); //64x64 pix
36     QGraphicsScene *scene= new QGraphicsScene(0,0,700,360);
37     scene->setBackgroundBrush(Qt::white);
38     scene->addItem(infoTab);
39     scene->addItem(userPic);
40
41     QGraphicsView *view = new QGraphicsView(scene);
42     view->setFrameStyle(0);
43     view->setAlignment(Qt::AlignLeft | Qt::AlignTop);
44     view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
45     view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
46
47
48     QStateMachine *machine = new QStateMachine;
49     machine->setGlobalRestorePolicy(QStateMachine::RestoreProperties);
50
51     QState *state1 = new QState(machine);
52     QState *state2 = new QState(machine);
53     machine->setInitialState(state1);
54
55     // State 1
56     state1->assignProperty(infoTab,"pos",QPointF(-330,30));
57     state1->assignProperty(userPic,"pos",QPointF(-310,50));
58     // State 2
59     state2->assignProperty(infoTab,"pos",QPointF(0,30));
60     state2->assignProperty(userPic,"pos",QPointF(20,50));
61
62
63     QAbstractTransition *trans1 = state1->addTransition(infoTab,SIGNAL(clicked()),state2);
64     trans1->addAnimation(new QPropertyAnimation(infoTab,"pos"));
65     trans1->addAnimation(new QPropertyAnimation(userPic,"pos"));
66
67     QAbstractTransition *trans2 = state2->addTransition(infoTab,SIGNAL(clicked()),state1);
68     trans2->addAnimation(new QPropertyAnimation(infoTab,"pos"));
69     trans2->addAnimation(new QPropertyAnimation(userPic,"pos"));
70
71     machine->start();
72
73     vbox = new QVBoxLayout(this);
74     vbox->addWidget(view);
75 }
76
77 ListViewScreen::~ListViewScreen()
78 {
79     if (vbox)
80         delete vbox;
81 }