diff options
Diffstat (limited to 'examples/animation/sub-attaq')
24 files changed, 72 insertions, 169 deletions
diff --git a/examples/animation/sub-attaq/animationmanager.cpp b/examples/animation/sub-attaq/animationmanager.cpp index 5b9282a..477d3bd 100644 --- a/examples/animation/sub-attaq/animationmanager.cpp +++ b/examples/animation/sub-attaq/animationmanager.cpp @@ -43,11 +43,7 @@ #include "animationmanager.h" //Qt -#if defined(QT_EXPERIMENTAL_SOLUTION) -# include "qabstractanimation.h" -#else -# include <QtCore/QAbstractAnimation> -#endif +#include <QtCore/QAbstractAnimation> #include <QtCore/QDebug> // the universe's only animation manager diff --git a/examples/animation/sub-attaq/animationmanager.h b/examples/animation/sub-attaq/animationmanager.h index 69ec3d7..a563c96 100644 --- a/examples/animation/sub-attaq/animationmanager.h +++ b/examples/animation/sub-attaq/animationmanager.h @@ -44,7 +44,9 @@ #include <QtCore/QObject> +QT_BEGIN_NAMESPACE class QAbstractAnimation; +QT_END_NAMESPACE class AnimationManager : public QObject { diff --git a/examples/animation/sub-attaq/boat.cpp b/examples/animation/sub-attaq/boat.cpp index 143cf94..63d12bb 100644 --- a/examples/animation/sub-attaq/boat.cpp +++ b/examples/animation/sub-attaq/boat.cpp @@ -50,22 +50,12 @@ #include "qanimationstate.h" //Qt -#if defined(QT_EXPERIMENTAL_SOLUTION) -# include "qpropertyanimation.h" -# include "qstatemachine.h" -# include "qhistorystate.h" -# include "qfinalstate.h" -# include "qstate.h" -# include "qpauseanimation.h" -#include "qsequentialanimationgroup.h" -#else #include <QtCore/QPropertyAnimation> #include <QtCore/QStateMachine> #include <QtCore/QHistoryState> #include <QtCore/QFinalState> #include <QtCore/QState> #include <QtCore/QSequentialAnimationGroup> -#endif static QAbstractAnimation *setupDestroyAnimation(Boat *boat) { diff --git a/examples/animation/sub-attaq/boat.h b/examples/animation/sub-attaq/boat.h index b28cf20..08a9fa2 100644 --- a/examples/animation/sub-attaq/boat.h +++ b/examples/animation/sub-attaq/boat.h @@ -46,17 +46,15 @@ #include <QtCore/QObject> #include <QtGui/QKeyEvent> -#if defined(QT_EXPERIMENTAL_SOLUTION) -# include "qtgraphicswidget.h" -#else -# include <QtGui/QGraphicsWidget> -#endif +#include <QtGui/QGraphicsWidget> class PixmapItem; class Bomb; +QT_BEGIN_NAMESPACE class QVariantAnimation; class QAbstractAnimation; class QStateMachine; +QT_END_NAMESPACE class Boat : public QGraphicsWidget { diff --git a/examples/animation/sub-attaq/boat_p.h b/examples/animation/sub-attaq/boat_p.h index 6f03e48..a8a24a6 100644 --- a/examples/animation/sub-attaq/boat_p.h +++ b/examples/animation/sub-attaq/boat_p.h @@ -3,7 +3,7 @@ ** 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. +** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -42,16 +42,23 @@ #ifndef BOAT_P_H #define BOAT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + //Own #include "bomb.h" #include "graphicsscene.h" // Qt -#if defined(QT_EXPERIMENTAL_SOLUTION) -# include "qkeyeventtransition.h" -#else -# include <QtGui/QKeyEventTransition> -#endif +#include <QtGui/QKeyEventTransition> static const int MAX_BOMB = 5; diff --git a/examples/animation/sub-attaq/bomb.cpp b/examples/animation/sub-attaq/bomb.cpp index 04310aa..f1f5324 100644 --- a/examples/animation/sub-attaq/bomb.cpp +++ b/examples/animation/sub-attaq/bomb.cpp @@ -47,18 +47,10 @@ #include "qanimationstate.h" //Qt - -#if defined(QT_EXPERIMENTAL_SOLUTION) -#include "qpropertyanimation.h" -#include "qsequentialanimationgroup.h" -#include "qstatemachine.h" -#include "qfinalstate.h" -#else #include <QtCore/QSequentialAnimationGroup> #include <QtCore/QPropertyAnimation> #include <QtCore/QStateMachine> #include <QtCore/QFinalState> -#endif Bomb::Bomb(QGraphicsItem * parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags), launchAnimation(0) diff --git a/examples/animation/sub-attaq/bomb.h b/examples/animation/sub-attaq/bomb.h index 9191e6e..226d056 100644 --- a/examples/animation/sub-attaq/bomb.h +++ b/examples/animation/sub-attaq/bomb.h @@ -43,13 +43,8 @@ #define __BOMB__H__ //Qt -#if defined(QT_EXPERIMENTAL_SOLUTION) -# include "qanimationgroup.h" -# include "qgraphicswidget.h" -#else -# include <QtGui/QGraphicsWidget> -# include <QtCore/QAnimationGroup> -#endif +#include <QtGui/QGraphicsWidget> +#include <QtCore/QAnimationGroup> class PixmapItem; diff --git a/examples/animation/sub-attaq/custompropertyanimation.cpp b/examples/animation/sub-attaq/custompropertyanimation.cpp index f7ab269..8226cca 100644 --- a/examples/animation/sub-attaq/custompropertyanimation.cpp +++ b/examples/animation/sub-attaq/custompropertyanimation.cpp @@ -44,9 +44,6 @@ // Qt #include <QtCore/qdebug.h> -QT_BEGIN_NAMESPACE - - CustomPropertyAnimation::CustomPropertyAnimation(QObject *parent) : QVariantAnimation(parent), animProp(0) { @@ -108,8 +105,4 @@ void CustomPropertyAnimation::updateState(QAbstractAnimation::State oldState, QA QVariantAnimation::updateState(oldState, newState); } - - #include "moc_custompropertyanimation.cpp" - -QT_END_NAMESPACE diff --git a/examples/animation/sub-attaq/custompropertyanimation.h b/examples/animation/sub-attaq/custompropertyanimation.h index 48a50c9..8654aeb 100644 --- a/examples/animation/sub-attaq/custompropertyanimation.h +++ b/examples/animation/sub-attaq/custompropertyanimation.h @@ -42,13 +42,11 @@ #ifndef CUSTOMPROPERTYANIMATION_H #define CUSTOMPROPERTYANIMATION_H -#if defined(QT_EXPERIMENTAL_SOLUTION) -# include "qvariantanimation.h" -#else -# include <QtCore/qvariantanimation.h> -#endif +#include <QtCore/qvariantanimation.h> +QT_BEGIN_NAMESPACE class QGraphicsItem; +QT_END_NAMESPACE struct AbstractProperty { diff --git a/examples/animation/sub-attaq/graphicsscene.cpp b/examples/animation/sub-attaq/graphicsscene.cpp index 2a6f83c..e773dae 100644 --- a/examples/animation/sub-attaq/graphicsscene.cpp +++ b/examples/animation/sub-attaq/graphicsscene.cpp @@ -53,21 +53,12 @@ #include "progressitem.h" //Qt -#if defined(QT_EXPERIMENTAL_SOLUTION) -#include "qpropertyanimation.h" -#include "qsequentialanimationgroup.h" -#include "qparallelanimationgroup.h" -#include "qstatemachine.h" -#include "qfinalstate.h" -#include "qpauseanimation.h" -#else #include <QtCore/QPropertyAnimation> #include <QtCore/QSequentialAnimationGroup> #include <QtCore/QParallelAnimationGroup> #include <QtCore/QStateMachine> #include <QtCore/QFinalState> #include <QtCore/QPauseAnimation> -#endif #include <QtGui/QAction> #include <QtCore/QDir> #include <QtGui/QApplication> @@ -129,7 +120,7 @@ GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode) //parse the xml that contain all data of the game QXmlStreamReader reader; - QFile file(QDir::currentPath() + "/data.xml"); + QFile file(":data.xml"); file.open(QIODevice::ReadOnly); reader.setDevice(&file); LevelDescription currentLevel; diff --git a/examples/animation/sub-attaq/graphicsscene.h b/examples/animation/sub-attaq/graphicsscene.h index 0840564..8b0ea96 100644 --- a/examples/animation/sub-attaq/graphicsscene.h +++ b/examples/animation/sub-attaq/graphicsscene.h @@ -45,12 +45,7 @@ //Qt #include <QtGui/QGraphicsScene> #include <QtCore/QSet> - -#if defined(QT_EXPERIMENTAL_SOLUTION) -# include "qstate.h" -#else -# include <QtCore/QState> -#endif +#include <QtCore/QState> class Boat; @@ -59,7 +54,9 @@ class Torpedo; class Bomb; class PixmapItem; class ProgressItem; +QT_BEGIN_NAMESPACE class QAction; +QT_END_NAMESPACE class GraphicsScene : public QGraphicsScene { diff --git a/examples/animation/sub-attaq/mainwindow.cpp b/examples/animation/sub-attaq/mainwindow.cpp index a166241..9cf9eb5 100644 --- a/examples/animation/sub-attaq/mainwindow.cpp +++ b/examples/animation/sub-attaq/mainwindow.cpp @@ -43,11 +43,11 @@ #include "mainwindow.h" #include "graphicsscene.h" +//Qt +#include <QtGui/QtGui> #ifndef QT_NO_OPENGL - #include <QtOpenGL/QtOpenGL> +#include <QtOpenGL/QtOpenGL> #endif -//Qt -#include <QtGui/QGraphicsView> MainWindow::MainWindow() : QMainWindow(0) { diff --git a/examples/animation/sub-attaq/mainwindow.h b/examples/animation/sub-attaq/mainwindow.h index 72d1324..87f194a 100644 --- a/examples/animation/sub-attaq/mainwindow.h +++ b/examples/animation/sub-attaq/mainwindow.h @@ -44,9 +44,10 @@ //Qt #include <QtGui/QMainWindow> - class GraphicsScene; +QT_BEGIN_NAMESPACE class QGraphicsView; +QT_END_NAMESPACE class MainWindow : public QMainWindow { diff --git a/examples/animation/sub-attaq/qanimationstate.cpp b/examples/animation/sub-attaq/qanimationstate.cpp index 0f30ac2..d4d109c 100644 --- a/examples/animation/sub-attaq/qanimationstate.cpp +++ b/examples/animation/sub-attaq/qanimationstate.cpp @@ -41,14 +41,7 @@ #include "qanimationstate.h" -#if defined(QT_EXPERIMENTAL_SOLUTION) -# include "qstate.h" -# include "qstate_p.h" -#else -# include <QtCore/qstate.h> -# include <private/qstate_p.h> -#endif - +#include <QtCore/qstate.h> QT_BEGIN_NAMESPACE @@ -81,25 +74,11 @@ machine.start(); #ifndef QT_NO_ANIMATION -class QAnimationStatePrivate : public QStatePrivate -{ - Q_DECLARE_PUBLIC(QAnimationState) -public: - QAnimationStatePrivate() - : animation(0) - { - - } - ~QAnimationStatePrivate() {} - - QAbstractAnimation *animation; -}; - /*! Constructs a new state with the given \a parent state. */ QAnimationState::QAnimationState(QState *parent) - : QState(*new QAnimationStatePrivate, parent) + : QState(parent), m_animation(0) { } @@ -117,20 +96,18 @@ QAnimationState::~QAnimationState() */ void QAnimationState::setAnimation(QAbstractAnimation *animation) { - Q_D(QAnimationState); - - if (animation == d->animation) + if (animation == m_animation) return; //Disconnect from the previous animation if exist - if(d->animation) - disconnect(d->animation, SIGNAL(finished()), this, SIGNAL(animationFinished())); + if(m_animation) + disconnect(m_animation, SIGNAL(finished()), this, SIGNAL(animationFinished())); - d->animation = animation; + m_animation = animation; - if (d->animation) { + if (m_animation) { //connect the new animation - connect(d->animation, SIGNAL(finished()), this, SIGNAL(animationFinished())); + connect(m_animation, SIGNAL(finished()), this, SIGNAL(animationFinished())); } } @@ -139,8 +116,7 @@ void QAnimationState::setAnimation(QAbstractAnimation *animation) */ QAbstractAnimation* QAnimationState::animation() const { - Q_D(const QAnimationState); - return d->animation; + return m_animation; } /*! @@ -148,9 +124,8 @@ QAbstractAnimation* QAnimationState::animation() const */ void QAnimationState::onEntry(QEvent *) { - Q_D(QAnimationState); - if (d->animation) - d->animation->start(); + if (m_animation) + m_animation->start(); } /*! @@ -158,9 +133,8 @@ void QAnimationState::onEntry(QEvent *) */ void QAnimationState::onExit(QEvent *) { - Q_D(QAnimationState); - if (d->animation) - d->animation->stop(); + if (m_animation) + m_animation->stop(); } /*! diff --git a/examples/animation/sub-attaq/qanimationstate.h b/examples/animation/sub-attaq/qanimationstate.h index 88c0a6d..e5322ad 100644 --- a/examples/animation/sub-attaq/qanimationstate.h +++ b/examples/animation/sub-attaq/qanimationstate.h @@ -58,7 +58,7 @@ QT_MODULE(Gui) #ifndef QT_NO_ANIMATION -class QAnimationStatePrivate; +class QAbstractAnimation; class QAnimationState : public QState { @@ -80,7 +80,7 @@ protected: private: Q_DISABLE_COPY(QAnimationState) - Q_DECLARE_PRIVATE(QAnimationState) + QAbstractAnimation *m_animation; }; #endif diff --git a/examples/animation/sub-attaq/states.cpp b/examples/animation/sub-attaq/states.cpp index 7650b0f..adc8bd0 100644 --- a/examples/animation/sub-attaq/states.cpp +++ b/examples/animation/sub-attaq/states.cpp @@ -51,17 +51,10 @@ //Qt #include <QtGui/QMessageBox> #include <QtGui/QGraphicsView> -#if defined(QT_EXPERIMENTAL_SOLUTION) -#include "qstatemachine.h" -#include "qkeyeventtransition.h" -#include "qsignalevent.h" -#include "qfinalstate.h" -#else #include <QtCore/QStateMachine> #include <QtGui/QKeyEventTransition> #include <QtCore/QSignalEvent> #include <QtCore/QFinalState> -#endif PlayState::PlayState(GraphicsScene *scene, QState *parent) : QState(parent), diff --git a/examples/animation/sub-attaq/states.h b/examples/animation/sub-attaq/states.h index a1cb5ff..71375e0 100644 --- a/examples/animation/sub-attaq/states.h +++ b/examples/animation/sub-attaq/states.h @@ -43,23 +43,18 @@ #define STATES_H //Qt -#if defined(QT_EXPERIMENTAL_SOLUTION) -#include "qstate.h" -#include "qsignaltransition.h" -#include "qpropertyanimation.h" -#include "qkeyeventtransition.h" -#else #include <QtCore/QState> #include <QtCore/QSignalTransition> #include <QtCore/QPropertyAnimation> -# include <QtGui/QKeyEventTransition> -#endif +#include <QtGui/QKeyEventTransition> #include <QtCore/QSet> class GraphicsScene; class Boat; class SubMarine; +QT_BEGIN_NAMESPACE class QStateMachine; +QT_END_NAMESPACE class PlayState : public QState { diff --git a/examples/animation/sub-attaq/sub-attaq.pro b/examples/animation/sub-attaq/sub-attaq.pro index 961a9b5..d13a099 100644 --- a/examples/animation/sub-attaq/sub-attaq.pro +++ b/examples/animation/sub-attaq/sub-attaq.pro @@ -1,14 +1,5 @@ -# ##################################################################### -# Automatically generated by qmake (2.01a) Thu Oct 9 10:53:30 2008 -# ##################################################################### -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . -QT += xml contains(QT_CONFIG, opengl):QT += opengl -# Input HEADERS += boat.h \ bomb.h \ mainwindow.h \ @@ -37,3 +28,9 @@ SOURCES += boat.cpp \ qanimationstate.cpp \ progressitem.cpp RESOURCES += subattaq.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/animation/sub-attaq +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS sub-attaq.pro pics +sources.path = $$[QT_INSTALL_EXAMPLES]/animation/sub-attaq +INSTALLS += target sources diff --git a/examples/animation/sub-attaq/subattaq.qrc b/examples/animation/sub-attaq/subattaq.qrc index c76f8ef..80a3af1 100644 --- a/examples/animation/sub-attaq/subattaq.qrc +++ b/examples/animation/sub-attaq/subattaq.qrc @@ -34,5 +34,6 @@ <file alias="big/explosion/submarine/step2" >pics/big/explosion/submarine/step2.png</file> <file alias="big/explosion/submarine/step3" >pics/big/explosion/submarine/step3.png</file> <file alias="big/explosion/submarine/step4" >pics/big/explosion/submarine/step4.png</file> + <file>data.xml</file> </qresource> </RCC> diff --git a/examples/animation/sub-attaq/submarine.cpp b/examples/animation/sub-attaq/submarine.cpp index 0f03efc..d8cf1da 100644 --- a/examples/animation/sub-attaq/submarine.cpp +++ b/examples/animation/sub-attaq/submarine.cpp @@ -49,18 +49,10 @@ #include "custompropertyanimation.h" #include "qanimationstate.h" -#if defined(QT_EXPERIMENTAL_SOLUTION) -# include "qpropertyanimation.h" -# include "qstatemachine.h" -# include "qfinalstate.h" -# include "qsequentialanimationgroup.h" -# include "qpauseanimation.h" -#else #include <QtCore/QPropertyAnimation> #include <QtCore/QStateMachine> #include <QtCore/QFinalState> #include <QtCore/QSequentialAnimationGroup> -#endif static QAbstractAnimation *setupDestroyAnimation(SubMarine *sub) { diff --git a/examples/animation/sub-attaq/submarine.h b/examples/animation/sub-attaq/submarine.h index 7ee587d..4001603 100644 --- a/examples/animation/sub-attaq/submarine.h +++ b/examples/animation/sub-attaq/submarine.h @@ -43,13 +43,8 @@ #define __SUBMARINE__H__ //Qt -#if defined(QT_EXPERIMENTAL_SOLUTION) -#include "qvariantanimation.h" -#include "qgraphicswidget.h" -#else #include <QtCore/QVariantAnimation> #include <QtGui/QGraphicsWidget> -#endif class PixmapItem; diff --git a/examples/animation/sub-attaq/submarine_p.h b/examples/animation/sub-attaq/submarine_p.h index c76d991..8c31eb7 100644 --- a/examples/animation/sub-attaq/submarine_p.h +++ b/examples/animation/sub-attaq/submarine_p.h @@ -3,7 +3,7 @@ ** 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. +** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -42,17 +42,24 @@ #ifndef SUBMARINE_P_H #define SUBMARINE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + //Own #include "animationmanager.h" #include "submarine.h" #include "qanimationstate.h" //Qt -#if defined(QT_EXPERIMENTAL_SOLUTION) -#include "qpropertyanimation.h" -#else #include <QtCore/QPropertyAnimation> -#endif #include <QtGui/QGraphicsScene> //This state is describing when the boat is moving right diff --git a/examples/animation/sub-attaq/torpedo.cpp b/examples/animation/sub-attaq/torpedo.cpp index 88f1112..02a54fc 100644 --- a/examples/animation/sub-attaq/torpedo.cpp +++ b/examples/animation/sub-attaq/torpedo.cpp @@ -47,15 +47,9 @@ #include "animationmanager.h" #include "qanimationstate.h" -#if defined(QT_EXPERIMENTAL_SOLUTION) -#include "qpropertyanimation.h" -#include "qstatemachine.h" -#include "qfinalstate.h" -#else #include <QtCore/QPropertyAnimation> #include <QtCore/QStateMachine> #include <QtCore/QFinalState> -#endif Torpedo::Torpedo(QGraphicsItem * parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags), currentSpeed(0), launchAnimation(0) diff --git a/examples/animation/sub-attaq/torpedo.h b/examples/animation/sub-attaq/torpedo.h index 2e44e41..4a0f457 100644 --- a/examples/animation/sub-attaq/torpedo.h +++ b/examples/animation/sub-attaq/torpedo.h @@ -45,13 +45,8 @@ //Qt #include <QtCore/QObject> -#if defined(QT_EXPERIMENTAL_SOLUTION) -# include "qvariantanimation.h" -# include "qgraphicswidget.h" -#else -# include <QtCore/QVariantAnimation> -# include <QtGui/QGraphicsWidget> -#endif +#include <QtCore/QVariantAnimation> +#include <QtGui/QGraphicsWidget> class PixmapItem; |