summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-04-20 13:04:54 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-04-20 13:31:04 (GMT)
commit51e0bd2d1f1325081e7aff9ee0b51c0e8a4a49bd (patch)
tree71987c181d978e1a65868a5f0533036530a23e64 /examples
parent2e679706b28ade66cb55ace1e9bfae42dd5044ea (diff)
downloadQt-51e0bd2d1f1325081e7aff9ee0b51c0e8a4a49bd.zip
Qt-51e0bd2d1f1325081e7aff9ee0b51c0e8a4a49bd.tar.gz
Qt-51e0bd2d1f1325081e7aff9ee0b51c0e8a4a49bd.tar.bz2
cleanup in demo
sub-attaq doesn't use anymore animation private headers
Diffstat (limited to 'examples')
-rw-r--r--examples/animation/sub-attaq/custompropertyanimation.cpp56
-rw-r--r--examples/animation/sub-attaq/custompropertyanimation.h3
-rw-r--r--examples/animation/sub-attaq/custompropertyanimation_p.h64
-rw-r--r--examples/animation/sub-attaq/sub-attaq.pro2
4 files changed, 30 insertions, 95 deletions
diff --git a/examples/animation/sub-attaq/custompropertyanimation.cpp b/examples/animation/sub-attaq/custompropertyanimation.cpp
index 1637ed2..f7ab269 100644
--- a/examples/animation/sub-attaq/custompropertyanimation.cpp
+++ b/examples/animation/sub-attaq/custompropertyanimation.cpp
@@ -40,7 +40,6 @@
****************************************************************************/
#include "custompropertyanimation.h"
-#include "custompropertyanimation_p.h"
// Qt
#include <QtCore/qdebug.h>
@@ -48,22 +47,8 @@
QT_BEGIN_NAMESPACE
-void CustomPropertyAnimationPrivate::initDefaultStartValue()
-{
- if (!animProp)
- return;
- QVariant def = animProp->read();
- if (def.isValid())
- convertValues(def.userType());
- if (animProp && !defaultStartValue.isValid() && currentTime == 0
- || (currentTime == duration && currentLoop == (loopCount - 1))) {
- setDefaultStartValue(def);
- }
-}
-
-
CustomPropertyAnimation::CustomPropertyAnimation(QObject *parent) :
- QVariantAnimation(*new CustomPropertyAnimationPrivate, parent)
+ QVariantAnimation(parent), animProp(0)
{
}
@@ -71,13 +56,12 @@ CustomPropertyAnimation::~CustomPropertyAnimation()
{
}
-void CustomPropertyAnimation::setProperty(AbstractProperty *animProp)
+void CustomPropertyAnimation::setProperty(AbstractProperty *_animProp)
{
- Q_D(CustomPropertyAnimation);
- if (d->animProp == animProp)
+ if (animProp == _animProp)
return;
- delete d->animProp;
- d->animProp = animProp;
+ delete animProp;
+ animProp = _animProp;
}
/*!
@@ -85,11 +69,10 @@ void CustomPropertyAnimation::setProperty(AbstractProperty *animProp)
*/
void CustomPropertyAnimation::updateCurrentValue(const QVariant &value)
{
- Q_D(CustomPropertyAnimation);
- if (!d->animProp || state() == QAbstractAnimation::Stopped)
+ if (!animProp || state() == QAbstractAnimation::Stopped)
return;
- d->animProp->write(value);
+ animProp->write(value);
}
@@ -98,10 +81,29 @@ void CustomPropertyAnimation::updateCurrentValue(const QVariant &value)
*/
void CustomPropertyAnimation::updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState)
{
- Q_D(CustomPropertyAnimation);
// Initialize start value
- if (oldState == QAbstractAnimation::Stopped)
- d->initDefaultStartValue();
+ if (oldState == QAbstractAnimation::Stopped) {
+ if (!animProp)
+ return;
+ QVariant def = animProp->read();
+ if (def.isValid()) {
+ const int t = def.userType();
+ KeyValues values = keyValues();
+ //this ensures that all the keyValues are of type t
+ for (int i = 0; i < values.count(); ++i) {
+ QVariantAnimation::KeyValue &pair = values[i];
+ if (pair.second.userType() != t)
+ pair.second.convert(static_cast<QVariant::Type>(t));
+ }
+ //let's now update the key values
+ setKeyValues(values);
+ }
+
+ if (animProp && !startValue().isValid() && currentTime() == 0
+ || (currentTime() == duration() && currentLoop() == (loopCount() - 1))) {
+ setStartValue(def);
+ }
+ }
QVariantAnimation::updateState(oldState, newState);
}
diff --git a/examples/animation/sub-attaq/custompropertyanimation.h b/examples/animation/sub-attaq/custompropertyanimation.h
index ba6ef55..48a50c9 100644
--- a/examples/animation/sub-attaq/custompropertyanimation.h
+++ b/examples/animation/sub-attaq/custompropertyanimation.h
@@ -49,7 +49,6 @@
#endif
class QGraphicsItem;
-class CustomPropertyAnimationPrivate;
struct AbstractProperty
{
@@ -111,7 +110,7 @@ public:
private:
Q_DISABLE_COPY(CustomPropertyAnimation);
- Q_DECLARE_PRIVATE(CustomPropertyAnimation);
+ AbstractProperty *animProp;
};
#endif // CUSTOMPROPERTYANIMATION_H
diff --git a/examples/animation/sub-attaq/custompropertyanimation_p.h b/examples/animation/sub-attaq/custompropertyanimation_p.h
deleted file mode 100644
index 89fc757..0000000
--- a/examples/animation/sub-attaq/custompropertyanimation_p.h
+++ /dev/null
@@ -1,64 +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 CUSTOMPROPERTYANIMATION_P_H
-#define CUSTOMPROPERTYANIMATION_P_H
-
-#ifdef QT_EXPERIMENTAL_SOLUTION
-# include "qvariantanimation_p.h"
-#else
-# include <private/qvariantanimation_p.h>
-#endif
-
-class CustomPropertyAnimationPrivate : public QVariantAnimationPrivate
-{
- Q_DECLARE_PUBLIC(CustomPropertyAnimation)
-public:
- CustomPropertyAnimationPrivate() : QVariantAnimationPrivate(), animProp(0)
- {
- }
-
- void initDefaultStartValue();
-
- AbstractProperty *animProp;
-};
-
-#endif //QTCUSTOMPROPERTYANIMATION_P_H
diff --git a/examples/animation/sub-attaq/sub-attaq.pro b/examples/animation/sub-attaq/sub-attaq.pro
index 07c4d06..1456d0e 100644
--- a/examples/animation/sub-attaq/sub-attaq.pro
+++ b/examples/animation/sub-attaq/sub-attaq.pro
@@ -20,10 +20,8 @@ HEADERS += boat.h \
states.h \
boat_p.h \
submarine_p.h \
- custompropertyanimation_p.h \
custompropertyanimation.h \
qanimationstate.h
-
SOURCES += boat.cpp \
bomb.cpp \
main.cpp \