Copyright (C) 2010 Ixonos Plc. Authors:
Kaj Wallin - kaj.wallin@ixonos.com
+ Jukka Saastamoinen jukka.saastamoinen@ixonos.com
Situare is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
USA.
*/
+#include <QGraphicsScene>
+#include <QGraphicsView>
+#include <QGraphicsWidget>
+#include <QtGui/QVBoxLayout>
+#include <QGraphicsProxyWidget>
+#include <QStateMachine>
#include "listviewscreen.h"
+#include <QDebug>
ListViewScreen::ListViewScreen(QWidget *parent)
- : QWidget(parent)
+ : QWidget(parent)
{
- QPushButton *listViewButton = new QPushButton(tr("This is listview"));
- QHBoxLayout *listViewLayout = new QHBoxLayout;
- listViewLayout->addWidget(listViewButton);
- setLayout(listViewLayout);
- setObjectName("List view");
+
+ m_arrowbutton = new Pixmap(QPixmap(":/res/images/arrow_right.png"));
+
+ m_personalInfo = new InfoTab;
+ m_personalInfo->setAvatar(QPixmap(":/res/images/facebook_user_64.png"));
+ m_personalInfo->setUserName("Fred Facebook");
+ m_personalInfo->setMessageText("Hello Maemo Situare !");
+ m_personalInfo->setTime("1 hour ago");
+ m_personalInfo->setAddress("Kiviharjunlenkki 1E, 91910 Oulu");
+
+
+ m_widgetProxy = new QGraphicsProxyWidget();
+ m_widgetProxy->setWidget(m_personalInfo);
+
+ QGraphicsScene *scene= new QGraphicsScene(this);
+ scene->setBackgroundBrush(Qt::white);
+ scene->addItem(m_widgetProxy);
+ scene->addItem(m_arrowbutton);
+ qDebug() << "Scene width: " << scene->width();
+ qDebug() << "Scene heigth: " << scene->height();
+
+ QGraphicsView *view = new QGraphicsView(scene);
+ view->setAlignment(Qt::AlignLeft|Qt::AlignTop);
+ view->setSceneRect(0,0,7000,3000);
+ view->centerOn(QPointF(0,0));
+ view->setFrameStyle(0);
+ view->setAlignment(Qt::AlignLeft | Qt::AlignTop);
+ view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+ QStateMachine *machine = new QStateMachine(this);
+ machine->setGlobalRestorePolicy(QStateMachine::RestoreProperties);
+
+ QState *state1 = new QState(machine);
+ QState *state2 = new QState(machine);
+ machine->setInitialState(state1);
+
+ // State 1
+ state1->assignProperty(m_widgetProxy,"pos",QPointF(-(m_personalInfo->width()),0));
+ state1->assignProperty(m_arrowbutton,"pos",QPointF(0,(m_personalInfo->height()/4)));
+
+ // State 2
+ state2->assignProperty(m_widgetProxy,"pos",QPointF(0,0));
+ state2->assignProperty(m_arrowbutton,"pos",QPointF((m_personalInfo->width()),(m_personalInfo->height()/4)));
+
+ m_trans1 = state1->addTransition(m_arrowbutton,SIGNAL(clicked()),state2);
+ m_anim1 = new QPropertyAnimation(m_widgetProxy,"pos");
+ m_anim2 = new QPropertyAnimation(m_arrowbutton,"pos");
+ m_trans1->addAnimation(m_anim1);
+ m_trans1->addAnimation(m_anim2);
+
+ m_trans2 = state2->addTransition(m_arrowbutton,SIGNAL(clicked()),state1);
+ m_anim3= new QPropertyAnimation(m_widgetProxy,"pos");
+ m_anim4= new QPropertyAnimation(m_arrowbutton,"pos");
+ m_trans2->addAnimation(m_anim3);
+ m_trans2->addAnimation(m_anim4);
+
+ machine->start();
+
+ m_vbox = new QVBoxLayout(this);
+ m_vbox->addWidget(view);
+ m_vbox->setMargin(0);
+
+ setObjectName("List view");
+
+ //connect(m_personalInfo,SIGNAL(launchMessageUpdate()),this,SLOT(updateMessage()));
+}
+
+ListViewScreen::~ListViewScreen()
+{
+ if (m_personalInfo)
+ delete m_personalInfo;
+ if (m_arrowbutton)
+ delete m_arrowbutton;
+ if (m_trans1)
+ delete m_trans1;
+ if (m_trans2)
+ delete m_trans2;
+ if (m_anim1)
+ delete m_anim1;
+ if (m_anim2)
+ delete m_anim2;
+ if (m_anim3)
+ delete m_anim3;
+ if (m_anim4)
+ delete m_anim4;
+ if (m_vbox)
+ delete m_vbox;
+}
+
+void ListViewScreen::updateMessage()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+// m_locationDialog->exec();
}