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"
34 ListViewScreen::ListViewScreen(QWidget *parent)
37 Pixmap *arrowbutton = new Pixmap(QPixmap(":/resources/arrow_right.png"));
39 InfoTab *personalInfo = new InfoTab;
40 personalInfo->setAvatar(QPixmap(":/resources/facebook_user_64.png"));
41 personalInfo->setUserName("Fred Facebook");
42 personalInfo->setMessageText("Hello Maemo Situare !");
43 personalInfo->setTime("1 hour ago");
44 personalInfo->setAddress("Kiviharjunlenkki 1E, 91910 Oulu");
46 QGraphicsProxyWidget *widgetProxy = new QGraphicsProxyWidget();
47 widgetProxy->setWidget(personalInfo);
49 QGraphicsScene *scene= new QGraphicsScene();
50 QGraphicsWidget *graphWidget = new QGraphicsWidget();
51 graphLayout = new QGraphicsLinearLayout(graphWidget);
52 graphLayout->setOrientation(Qt::Horizontal);
53 graphLayout->addItem(widgetProxy);
54 scene->setBackgroundBrush(Qt::white);
55 scene->addItem(graphWidget);
56 scene->addItem(arrowbutton);
57 qDebug() << "Scene width: " << scene->width();
58 qDebug() << "Scene heigth: " << scene->height();
60 QGraphicsView *view = new QGraphicsView(scene);
61 view->setAlignment(Qt::AlignLeft|Qt::AlignTop);
62 view->setSceneRect(0,0,7000,3000);
63 view->centerOn(QPointF(0,0));
64 view->setFrameStyle(0);
65 view->setAlignment(Qt::AlignLeft | Qt::AlignTop);
66 view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
67 view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
69 QStateMachine *machine = new QStateMachine;
70 machine->setGlobalRestorePolicy(QStateMachine::RestoreProperties);
72 QState *state1 = new QState(machine);
73 QState *state2 = new QState(machine);
74 machine->setInitialState(state1);
77 state1->assignProperty(graphWidget,"pos",QPointF(-(personalInfo->width()+20),0));
78 state1->assignProperty(arrowbutton,"pos",QPointF(0,(arrowbutton->boundingRect().height()/2)+10));
81 state2->assignProperty(graphWidget,"pos",QPointF(-20,0));
82 state2->assignProperty(arrowbutton,"pos",QPointF((personalInfo->width()-5),(arrowbutton->boundingRect().height()/2)+10));
84 QAbstractTransition *trans1 = state1->addTransition(arrowbutton,SIGNAL(clicked()),state2);
85 trans1->addAnimation(new QPropertyAnimation(graphWidget,"pos"));
86 trans1->addAnimation(new QPropertyAnimation(arrowbutton,"pos"));
88 QAbstractTransition *trans2 = state2->addTransition(arrowbutton,SIGNAL(clicked()),state1);
89 trans2->addAnimation(new QPropertyAnimation(graphWidget,"pos"));
90 trans2->addAnimation(new QPropertyAnimation(arrowbutton,"pos"));
94 vbox = new QVBoxLayout(this);
95 vbox->addWidget(view);
98 ListViewScreen::~ListViewScreen()