diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-05-20 09:49:17 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-05-20 09:49:17 (GMT) |
commit | 66f78ca4352aeb93586d920ad3905394b15f3c0d (patch) | |
tree | 217ae4e1cd85f4dfcbcaf44e55fe511e72f508d0 /examples | |
parent | c21803201a607dabc1d5a9345004d8f5dbc02d25 (diff) | |
download | Qt-66f78ca4352aeb93586d920ad3905394b15f3c0d.zip Qt-66f78ca4352aeb93586d920ad3905394b15f3c0d.tar.gz Qt-66f78ca4352aeb93586d920ad3905394b15f3c0d.tar.bz2 |
Remove old examples and demos for animations
Diffstat (limited to 'examples')
32 files changed, 0 insertions, 3078 deletions
diff --git a/examples/animation/example/example.pro b/examples/animation/example/example.pro deleted file mode 100644 index bc79b82..0000000 --- a/examples/animation/example/example.pro +++ /dev/null @@ -1,12 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Thu Sep 25 14:03:47 2008 -###################################################################### - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input -HEADERS += mainwindow.h -SOURCES += main.cpp mainwindow.cpp diff --git a/examples/animation/example/main.cpp b/examples/animation/example/main.cpp deleted file mode 100644 index 1180b4f..0000000 --- a/examples/animation/example/main.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui> -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - //Q_INIT_RESOURCE(example); - QApplication app(argc, argv); - MainWindow w; - w.show(); - return app.exec(); -} - diff --git a/examples/animation/example/mainwindow.cpp b/examples/animation/example/mainwindow.cpp deleted file mode 100644 index 4aff384..0000000 --- a/examples/animation/example/mainwindow.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "mainwindow.h" - -MainWindow::MainWindow() : QMainWindow(0) -{ - // Text edit and button - listWidget = new QListWidget; - new QListWidgetItem("Rachel", listWidget); - new QListWidgetItem("Andreas", listWidget); - new QListWidgetItem("David", listWidget); - new QListWidgetItem("Olivier", listWidget); - new QListWidgetItem("Andy", listWidget); - new QListWidgetItem("Martial", listWidget); - new QListWidgetItem("Kazou", listWidget); - new QListWidgetItem("Fred", listWidget); - new QListWidgetItem("Ingrid", listWidget); - QGraphicsProxyWidget *listProxy = new QGraphicsProxyWidget; - listProxy->setWidget(listWidget); - - labelWidget = new QLabel; - QGraphicsProxyWidget *labelProxy = new QGraphicsProxyWidget; - labelProxy->setWidget(labelWidget); - labelWidget->setAttribute(Qt::WA_NoSystemBackground); - - label2Widget = new QLabel; - label2Widget->setAlignment(Qt::AlignCenter); - QGraphicsProxyWidget *label2Proxy = new QGraphicsProxyWidget; - label2Proxy->setWidget(label2Widget); - label2Widget->setAttribute(Qt::WA_NoSystemBackground); - - editWidget = new QLineEdit; - QGraphicsProxyWidget *editProxy = new QGraphicsProxyWidget; - editProxy->setWidget(editWidget); - editWidget->setAttribute(Qt::WA_NoSystemBackground); - - // Parent widget - QGraphicsWidget *widget = new QGraphicsWidget; - // Parent widget - QGraphicsWidget *widget2 = new QGraphicsWidget; - - QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout(Qt::Vertical, widget); - vLayout->addItem(listProxy); - vLayout->addItem(widget2); - widget->setLayout(vLayout); - - QPushButton *button = new QPushButton; - QGraphicsProxyWidget *buttonProxy = new QGraphicsProxyWidget; - buttonProxy->setWidget(button); - - QPushButton *button2 = new QPushButton; - QGraphicsProxyWidget *buttonProxy2 = new QGraphicsProxyWidget; - buttonProxy2->setWidget(button2); - - QPushButton *button3 = new QPushButton; - QGraphicsProxyWidget *buttonProxy3 = new QGraphicsProxyWidget; - buttonProxy3->setWidget(button3); - - QPushButton *button4 = new QPushButton; - QGraphicsProxyWidget *buttonProxy4 = new QGraphicsProxyWidget; - buttonProxy4->setWidget(button4); - - QGraphicsLinearLayout *hLayout = new QGraphicsLinearLayout(Qt::Horizontal, widget2); - hLayout->addItem(buttonProxy); - hLayout->addItem(buttonProxy2); - hLayout->addItem(buttonProxy3); - widget2->setLayout(hLayout); - - scene = new QGraphicsScene(0, 0, 700, 600); - scene->setBackgroundBrush(scene->palette().window()); - scene->addItem(widget); - scene->addItem(editProxy); - scene->addItem(label2Proxy); - scene->addItem(labelProxy); - scene->addItem(buttonProxy4); - - machine = new QStateMachine(); - - group = new QState(machine->rootState()); - state1 = new QState(group); - state2 = new QState(group); - state3 = new QState(group); - group->setInitialState(state1); - - machine->setInitialState(group); - - // State 1 - state1->assignProperty(button, "text", "Edit"); - state1->assignProperty(button2, "text", "Add"); - state1->assignProperty(button3, "text", "Remove"); - state1->assignProperty(button4, "text", "Accept"); - state1->addTransition(button2, SIGNAL(clicked()), state3); - state1->assignProperty(listProxy, "geometry", QRectF(0, 0, 700, 560)); - state1->assignProperty(widget, "geometry", QRectF(0, 0, 700, 600)); - state1->assignProperty(editProxy, "opacity", double(0)); - state1->assignProperty(labelProxy, "opacity", double(0)); - state1->assignProperty(label2Proxy, "opacity", double(0)); - state1->assignProperty(buttonProxy4, "opacity", double(0)); - state1->assignProperty(labelWidget, "text", "Name : "); - state1->assignProperty(label2Widget, "text", "Edit a contact"); - state1->assignProperty(label2Proxy, "geometry", QRectF(375, -50, 300, 30)); - state1->assignProperty(labelProxy, "geometry", QRectF(350, 300, 100, 30)); - state1->assignProperty(editProxy, "geometry", QRectF(750, 300, 250, 30)); - state1->assignProperty(buttonProxy4, "geometry", QRectF(500, 350, 80, 25)); - - // State 2 - state2->assignProperty(button, "text", "Close Editing"); - state2->assignProperty(listProxy, "geometry", QRectF(0, 0, 350, 560)); - state2->addTransition(button2, SIGNAL(clicked()), state3); - state2->addTransition(button4, SIGNAL(clicked()), state1); - - state2->assignProperty(editProxy, "opacity", double(1)); - state2->assignProperty(labelProxy, "opacity", double(1)); - state2->assignProperty(label2Proxy, "opacity", double(1)); - state2->assignProperty(buttonProxy4, "opacity", double(1)); - - state2->assignProperty(label2Proxy, "geometry", QRectF(375, 250, 300, 30)); - state2->assignProperty(editProxy, "geometry", QRectF(440, 300, 260, 30)); - - // State 3 - state3->assignProperty(button4, "text", "Create New"); - state3->assignProperty(listProxy, "geometry", QRectF(0, 0, 350, 560)); - state3->addTransition(button4, SIGNAL(clicked()), state1); - state3->addTransition(button, SIGNAL(clicked()), state1); - state3->assignProperty(editProxy, "opacity", double(1)); - state3->assignProperty(labelProxy, "opacity", double(1)); - state3->assignProperty(label2Proxy, "opacity", double(1)); - state3->assignProperty(buttonProxy4, "opacity", double(1)); - - state3->assignProperty(label2Proxy, "geometry", QRectF(375, 250, 300, 30)); - state3->assignProperty(editProxy, "geometry", QRectF(440, 300, 260, 30)); - - { - QAnimationGroup *animationGroup = new QParallelAnimationGroup; - QVariantAnimation *anim = new QPropertyAnimation(labelProxy, "opacity"); - animationGroup->addAnimation(anim); - anim = new QPropertyAnimation(label2Proxy, "geometry"); - animationGroup->addAnimation(anim); - anim = new QPropertyAnimation(editProxy, "geometry"); - animationGroup->addAnimation(anim); - anim = new QPropertyAnimation(listProxy, "geometry"); - animationGroup->addAnimation(anim); - - QAbstractTransition *trans = state1->addTransition(button, SIGNAL(clicked()), state2); - trans->addAnimation(animationGroup); - } - - { - QVariantAnimation *anim; - QAnimationGroup *animationGroup = new QParallelAnimationGroup; - anim = new QPropertyAnimation(label2Proxy, "geometry"); - animationGroup->addAnimation(anim); - anim = new QPropertyAnimation(editProxy, "geometry"); - animationGroup->addAnimation(anim); - anim = new QPropertyAnimation(listProxy, "geometry"); - animationGroup->addAnimation(anim); - QAbstractTransition *trans = state2->addTransition(button, SIGNAL(clicked()), state1); - trans->addAnimation(animationGroup); - } - - currentState = state1; - - view = new QGraphicsView(scene); - - setCentralWidget(view); - - QObject::connect(state3, SIGNAL(entered()), this, SLOT(onEnterState3())); - QObject::connect(state2, SIGNAL(entered()), this, SLOT(onEnterState2())); - QObject::connect(state1, SIGNAL(entered()), this, SLOT(onEnterState1())); - - connect(listWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(onItemClicked(QListWidgetItem*))); - connect(button3, SIGNAL(clicked()), this, SLOT(onRemoveClicked())); - - machine->start(); -} - -void MainWindow::onEnterState2() -{ - currentState = state2; - if (listWidget->currentItem()) - editWidget->setText(listWidget->currentItem()->text()); -} - -void MainWindow::onEnterState1() -{ - if (currentState == state2 && listWidget->currentItem()) - listWidget->currentItem()->setText(editWidget->text()); - if (currentState == state3 && !editWidget->text().isNull()) { - new QListWidgetItem(editWidget->text(), listWidget); - editWidget->clear(); - } - currentState = state1; -} - -void MainWindow::onEnterState3() -{ - currentState = state3; -} - -void MainWindow::onItemClicked(QListWidgetItem*) -{ - if (currentState == state2) - { - editWidget->setText(listWidget->currentItem()->text()); - editWidget->clear(); - } -} - -void MainWindow::onRemoveClicked() -{ - QListWidgetItem *listItem = listWidget->takeItem(listWidget->currentRow()); - delete listItem; -} diff --git a/examples/animation/example/mainwindow.h b/examples/animation/example/mainwindow.h deleted file mode 100644 index 163eb89..0000000 --- a/examples/animation/example/mainwindow.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef __MAINWINDOW__H__ -#define __MAINWINDOW__H__ - -#include <QtGui> - -class MainWindow : public QMainWindow -{ -Q_OBJECT -public: - MainWindow(); - -private slots : - void onEnterState3(); - void onEnterState2(); - void onEnterState1(); - void onItemClicked(QListWidgetItem*); - void onRemoveClicked(); -private: - QListWidget *listWidget; - QLabel *labelWidget; - QLabel *label2Widget; - QLineEdit *editWidget; - QGraphicsScene *scene; - QGraphicsView *view; - QState *state1; - QState *state2; - QState *state3; - QState *currentState; - QState *group; - QStateMachine *machine; -}; - -#endif //__MAINWINDOW__H__ - diff --git a/examples/animation/research/memberfunctions/main.cpp b/examples/animation/research/memberfunctions/main.cpp deleted file mode 100644 index 2663f9c..0000000 --- a/examples/animation/research/memberfunctions/main.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui> -#include "qvalueanimation.h" - -AbstractProperty *qGraphicsItemProperty(QGraphicsItem *item, const char *property) -{ - if (qstrcmp(property, "pos") == 0) { - return new MemberFunctionProperty<QGraphicsItem, QPointF>(item, &QGraphicsItem::pos, &QGraphicsItem::setPos); - } - return 0; -} - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - QGraphicsScene scene; - QGraphicsView view(&scene); - - QGraphicsItem *item = new QGraphicsRectItem(QRectF(0,0, 200, 100)); - scene.addItem(item); - - QValueAnimation *posAnim = new QValueAnimation; - posAnim->setStartValue(QPointF(0,0)); - posAnim->setEndValue(QPointF(400, 0)); - posAnim->setDuration(1000); - // Alternative 1 - //posAnim->setMemberFunction(item, &QGraphicsItem::pos, &QGraphicsItem::setPos); - - // Alternative 2 - //posAnim->setProperty(qMemberFunctionProperty(item, &QGraphicsItem::pos, &QGraphicsItem::setPos)); - - // Alternative 3 - posAnim->setProperty(qGraphicsItemProperty(item, "pos")); - - // Alternative 4, (by implementing the qGraphicsItemProperty QGraphicsItem::property()) - //posAnim->setProperty(item->property("pos")); - - // can also do this, which abstracts away the whole property thing. - // i.e. this interface can also be used for QObject-properties: - //posAnim->setAnimationProperty(animationProperty); - - posAnim->start(); - - view.resize(800,600); - view.show(); - return app.exec(); -} - diff --git a/examples/animation/research/memberfunctions/memberfunctions.pro b/examples/animation/research/memberfunctions/memberfunctions.pro deleted file mode 100644 index 6b67895..0000000 --- a/examples/animation/research/memberfunctions/memberfunctions.pro +++ /dev/null @@ -1,16 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) fr 26. sep 13:21:57 2008 -###################################################################### - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input -SOURCES += main.cpp \ - qvalueanimation.cpp -HEADERS += qvalueanimation.h - -CONFIG += console - diff --git a/examples/animation/research/memberfunctions/qvalueanimation.cpp b/examples/animation/research/memberfunctions/qvalueanimation.cpp deleted file mode 100644 index de0b8ff..0000000 --- a/examples/animation/research/memberfunctions/qvalueanimation.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qvalueanimation.h" -#include "qvalueanimation_p.h" - -QT_BEGIN_NAMESPACE - - -void QValueAnimationPrivate::initDefaultStartValue() -{ - Q_Q(QValueAnimation); - if (animProp && !q->startValue().isValid() - && (currentTime == 0 - || (currentTime == duration && currentLoop == (loopCount - 1)))) { - setDefaultStartValue(animProp->read()); - } -} - - -QValueAnimation::QValueAnimation(QObject *parent) : QVariantAnimation(*new QValueAnimationPrivate, parent) -{ -} - -QValueAnimation::~QValueAnimation() -{ -} - -void QValueAnimation::setProperty(AbstractProperty *animProp) -{ - Q_D(QValueAnimation); - d->animProp = animProp; -} - -/*! - \reimp - */ -void QValueAnimation::updateCurrentValue(const QVariant &value) -{ - Q_D(QValueAnimation); - if (state() == QAbstractAnimation::Stopped) - return; - - d->animProp->write(value); -} - - -/*! - \reimp -*/ -void QValueAnimation::updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState) -{ - Q_D(QValueAnimation); - // Initialize start value - if (oldState == QAbstractAnimation::Stopped && newState == QAbstractAnimation::Running) - d->initDefaultStartValue(); -} - - - -#include "moc_qvalueanimation.cpp" - -QT_END_NAMESPACE diff --git a/examples/animation/research/memberfunctions/qvalueanimation.h b/examples/animation/research/memberfunctions/qvalueanimation.h deleted file mode 100644 index 17e9817..0000000 --- a/examples/animation/research/memberfunctions/qvalueanimation.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVALUEANIMATION_H -#define QVALUEANIMATION_H - -#include <QtCore/qvariantanimation.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGraphicsItem; -class QValueAnimationPrivate; - -QT_MODULE(Gui) - -struct AbstractProperty { - virtual void write(const QVariant &value) = 0; - virtual QVariant read() const = 0; -}; - -# define CALL_MEMBER_FN(object,ptrToMember) ((object)->*(ptrToMember)) -template <typename Target, typename T> -class MemberFunctionProperty : public AbstractProperty { -public: - typedef void (Target::*RefWrite)(const T &); - typedef T (Target::*ValRead)(void) const; - - MemberFunctionProperty(Target *target, ValRead readFunc, RefWrite writeFunc) - : m_target(target), m_readFn(readFunc), m_writeFn(writeFunc) {} - - virtual void write(const QVariant &value) { - CALL_MEMBER_FN(m_target, m_writeFn)(qVariantValue<T>(value)); - } - - virtual QVariant read() const { - if (m_readFn) - return qVariantFromValue<T>(CALL_MEMBER_FN(m_target, m_readFn)()); - return QVariant(); - } - -private: - Target *m_target; - ValRead m_readFn; - RefWrite m_writeFn; -}; - - -class QValueAnimation : public QVariantAnimation -{ - Q_OBJECT - -public: - QValueAnimation(QObject *parent = 0); - ~QValueAnimation(); - - template <typename Target, typename T> - void setMemberFunction(Target *target, - T (Target::*readFunc)(void) const, // ### useValRead typedef - void (Target::*writeFunc)(const T &) // ### use RefWrite typedef - ) { - // ### ownership of MemberFunctionProperty - AbstractProperty *animProp = new MemberFunctionProperty<Target, T>(target, readFunc, writeFunc); - setProperty(animProp); - } - - void updateCurrentValue(const QVariant &value); - void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState); - void setProperty(AbstractProperty *animProp); - -private: - Q_DISABLE_COPY(QValueAnimation); - Q_DECLARE_PRIVATE(QValueAnimation); -}; - -#endif // QVALUEANIMATION_H diff --git a/examples/animation/research/memberfunctions/qvalueanimation_p.h b/examples/animation/research/memberfunctions/qvalueanimation_p.h deleted file mode 100644 index 55c8ce1..0000000 --- a/examples/animation/research/memberfunctions/qvalueanimation_p.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVALUEANIMATION_P_H -#define QVALUEANIMATION_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of QIODevice. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <private/qvariantanimation_p.h> //### - -QT_BEGIN_NAMESPACE - -class QValueAnimationPrivate : public QVariantAnimationPrivate -{ - Q_DECLARE_PUBLIC(QValueAnimation) -public: - QValueAnimationPrivate() : QVariantAnimationPrivate(), animProp(0) - { - } - - void initDefaultStartValue(); - - AbstractProperty *animProp; - - //###TODO -}; - -QT_END_NAMESPACE - -#endif //QVALUEANIMATION_P_H diff --git a/examples/animation/research/photobrowser/main.cpp b/examples/animation/research/photobrowser/main.cpp deleted file mode 100644 index d5ab2a3..0000000 --- a/examples/animation/research/photobrowser/main.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui> - -#include "river.h" -#include "menu.h" - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - if (app.arguments().size() == 1) { - qWarning("you have to specifiy a path to look for the photos"); - return 0; - } - - - QGraphicsScene scene; - scene.setSceneRect(QRectF(QPointF(), River::fixedSize())); - - QGraphicsView view(&scene); - view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - const int fw = view.frameWidth() * 2; - view.setFixedSize(River::fixedSize() + QSize(fw,fw)); - - River river(app.arguments()[1]); - scene.addItem(&river); - - Menu menu(&river); - menu.addAction(QLatin1String("River Mode"), &river, SLOT(setRiverMode())); - menu.addAction(QLatin1String("Grid Mode"), &river, SLOT(setGridMode())); - menu.addAction(QLatin1String("Cover Flow"), &river, SLOT(setCoverMode())); - menu.addAction(QLatin1String("Hide Menu"), &menu, SLOT(hide())); - menu.addAction(QLatin1String("Exit"), &app, SLOT(quit())); - menu.setZValue(2); - menu.setFocus(); - - river.menu = &menu; - view.show(); - - return app.exec(); -} diff --git a/examples/animation/research/photobrowser/menu.cpp b/examples/animation/research/photobrowser/menu.cpp deleted file mode 100644 index 97493ba..0000000 --- a/examples/animation/research/photobrowser/menu.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "menu.h" - -Menu::Menu(QGraphicsItem *parent) : QGraphicsWidget(parent), m_selected(0) -{ - setFlag(QGraphicsItem::ItemIsFocusable); - m_selection = new QGraphicsRectItem(this); - QLinearGradient linearGrad(QPointF(0, 0), QPointF(0,50)); - linearGrad.setColorAt(0, QColor(255,255,255,128)); - linearGrad.setColorAt(1, QColor(255,255,255,16)); - m_selection->setBrush(linearGrad); - m_selection->setPen(QPen(Qt::transparent)); -} - -Menu::~Menu() -{ -} - - -MenuAction *Menu::addAction(const QString &text, QObject *receiver, const char* slot) -{ - MenuAction *action = new MenuAction(text, this); - if (!m_actions.isEmpty()) { - MenuAction *last = m_actions.last(); - action->setPos(last->pos() + last->boundingRect().bottomLeft()); - } - m_actions.append(action); - if (m_selection->boundingRect().width() < action->boundingRect().width()) - m_selection->setRect(action->boundingRect()); - - QObject::connect(action, SIGNAL(triggered()), receiver, slot); - return action; -} - -QRectF Menu::boundingRect() const -{ - QRectF res; - foreach (MenuAction *a, m_actions) - res |= a->boundingRect(); - return res; -} - -void Menu::keyPressEvent (QKeyEvent * event) -{ - switch (event->key()) { - case Qt::Key_Escape: - hide(); - break; - case Qt::Key_Up: - m_selected -= 2; - case Qt::Key_Down: - if (!m_actions.isEmpty()) { - m_selected = (m_selected + 1 + m_actions.count()) % m_actions.count(); - QItemAnimation *anim = new QItemAnimation(m_selection, QItemAnimation::Position); - anim->setEndValue(m_actions.at(m_selected)->pos()); - anim->start(QAbstractAnimation::DeleteWhenStopped); - } - break; - case Qt::Key_Enter: - case Qt::Key_Return: - if (!m_actions.isEmpty()) { - QItemAnimation *anim = new QItemAnimation(m_selection, QItemAnimation::RotationX); - anim->setEndValue(m_selection->xRotation() < 180 ? qreal(360) : qreal(0)); - anim->start(QAbstractAnimation::DeleteWhenStopped); - m_actions.at(m_selected)->trigger(); - hide(); - } - break; - default: - QGraphicsItem::keyPressEvent(event); - } -} - -void Menu::show() -{ - QItemAnimation *anim = new QItemAnimation(this, QItemAnimation::Opacity); - anim->setEndValue(qreal(1.)); - anim->start(QAbstractAnimation::DeleteWhenStopped); - anim = new QItemAnimation(m_selection, QItemAnimation::ScaleFactorX); - anim->setEndValue(qreal(1)); - anim->start(QAbstractAnimation::DeleteWhenStopped); - anim = new QItemAnimation(m_selection, QItemAnimation::ScaleFactorY); - anim->setEndValue(qreal(1)); - anim->start(QAbstractAnimation::DeleteWhenStopped); - setFocus(); -} - -void Menu::hide() -{ - QItemAnimation *anim = new QItemAnimation(m_selection, QItemAnimation::ScaleFactorX); - anim->setEndValue(qreal(.1)); - anim->start(QAbstractAnimation::DeleteWhenStopped); - anim = new QItemAnimation(m_selection, QItemAnimation::ScaleFactorY); - anim->setEndValue(qreal(.1)); - anim->start(QAbstractAnimation::DeleteWhenStopped); - anim = new QItemAnimation(this, QItemAnimation::Opacity); - anim->setEndValue(qreal(0)); - anim->start(QAbstractAnimation::DeleteWhenStopped); - parentItem()->setFocus(); -} - - -MenuAction::MenuAction(const QString &text, Menu * parent) - : QGraphicsTextItem(text,parent) -{ - QFont f = font(); - f.setPointSize(18); - setFont(f); - setDefaultTextColor(Qt::white); -} - -void MenuAction::trigger() -{ - emit triggered(); -} diff --git a/examples/animation/research/photobrowser/menu.h b/examples/animation/research/photobrowser/menu.h deleted file mode 100644 index 3bdfe45..0000000 --- a/examples/animation/research/photobrowser/menu.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef __MENU__H__ -#define __MENU__H__ - -#include <QtGui> - -class MenuAction; - -class Menu : public QGraphicsWidget -{ - Q_OBJECT -public: - Menu(QGraphicsItem *parent); - ~Menu(); - - MenuAction *addAction(const QString&, QObject *receiver = 0, const char* slot = 0 ); - - QRectF boundingRect() const; - void keyPressEvent ( QKeyEvent * event ); -public slots: - void show(); - void hide(); -private: - QList<MenuAction*> m_actions; - QGraphicsRectItem *m_selection; - int m_selected; -}; - -class MenuAction : public QGraphicsTextItem -{ - Q_OBJECT -public: - MenuAction(const QString &text, Menu * parent); - void trigger(); -signals: - void triggered(); -}; - - -#endif //__RIVERITEM__H__ diff --git a/examples/animation/research/photobrowser/photobrowser.pro b/examples/animation/research/photobrowser/photobrowser.pro deleted file mode 100644 index 21f03d6..0000000 --- a/examples/animation/research/photobrowser/photobrowser.pro +++ /dev/null @@ -1,17 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) ven. 22. août 13:09:33 2008 -###################################################################### - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input -SOURCES += main.cpp \ - river.cpp \ - riveritem.cpp \ - menu.cpp -HEADERS += river.h \ - riveritem.h \ - menu.h diff --git a/examples/animation/research/photobrowser/river.cpp b/examples/animation/research/photobrowser/river.cpp deleted file mode 100644 index 6760066..0000000 --- a/examples/animation/research/photobrowser/river.cpp +++ /dev/null @@ -1,591 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "river.h" -#include "riveritem.h" - -#include "qvariantanimation.h" - -#include <QtCore/QDebug> -#include <QtGui/QKeyEvent> -#include <QtGui/QGraphicsScene> -#include <QtGui/QPainter> - - -#define GRID_ROW_COUNT 3 -#define GRID_COLUMN_COUNT 2 -#define GRID_DIMENSIONS (GRID_ROW_COUNT * GRID_COLUMN_COUNT) -#define ITEM_COUNT 12 - -#define RIVER_MAGNIFY(ITEM) (qreal(0.50) + (ITEM)->zValue()*2 ) -#define GRID_MAGNIFY qreal(1.5) -#define GRID_CURRENT_MAGNIFY 2 - -River::River(const QString &path) : -m_images(QDir(path).entryInfoList(QStringList() << QLatin1String("*.jpg") << QLatin1String("*.png"))), -m_currentImage(0), m_mode(RiverMode), m_selectedItem(-1) , m_topLeftIndex(-1) -{ - setFocusPolicy(Qt::StrongFocus); - setGeometry(QRectF( QPointF(), fixedSize())); - - - for (int i = 0; i < ITEM_COUNT; ++i) { - RiverItem * item = new RiverItem(this); - - //here we also randomize the x position (not when looping) - const int x = qrand() % fixedSize().width(); - item->setPos(x, -1); - - m_items.insert(m_currentImage, item); - addUnusedRiverItem(item); - } - -} - -QPointF River::gridItemPosition(int row, int col) const -{ - if (col < 0) { - col += GRID_COLUMN_COUNT; - row --; - } - return QPointF(rect().width()*(col*2 + 1)/(GRID_COLUMN_COUNT*2), - rect().height()*(row*2 + 1)/(GRID_ROW_COUNT*2)); -} - -QPixmap River::pixmap(int index) const -{ - if (index < 0 || index >= m_images.size()) - return QPixmap(); - - if (m_pixmaps.size() <= index) { - m_pixmaps.resize(index+1); - } - - if (m_pixmaps.at(index).isNull()) { - m_pixmaps[index] = QPixmap(m_images.at(index).absoluteFilePath()); - } - - return m_pixmaps.at(index); -} - -void River::addUnusedRiverItem(RiverItem * item) -{ - if (m_images.isEmpty()) - return; - - QRectF realItemRect = item->mapToParent(item->boundingRect()).boundingRect(); - - int y = item->pos().y(); - int x = item->pos().x(); - if (x >= fixedSize().width() || x < -realItemRect.width() || y < 0) { - //we set the new pixmap - - m_items.remove(m_items.key(item)); - - while (m_items.contains(m_currentImage)) - m_currentImage = (m_currentImage + 1 ) % m_images.size(); - - item->setPixmap(pixmap(m_currentImage)); - - m_items.insert(m_currentImage, item); - //this manages looping as well - m_currentImage = (m_currentImage + 1 ) % m_images.size(); - - item->setZValue(qreal(qrand()%100)/200.0); - - QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::ScaleFactorX, scene()); - anim->setEndValue(RIVER_MAGNIFY(item)); - anim->start(QAbstractAnimation::DeleteWhenStopped); - anim = new QItemAnimation(item, QItemAnimation::ScaleFactorY, scene()); - anim->setEndValue(RIVER_MAGNIFY(item)); - anim->start(QAbstractAnimation::DeleteWhenStopped); - - realItemRect = item->mapToParent(item->boundingRect()).boundingRect(); - - y = -realItemRect.y() + qrand() % (fixedSize().height() - int(realItemRect.height())); - if (x >= fixedSize().width()) { - x = -realItemRect.width()/2; - } - } - - item->setPos(x, y); - - const QPointF target(QPointF(fixedSize().width() + realItemRect.width()/2, y)); - - const int distance = target.x() - x; - - const int duration = (40 - 50*item->zValue() ) * distance; - QItemAnimation *a = new QItemAnimation(item, QItemAnimation::Position, scene()); - a->setEndValue(target); - a->setDuration(duration); - a->start(QAbstractAnimation::DeleteWhenStopped); - connect(a, SIGNAL(finished()), SLOT(animationFinished())); -} - -void River::animationFinished() -{ - QItemAnimation *anim = qobject_cast<QItemAnimation*>(sender()); - if (!anim || anim->propertyName() != QItemAnimation::Position) - return; - - /*RiverItem *item = static_cast<RiverItem*>(anim->graphicsItem()); - if (m_mode != RiverMode) {*/ - /*int key = m_items.key(item); - if (key < m_topLeftIndex || key >= m_topLeftIndex + GRID_DIMENSIONS) { - delete item; - m_items.remove(key); - }*/ - //return; - - //} - - addUnusedRiverItem(static_cast<RiverItem*>(anim->targetItem())); -} - -void River::switchPaused() -{ - const bool paused = m_pausedAnimations.isEmpty(); - if (paused) - m_pausedAnimations = scene()->findChildren<QItemAnimation*>(); - - foreach(QItemAnimation *anim, m_pausedAnimations) { - if (paused) - anim->pause(); - else - anim->resume(); - } - - if (!paused) - m_pausedAnimations.clear(); -} - -void River::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) -{ - painter->fillRect(option->rect, Qt::black); -} - -void River::setMode(Mode m) -{ - if (m_mode == m) - return; - - Mode oldMode = m_mode; - m_mode = m; - switch(m) - { - case RiverMode: - m_mode = oldMode; //some animation may be stopt, and we don't want that animationFinished we were in that mode yet - foreach (RiverItem *item, m_items) { - const int x = qrand() % fixedSize().width(); - const int y = qrand() % fixedSize().width(); - QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::ScaleFactorX, scene()); - anim->setEndValue(RIVER_MAGNIFY(item)); - anim->start(QAbstractAnimation::DeleteWhenStopped); - anim = new QItemAnimation(item, QItemAnimation::ScaleFactorY, scene()); - anim->setEndValue(RIVER_MAGNIFY(item)); - anim->start(QAbstractAnimation::DeleteWhenStopped); - anim = new QItemAnimation(item, QItemAnimation::Position, scene()); - anim->setEndValue(QPointF(x, y)); - anim->start(QAbstractAnimation::DeleteWhenStopped); - connect(anim, SIGNAL(finished()), SLOT(animationFinished())); - } - m_mode = m; - break; - - case GridMode: - - if (oldMode == GridFullScreenMode) { - currentItem()->setFullScreen(false, GRID_CURRENT_MAGNIFY); - } else { - m_topLeftIndex = -GRID_DIMENSIONS; - foreach (RiverItem *item, m_items) { - QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::ScaleFactorX, scene()); - anim->setEndValue(GRID_MAGNIFY); - anim->start(QAbstractAnimation::DeleteWhenStopped); - anim = new QItemAnimation(item, QItemAnimation::ScaleFactorY, scene()); - anim->setEndValue(GRID_MAGNIFY); - anim->start(QAbstractAnimation::DeleteWhenStopped); - } - adjustGrid(m_currentImage - GRID_DIMENSIONS + 1); - setCurrentItem(m_topLeftIndex); - } - break; - case GridFullScreenMode: - //let's put the current item fullscreen - currentItem()->setFullScreen(true, GRID_CURRENT_MAGNIFY); - break; - case CoverMode: - m_gridItem = m_items.values(); - setCurrentItem(m_gridItem.count()/2); - default: - break; - } -} - -River::Mode River::mode() const -{ - return m_mode; -} - -QSize River::fixedSize() -{ - return QSize(352, 416); -} - -//the name of this method is not that good... -void River::makeCenterAvailable(qreal size) -{ - QRectF center(QPointF(), QSizeF(size, size)); - center.moveCenter(rect().center()); - - const QList<QGraphicsItem*> list = scene()->items(center); - - foreach(QGraphicsItem *item, m_items) { - - if (!list.contains(item)) - continue; - - QPointF pos = item->pos(); - - if (pos.y() < rect().center().y()) { - //item is above center - pos.ry() = center.top() - item->boundingRect().height() - 1; - } else { - //item is below the center - pos.ry() = center.bottom() + 1; - } - QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::Position, scene()); - anim->setEndValue(pos); - anim->setDuration(150); - anim->start(QAbstractAnimation::DeleteWhenStopped); - } -} - - -//this is there just to test small interaction -void River::keyPressEvent ( QKeyEvent * keyEvent ) -{ - switch(keyEvent->key()) - { - case Qt::Key_O: - { - QItemAnimation *anim = new QItemAnimation(this, QItemAnimation::Opacity, scene()); - anim->setDuration(2000); - anim->setEndValue(qreal(.5)); - anim->start(QAbstractAnimation::DeleteWhenStopped); - } - break; - case Qt::Key_N: - //that's a test - makeCenterAvailable(60); - break; - case Qt::Key_P: - switchPaused(); - break; - case Qt::Key_V: - setMode(GridMode); - break; - case Qt::Key_R: - setMode(RiverMode); - break; - case Qt::Key_C: - setMode(CoverMode); - break; - case Qt::Key_Return: - case Qt::Key_Enter: - if (m_mode == RiverMode) { - setMode(GridMode); - } else if (m_mode == GridMode) { - setMode(GridFullScreenMode); - } else if (m_mode == GridFullScreenMode) { - setMode(GridMode); - } - break; - case Qt::Key_Escape: - if (m_mode == GridFullScreenMode) { - setMode(GridMode); - } else if (m_mode == GridMode || m_mode == CoverMode) { - setMode(RiverMode); - } else if (m_mode == RiverMode) { - menu->show(); - } - break; - case Qt::Key_Right: - if (m_mode == GridMode) { - navigateBy(+1); - } else if (m_mode == CoverMode) { - setCurrentItem(m_selectedItem + 1); - } - break; - case Qt::Key_Left: - if (m_mode == GridMode) { - navigateBy(-1); - } else if (m_mode == CoverMode) { - setCurrentItem(m_selectedItem - 1); - } - break; - case Qt::Key_Down: - if (m_mode == GridMode) { - navigateBy(GRID_COLUMN_COUNT); - } - break; - case Qt::Key_Up: - if (m_mode == GridMode) { - navigateBy(-GRID_COLUMN_COUNT); - } - break; -// case Qt::Key_PageUp: - case Qt::Key_M: - menu->show(); - break; - case Qt::Key_Space: - if (m_mode == GridMode) { - RiverItem *item = currentItem(); - if(!item) - break; - - //stupid sequence. - QPointF pos = item->pos(); - QAnimationGroup *group = new QSequentialAnimationGroup(); - //item->animator()->beginSequence(); - - QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::Position, scene()); - anim->setEndValue(pos); - group->addAnimation(anim); - anim = new QItemAnimation(item, QItemAnimation::ScaleFactorX, scene()); - anim->setEndValue(qreal(1.)); - anim->setDuration(500); - group->addAnimation(anim); - anim = new QItemAnimation(item, QItemAnimation::ScaleFactorY, scene()); - anim->setEndValue(qreal(1.)); - anim->setDuration(500); - group->addAnimation(anim); - anim = new QItemAnimation(item, QItemAnimation::RotationX, scene()); - anim->setEndValue(qreal(0)); - group->addAnimation(anim); - group->start(QAbstractAnimation::DeleteWhenStopped); - } - default: - break; - } - - QGraphicsItem::keyPressEvent(keyEvent); -} - - -void River::setGridMode() -{ - setMode(GridMode); -} - -void River::setRiverMode() -{ - setMode(RiverMode); -} - -void River::setCoverMode() -{ - setMode(CoverMode); -} - - -void River::adjustGrid(int newTopLeft) -{ - for (int i = newTopLeft ; i < newTopLeft + GRID_DIMENSIONS; i++) { - if (!m_items.contains(i)) { - RiverItem *item = createItem(i); - int row = (i - m_topLeftIndex) / GRID_COLUMN_COUNT; - int col = (i - m_topLeftIndex) % GRID_COLUMN_COUNT; - item->setPos(gridItemPosition(row, col)); - item->setXScale(0); - item->setYScale(0); - QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::ScaleFactorX, scene()); - anim->setEndValue(GRID_MAGNIFY); - anim->start(QAbstractAnimation::DeleteWhenStopped); - anim = new QItemAnimation(item, QItemAnimation::ScaleFactorY, scene()); - anim->setEndValue(GRID_MAGNIFY); - anim->start(QAbstractAnimation::DeleteWhenStopped); - } - } - newTopLeft = newTopLeft - newTopLeft % GRID_COLUMN_COUNT; - - QHash<int, RiverItem *>::iterator it = m_items.begin(); - while (it != m_items.constEnd()) { - const int imageIdx = it.key(); - RiverItem *item = *it; - QSizeF itemSize = item->boundingRect().size(); - if ((imageIdx >= newTopLeft && imageIdx < newTopLeft + GRID_DIMENSIONS) - || boundingRect().adjusted(-itemSize.width()/2, -itemSize.height()/2, itemSize.width()/2, itemSize.height()/2) - .contains(item->pos())) { - int row = (imageIdx-newTopLeft) / GRID_COLUMN_COUNT; - int col = (imageIdx-newTopLeft) % GRID_COLUMN_COUNT; - QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::Position, scene()); - anim->setEndValue(gridItemPosition(row, col)); - anim->start(QAbstractAnimation::DeleteWhenStopped); - ++it; - } else { - ++it; /* ### ideally we should remove the items, but this cause the photobrowser to crash - because the QItemAnimations are not notified the item is deleted - delete item; - it = m_items.erase(it); - */ - } - } - - m_topLeftIndex = newTopLeft; -} - - -RiverItem *River::createItem(int imageIndex) -{ - Q_ASSERT(!m_items.contains(imageIndex)); - RiverItem * item = new RiverItem(this); - item->setPixmap(pixmap(imageIndex)); - m_items.insert(imageIndex,item); - return item; -} - -void River::setCurrentItem(int newCurrentItem) -{ - if (m_mode == CoverMode) - { - m_selectedItem = newCurrentItem; - for (int i = 0; i < m_gridItem.count(); i++) { - QVariantAnimation *anim; - RiverItem *item = m_gridItem.at(i); - - qreal rotation = 0; - qreal width = boundingRect().width() / 2; - qreal x = width; - qreal scale = 3; - qreal z = 1; - qreal y = boundingRect().height()/2; - - if (i < newCurrentItem - 4) { - item->setVisible(false); - item->setPos(QPointF(0, y)); - continue; - } else if(i > newCurrentItem + 4) { - item->setVisible(false); - item->setPos(QPointF(boundingRect().width(), y)); - continue; - } else if (i < newCurrentItem) { - x = (i - newCurrentItem + 4) * width/7; - rotation = -75; - scale = 2; - z = 1.+qreal(i-newCurrentItem)/10.; - } else if (i > newCurrentItem) { - x = width + (i - newCurrentItem + 3) * width/7; - rotation = 75; - scale = 2; - z = 1.-qreal(i-newCurrentItem)/8.; - } - - item->setVisible(true); - item->setZValue(z); - - anim = new QItemAnimation(item, QItemAnimation::RotationY, scene()); - anim->setEndValue(rotation); - anim->start(QAbstractAnimation::DeleteWhenStopped); - - anim = new QItemAnimation(item, QItemAnimation::ScaleFactorX, scene()); - anim->setEndValue(scale); - anim->start(QVariantAnimation::DeleteWhenStopped); - - anim = new QItemAnimation(item, QItemAnimation::ScaleFactorY, scene()); - anim->setEndValue(scale); - anim->start(QVariantAnimation::DeleteWhenStopped); - - anim = new QItemAnimation(item, QItemAnimation::Position, scene()); - anim->setEndValue(QPointF(x,y)); - anim->start(QVariantAnimation::DeleteWhenStopped); - } - return; - } - - - //deselect the current item - if (m_selectedItem >= 0 && m_items.contains(m_selectedItem)) { - RiverItem *item = m_items.value(m_selectedItem); - item->setZValue(qreal(qrand()%100)/200.0); - QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::ScaleFactorX, scene()); - anim->setEndValue(GRID_MAGNIFY); - anim->start(QAbstractAnimation::DeleteWhenStopped); - anim = new QItemAnimation(item, QItemAnimation::ScaleFactorY, scene()); - anim->setEndValue(GRID_MAGNIFY); - anim->start(QAbstractAnimation::DeleteWhenStopped); - } - - if (newCurrentItem < 0) { - m_selectedItem = newCurrentItem; - return; - } - - //ensure visible; - if (newCurrentItem < m_topLeftIndex) { - adjustGrid(newCurrentItem); - } else if (newCurrentItem >= m_topLeftIndex + GRID_DIMENSIONS) { - adjustGrid(newCurrentItem - GRID_DIMENSIONS + GRID_COLUMN_COUNT); - } - - //select the new one - m_selectedItem = newCurrentItem; - RiverItem *item = currentItem(); - Q_ASSERT(item); - item->setZValue(1); - - QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::ScaleFactorX, scene()); - anim->setEndValue(GRID_CURRENT_MAGNIFY); - anim->start(QAbstractAnimation::DeleteWhenStopped); - anim = new QItemAnimation(item, QItemAnimation::ScaleFactorY, scene()); - anim->setEndValue(GRID_CURRENT_MAGNIFY); - anim->start(QAbstractAnimation::DeleteWhenStopped); -} - -void River::navigateBy(int offset) -{ - int newSelection = m_selectedItem + offset; - const int imageCount = m_images.size(); - while (newSelection < 0) - newSelection += imageCount; - newSelection %= imageCount; - setCurrentItem(newSelection); -} diff --git a/examples/animation/research/photobrowser/river.h b/examples/animation/research/photobrowser/river.h deleted file mode 100644 index d6bfc76..0000000 --- a/examples/animation/research/photobrowser/river.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef __RIVER__H__ -#define __RIVER__H__ - -#include <QtCore/QDirIterator> -#include <QtGui/QGraphicsWidget> - -#include "menu.h" - -class RiverItem; - -class River : public QGraphicsWidget -{ - Q_OBJECT -public: - enum Mode - { - RiverMode, - GridMode, - GridFullScreenMode, - CoverMode - }; - - River(const QString &path); - void addUnusedRiverItem(RiverItem * item); - - static QSize fixedSize(); - - void switchPaused(); - - void setMode(Mode m); - Mode mode() const; - - Menu *menu; - -protected: - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - void keyPressEvent ( QKeyEvent * keyEvent ); - void makeCenterAvailable(qreal size); - QPointF gridItemPosition(int row, int col) const; - QPixmap pixmap(int index) const; - -protected slots: - void animationFinished(); -public slots: - void setRiverMode(); - void setGridMode(); - void setCoverMode(); - -private: - const QFileInfoList m_images; - int m_currentImage; - mutable QVector<QPixmap> m_pixmaps; - QHash<int, RiverItem*> m_items; - QList<RiverItem*> m_gridItem; - QList<QItemAnimation*> m_pausedAnimations; - Mode m_mode; - - void adjustGrid(int topRight); - RiverItem *currentItem() { return m_items.value(m_selectedItem); } - RiverItem *createItem(int imageIndex); - void setCurrentItem(int currentItem); - void navigateBy(int offset); - - int m_selectedItem; - int m_topLeftIndex; - -}; - - -#endif //__RIVERITEM__H__ diff --git a/examples/animation/research/photobrowser/riveritem.cpp b/examples/animation/research/photobrowser/riveritem.cpp deleted file mode 100644 index 9692d30..0000000 --- a/examples/animation/research/photobrowser/riveritem.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "riveritem.h" -#include "river.h" - -RiverItem::RiverItem(QGraphicsItem *parent) : QGraphicsPixmapItem(parent), m_fullscreen(false) -{ - setCacheMode(DeviceCoordinateCache); -} - -RiverItem::~RiverItem() -{ -} - -void RiverItem::setPixmap(const QPixmap &pix) -{ - const QSize oldSize = pixmap().size(); - const QSize newSize = pix.size(); - QGraphicsPixmapItem::setPixmap(pix); - - if (newSize != oldSize) { - setOffset(-newSize.width()/2, -newSize.height()/2); - const qreal scaleFactor = qreal(River::fixedSize().height())/(qreal(pix.height()*7)); - setTransform(QTransform().scale(scaleFactor, scaleFactor)); - prepareGeometryChange(); - } -} - - -void RiverItem::setFullScreen(bool b, qreal originScaleFactor) -{ - if (m_fullscreen == b) - return; - - m_fullscreen = b; - - QPointF newPos; - qreal rotationZ; - qreal scaleX, scaleY; - - if (b) { - const QSizeF basePixmapSize = transform().map(boundingRect()).boundingRect().size(); - - newPos = parentItem()->boundingRect().center(); - rotationZ = 90; - scaleY = qreal(River::fixedSize().width()) / basePixmapSize.height() * yScale(); - scaleX = qreal(River::fixedSize().height()) / basePixmapSize.width() * xScale(); - - if (m_nonFSPos.isNull()) { - m_nonFSPos = pos(); //let's save our current (non fullscreen) position - } - - } else { - Q_ASSERT(!m_nonFSPos.isNull()); - rotationZ = 0; - scaleX = originScaleFactor; - scaleY = originScaleFactor; - newPos = m_nonFSPos; - } - - QAnimationGroup *group = new QParallelAnimationGroup(scene()); - QItemAnimation *anim = new QItemAnimation(this, QItemAnimation::Position); - anim->setEndValue(newPos); - group->addAnimation(anim); - anim = new QItemAnimation(this, QItemAnimation::RotationZ); - anim->setEndValue(rotationZ); - group->addAnimation(anim); - anim = new QItemAnimation(this, QItemAnimation::ScaleFactorX); - anim->setEndValue(scaleX); - group->addAnimation(anim); - anim = new QItemAnimation(this, QItemAnimation::ScaleFactorY); - anim->setEndValue(scaleY); - group->addAnimation(anim); - group->start(QAbstractAnimation::DeleteWhenStopped); -} - -void RiverItem::mousePressEvent(QGraphicsSceneMouseEvent*) -{ - //just let it rotate on itself - QItemAnimation *anim = new QItemAnimation(this, QItemAnimation::RotationY); - anim->setEndValue(yRotation() < 180 ? 360 : 0); - anim->setDuration(500); - anim->start(QAbstractAnimation::DeleteWhenStopped); -} - - diff --git a/examples/animation/research/photobrowser/riveritem.h b/examples/animation/research/photobrowser/riveritem.h deleted file mode 100644 index 2023c44..0000000 --- a/examples/animation/research/photobrowser/riveritem.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef __RIVERITEM__H__ -#define __RIVERITEM__H__ - -#include <QtGui/QGraphicsPixmapItem> - -class RiverItemAnimator; - -class RiverItem : public QGraphicsPixmapItem -{ -public: - RiverItem(QGraphicsItem *parent); - ~RiverItem(); - - void setPixmap(const QPixmap &); - void setFullScreen(bool b, qreal originScaleFactor); - -protected: - void mousePressEvent(QGraphicsSceneMouseEvent*); - -private: - QPointF m_nonFSPos; //to save the position when not in fullscreen - bool m_fullscreen; -}; - -#endif //__RIVERITEM__H__ diff --git a/examples/animation/research/piemenu/main.cpp b/examples/animation/research/piemenu/main.cpp deleted file mode 100644 index 8076da8..0000000 --- a/examples/animation/research/piemenu/main.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui> -#include "scene.h" -#include "qgraphicspiemenu.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - Scene scene; - - QGraphicsView view(&scene); - view.show(); - - return app.exec(); -} diff --git a/examples/animation/research/piemenu/piemenu.pro b/examples/animation/research/piemenu/piemenu.pro deleted file mode 100644 index 4d7a067..0000000 --- a/examples/animation/research/piemenu/piemenu.pro +++ /dev/null @@ -1,8 +0,0 @@ -SOURCES += \ - main.cpp \ - qgraphicspiemenu.cpp \ - scene.cpp -HEADERS += \ - qgraphicspiemenu.h \ - qgraphicspiemenu_p.h \ - scene.h diff --git a/examples/animation/research/piemenu/qgraphicspiemenu.cpp b/examples/animation/research/piemenu/qgraphicspiemenu.cpp deleted file mode 100644 index a199119..0000000 --- a/examples/animation/research/piemenu/qgraphicspiemenu.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicspiemenu.h" -#include "qgraphicspiemenu_p.h" - -#include <QtGui/qaction.h> - -QGraphicsPieMenu::QGraphicsPieMenu(QGraphicsItem *parent) - : QGraphicsWidget(parent), d_ptr(new QGraphicsPieMenuPrivate) -{ - d_ptr->q_ptr = this; - d_ptr->machine = new QStateMachine(); - d_ptr->popupState = new QState(d_ptr->machine->rootState()); - d_ptr->machine->setInitialState(d_ptr->popupState); - d_ptr->menuAction = new QAction(this); -} - -QGraphicsPieMenu::QGraphicsPieMenu(const QString &title, QGraphicsItem *parent) - : QGraphicsWidget(parent), d_ptr(new QGraphicsPieMenuPrivate) -{ - d_ptr->q_ptr = this; - d_ptr->machine = new QStateMachine(); - d_ptr->popupState = new QState(d_ptr->machine->rootState()); - d_ptr->machine->setInitialState(d_ptr->popupState); - d_ptr->menuAction = new QAction(this); - setTitle(title); -} - -QGraphicsPieMenu::QGraphicsPieMenu(const QIcon &icon, const QString &title, QGraphicsItem *parent) - : QGraphicsWidget(parent), d_ptr(new QGraphicsPieMenuPrivate) -{ - d_ptr->q_ptr = this; - d_ptr->machine = new QStateMachine(); - d_ptr->popupState = new QState(d_ptr->machine->rootState()); - d_ptr->machine->setInitialState(d_ptr->popupState); - d_ptr->menuAction = new QAction(this); - setIcon(icon); - setTitle(title); -} - -QGraphicsPieMenu::~QGraphicsPieMenu() -{ - delete d_ptr; -} - -QAction *QGraphicsPieMenu::addAction(const QString &text) -{ - QAction *action = new QAction(text, this); - addAction(action); - return action; -} - -QAction *QGraphicsPieMenu::addAction(const QIcon &icon, const QString &text) -{ - QAction *action = new QAction(icon, text, this); - addAction(action); - return action; -} - -QAction *QGraphicsPieMenu::addAction(const QString &text, const QObject *receiver, const char *member, const QKeySequence &shortcut) -{ - QAction *action = new QAction(text, this); - action->setShortcut(shortcut); - connect(action, SIGNAL(triggered(bool)), receiver, member); - addAction(action); - return action; -} - -QAction *QGraphicsPieMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char *member, const QKeySequence &shortcut) -{ - QAction *action = new QAction(icon, text, this); - action->setShortcut(shortcut); - connect(action, SIGNAL(triggered(bool)), receiver, member); - addAction(action); - return action; -} - -QAction *QGraphicsPieMenu::addMenu(QGraphicsPieMenu *menu) -{ - QAction *action = menu->menuAction(); - addAction(action); - return action; -} - -QGraphicsPieMenu *QGraphicsPieMenu::addMenu(const QString &title) -{ - QGraphicsPieMenu *menu = new QGraphicsPieMenu(title, this); - addMenu(menu); - return menu; -} - -QGraphicsPieMenu *QGraphicsPieMenu::addMenu(const QIcon &icon, const QString &title) -{ - QGraphicsPieMenu *menu = new QGraphicsPieMenu(icon, title, this); - addMenu(menu); - return menu; -} - -QAction *QGraphicsPieMenu::addSeparator() -{ - QAction *action = new QAction(this); - action->setSeparator(true); - addAction(action); - return action; -} - -QAction *QGraphicsPieMenu::insertMenu(QAction *before, QGraphicsPieMenu *menu) -{ - QAction *action = menu->menuAction(); - insertAction(before, action); - return action; -} - -QAction *QGraphicsPieMenu::insertSeparator(QAction *before) -{ - QAction *action = new QAction(this); - action->setSeparator(true); - insertAction(before, action); - return action; -} - -QAction *QGraphicsPieMenu::menuAction() const -{ - return d_func()->menuAction; -} - -bool QGraphicsPieMenu::isEmpty() const -{ - // ### d->actions - QList<QAction *> actionList = actions(); - bool ret = true; - for (int i = 0; ret && i < actionList.size(); ++i) { - const QAction *action = actionList.at(i); - if (!action->isSeparator() && action->isVisible()) { - ret = false; - break; - } - } - return ret; -} - -void QGraphicsPieMenu::clear() -{ - // ### d->actions - QList<QAction *> actionList = actions(); - for(int i = 0; i < actionList.size(); i++) { - QAction *action = actionList.at(i); - removeAction(action); - if (action->parent() == this && action->associatedGraphicsWidgets().isEmpty()) - delete action; - } -} - -void QGraphicsPieMenu::popup(const QPointF &pos) -{ - Q_UNUSED(pos); - Q_D(QGraphicsPieMenu); - d->machine->start(); -} - -QAction *QGraphicsPieMenu::exec() -{ - return exec(pos()); -} - -QAction *QGraphicsPieMenu::exec(const QPointF &pos) -{ - Q_UNUSED(pos); - return 0; -} - -QAction *QGraphicsPieMenu::exec(QList<QAction *> actions, const QPointF &pos) -{ - QGraphicsPieMenu menu; - for (QList<QAction *>::ConstIterator it = actions.constBegin(); it != actions.constEnd(); ++it) - menu.addAction(*it); - return menu.exec(pos); -} - -QString QGraphicsPieMenu::title() const -{ - Q_D(const QGraphicsPieMenu); - return d->title; -} - -void QGraphicsPieMenu::setTitle(const QString &title) -{ - Q_D(QGraphicsPieMenu); - d->title = title; - updateGeometry(); -} - -QIcon QGraphicsPieMenu::icon() const -{ - Q_D(const QGraphicsPieMenu); - return d->icon; -} - -void QGraphicsPieMenu::setIcon(const QIcon &icon) -{ - Q_D(QGraphicsPieMenu); - d->icon = icon; - updateGeometry(); -} - -QSizeF QGraphicsPieMenu::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const -{ - Q_UNUSED(which); - Q_UNUSED(constraint); - return QSizeF(1, 1); -} diff --git a/examples/animation/research/piemenu/qgraphicspiemenu.h b/examples/animation/research/piemenu/qgraphicspiemenu.h deleted file mode 100644 index d784f93..0000000 --- a/examples/animation/research/piemenu/qgraphicspiemenu.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSPIEMENU_H -#define QGRAPHICSPIEMENU_H - -#include <QtGui/qgraphicswidget.h> - -class QGraphicsPieMenuPrivate; -class QGraphicsPieMenu : public QGraphicsWidget -{ - Q_OBJECT -public: - QGraphicsPieMenu(QGraphicsItem *parent = 0); - QGraphicsPieMenu(const QString &title, QGraphicsItem *parent = 0); - QGraphicsPieMenu(const QIcon &icon, const QString &title, QGraphicsItem *parent = 0); - ~QGraphicsPieMenu(); - -#ifdef Q_NO_USING_KEYWORD - inline void addAction(QAction *action) { QGraphicsWidget::addAction(action); } -#else - using QGraphicsWidget::addAction; -#endif - QAction *addAction(const QString &text); - QAction *addAction(const QIcon &icon, const QString &text); - QAction *addAction(const QString &text, const QObject *receiver, const char *member, const QKeySequence &shortcut = 0); - QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char *member, const QKeySequence &shortcut = 0); - QAction *addMenu(QGraphicsPieMenu *menu); - QGraphicsPieMenu *addMenu(const QString &title); - QGraphicsPieMenu *addMenu(const QIcon &icon, const QString &title); - QAction *addSeparator(); - QAction *insertMenu(QAction *before, QGraphicsPieMenu *menu); - QAction *insertSeparator(QAction *before); - - QAction *menuAction() const; - - bool isEmpty() const; - void clear(); - - void popup(const QPointF &pos); - QAction *exec(); - QAction *exec(const QPointF &pos); - static QAction *exec(QList<QAction *> actions, const QPointF &pos); - - QString title() const; - void setTitle(const QString &title); - - QIcon icon() const; - void setIcon(const QIcon &icon); - -Q_SIGNALS: - void aboutToShow(); - void aboutToHide(); - void triggered(QAction *action); - void hovered(QAction *action); - -protected: - QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; - -private: - Q_DISABLE_COPY(QGraphicsPieMenu) - Q_DECLARE_PRIVATE(QGraphicsPieMenu) - QGraphicsPieMenuPrivate *d_ptr; -}; - -#endif diff --git a/examples/animation/research/piemenu/qgraphicspiemenu_p.h b/examples/animation/research/piemenu/qgraphicspiemenu_p.h deleted file mode 100644 index 458b8f1..0000000 --- a/examples/animation/research/piemenu/qgraphicspiemenu_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSPIEMENU_P_H -#define QGRAPHICSPIEMENU_P_H - -#include "qgraphicspiemenu.h" -#include "qgraphicspiemenusection_p.h" - -#include <QtGui/qicon.h> -#include <QtCore/qstate.h> -#include <QtCore/qtransition.h> -#include <QtCore/qstatemachine.h> - -class QAction; -class QEventLoop; -class QGraphicsPieMenuSection; - -class QGraphicsPieMenuPrivate -{ - Q_DECLARE_PUBLIC(QGraphicsPieMenu); -public: - void init(const QIcon &icon = QIcon(), const QString &title = QString()); - - QIcon icon; - QString title; - QStateMachine *machine; - QState *popupState; - //QTransition *transition; - QList<QGraphicsPieMenuSection *> sections; - - QEventLoop *eventLoop; - - QAction *menuAction; - QGraphicsPieMenu *q_ptr; - - void updatePopupState(); -}; - -#endif diff --git a/examples/animation/research/piemenu/qgraphicspiemenusection_p.h b/examples/animation/research/piemenu/qgraphicspiemenusection_p.h deleted file mode 100644 index 2d71a06..0000000 --- a/examples/animation/research/piemenu/qgraphicspiemenusection_p.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSPIEMENUSECTION_H -#define QGRAPHICSPIEMENUSECTION_H - -#include <QtGui/qgraphicswidget.h> -#include <QtGui/qpainter.h> - -class QGraphicsPieMenuSection : public QGraphicsWidget -{ - Q_OBJECT - Q_PROPERTY(qreal rotation READ rotation WRITE setRotation) -public: - QGraphicsPieMenuSection(QGraphicsItem *parent = 0) - : QGraphicsWidget(parent), rot(0) - { } - - qreal rotation() const - { - return rot; - } - void setRotation(qreal rotation) - { - rot = rotation; - setTransform(QTransform().rotate(rot)); - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) - { - Q_UNUSED(option); - Q_UNUSED(widget); - painter->setPen(QPen(Qt::black, 1)); - painter->setBrush(QBrush(Qt::gray)); - painter->drawPie(QRectF(-100, -100, 200, 200), 0, -30 * 16); - } - -protected: - QSizeF sizeHint(Qt::SizeHint which, const QSizeF &size = QSizeF()) const - { - Q_UNUSED(which); - Q_UNUSED(size); - return QSizeF(100, 30); - } - -private: - qreal rot; -}; - -#endif diff --git a/examples/animation/research/piemenu/scene.cpp b/examples/animation/research/piemenu/scene.cpp deleted file mode 100644 index 6309975..0000000 --- a/examples/animation/research/piemenu/scene.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicspiemenu.h" -#include "scene.h" - -#include <QtGui/qaction.h> -#include <QtGui/qgraphicssceneevent.h> - -Scene::Scene(qreal x, qreal y, qreal width, qreal height, QObject *parent) - : QGraphicsScene(x, y, width, height, parent) -{ -} - -Scene::Scene(const QRectF &sceneRect, QObject *parent) - : QGraphicsScene(sceneRect, parent) -{ -} - -Scene::Scene(QObject *parent) - : QGraphicsScene(parent) -{ -} - -Scene::~Scene() -{ -} - -void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - QGraphicsPieMenu *menu = new QGraphicsPieMenu; - for (int i = 0; i < 5; ++i) - menu->addAction(new QAction(QString("Item %1").arg(i), menu)); - menu->popup(event->scenePos()); -} diff --git a/examples/animation/research/piemenu/scene.h b/examples/animation/research/piemenu/scene.h deleted file mode 100644 index bbfe6d3..0000000 --- a/examples/animation/research/piemenu/scene.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SCENE_H -#define SCENE_H - -#include <QtGui/qgraphicsscene.h> - -class Scene : public QGraphicsScene -{ - Q_OBJECT -public: - Scene(qreal x, qreal y, qreal width, qreal height, QObject *parent = 0); - Scene(const QRectF &sceneRect, QObject *parent = 0); - Scene(QObject *parent = 0); - ~Scene(); - -protected: - void mousePressEvent(QGraphicsSceneMouseEvent *event); -}; - -#endif diff --git a/examples/animation/research/propertytransform/main.cpp b/examples/animation/research/propertytransform/main.cpp deleted file mode 100644 index 99cd769..0000000 --- a/examples/animation/research/propertytransform/main.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui> - -#include "qpropertytransform.h" - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - QGraphicsScene scene; - QGraphicsView view(&scene); - - QGraphicsItem *item = new QGraphicsRectItem(QRectF(0,0, 200, 100)); - scene.addItem(item); - QPropertyTransform transform; - transform.setTargetItem(item); - - QAnimationGroup *group = new QAnimationGroup(QAnimationGroup::Parallel, &scene); - QPropertyAnimation *scaleAnim = new QPropertyAnimation(&transform, "scaleX"); - scaleAnim->setStartValue(1.0); - scaleAnim->setTargetValue(2.0); - scaleAnim->setDuration(10000); - group->add(scaleAnim); - - QPropertyAnimation *scaleAnim2 = new QPropertyAnimation(&transform, "scaleY"); - scaleAnim2->setStartValue(.0); - scaleAnim2->setTargetValue(2.0); - scaleAnim2->setDuration(10000); - QEasingCurve curve(QEasingCurve::InElastic); - curve.setPeriod(2); - curve.setAmplitude(2); - - //scaleAnim2->setEasingCurve(curve); - //scaleAnim2->setEasingCurve(QEasingCurve(QEasingCurve::OutElastic , 2, 2 )); - group->add(scaleAnim2); - - QPropertyAnimation *rotAnim = new QPropertyAnimation(&transform, "rotation"); - rotAnim->setStartValue(0); - rotAnim->setTargetValue(90); - rotAnim->setDuration(10000); - group->add(rotAnim); - - group->start(); - - view.resize(800,600); - view.show(); - return app.exec(); -} diff --git a/examples/animation/research/propertytransform/propertytransform.pro b/examples/animation/research/propertytransform/propertytransform.pro deleted file mode 100644 index 94c36b8..0000000 --- a/examples/animation/research/propertytransform/propertytransform.pro +++ /dev/null @@ -1,14 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) fr 26. sep 13:21:57 2008 -###################################################################### - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input -SOURCES += main.cpp -HEADERS += qpropertytransform.h -CONFIG += console - diff --git a/examples/animation/research/propertytransform/qpropertytransform.h b/examples/animation/research/propertytransform/qpropertytransform.h deleted file mode 100644 index e27987f..0000000 --- a/examples/animation/research/propertytransform/qpropertytransform.h +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtCore/QObject> -#include <QtCore/QPoint> -#include <QtGui/QGraphicsItem> -#include <QtGui/QTransform> -#include <QtCore/QDebug> - -/** - * Experimental. - * Pros: - * 1. Does not add ugly/confusing API to QGraphicsItem. - * - * Cons: - * 1. apply() /m_item->setTransform() is called too many times. (FIXED NOW?) - * - * - */ -class QPropertyTransform : public QObject { - Q_OBJECT -public: - Q_PROPERTY(QPointF center READ center WRITE setCenter); - Q_PROPERTY(qreal rotation READ rotation WRITE setRotation); - Q_PROPERTY(qreal scaleX READ scaleX WRITE setScaleX); - Q_PROPERTY(qreal scaleY READ scaleY WRITE setScaleY); -public: - QPropertyTransform() : m_item(0), m_rotationZ(0), m_scaleX(1.), m_scaleY(1.) {} - - void setTargetItem(QGraphicsItem *item) { - m_item = item; - } - - void setCenter(const QPointF ¢er) { - m_center = center; - apply(); - } - - QPointF center() const { return m_center; } - - void setRotation(qreal rotation) { - m_rotationZ = rotation; - apply(); - } - - qreal rotation() const { return m_rotationZ; } - - void setScaleX(qreal scale) { - m_scaleX = scale; - apply(); - } - - qreal scaleX() const { return m_scaleX; } - - void setScaleY(qreal scale) { - m_scaleY = scale; - apply(); - } - - qreal scaleY() const { return m_scaleY; } - -private: - QTransform transform() const { - return QTransform().translate(m_center.x(), m_center.y()) - .rotate(m_rotationZ) - .scale(m_scaleX, m_scaleY) - .translate(-m_center.x(), -m_center.y()); - } - - void apply() { - if (m_item) - m_item->setTransform(transform()); - } - - QGraphicsItem *m_item; - QPointF m_center; - qreal m_rotationZ; - qreal m_scaleX; - qreal m_scaleY; -}; - diff --git a/examples/animation/research/sound/main.cpp b/examples/animation/research/sound/main.cpp deleted file mode 100644 index ffbc44c..0000000 --- a/examples/animation/research/sound/main.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//The purpose of this example is to show that it is possible to have your own -// animation with undefined duration - -#include <QtGui/QtGui> -#include <phonon> - -class SoundAnimation : public QAbstractAnimation -{ -public: - SoundAnimation(const QString &file) - { - //in an idea case we should also control the errors - Phonon::createPath(&m_media, &m_audio); - m_media.setCurrentSource(file); - connect(&m_media, SIGNAL(finished()), SLOT(stop())); - } - - int duration() const - { - return -1; - } - - void updateCurrentTime(int msecs) - { - //nothing to do here... - qDebug() << "updateCurrentTime" << msecs; - } - - void updateState(State state) - { - switch(state) - { - case Running: - m_media.play(); - break; - case Stopped: - m_media.stop(); - break; - case Paused: - m_media.pause(); - break; - } - } - - -private: - Phonon::MediaObject m_media; - Phonon::AudioOutput m_audio; - -}; - - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - Q_INIT_RESOURCE(sound); - - SoundAnimation anim(QLatin1String(":/media/sax.mp3")); - app.connect(&anim, SIGNAL(finished()), SLOT(quit())); - anim.start(); - - return app.exec(); -} diff --git a/examples/animation/research/sound/media/sax.mp3 b/examples/animation/research/sound/media/sax.mp3 Binary files differdeleted file mode 100644 index 0a078b1..0000000 --- a/examples/animation/research/sound/media/sax.mp3 +++ /dev/null diff --git a/examples/animation/research/sound/sound.pro b/examples/animation/research/sound/sound.pro deleted file mode 100644 index 0ad3050..0000000 --- a/examples/animation/research/sound/sound.pro +++ /dev/null @@ -1,14 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) mer. 21. janv. 13:53:26 2009 -###################################################################### - -TEMPLATE = app -QT += phonon -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -RESOURCES = sound.qrc - -# Input -SOURCES += main.cpp diff --git a/examples/animation/research/sound/sound.qrc b/examples/animation/research/sound/sound.qrc deleted file mode 100644 index 8919142..0000000 --- a/examples/animation/research/sound/sound.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> -<file>media/sax.mp3</file> -</qresource> -</RCC> |