diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-04-21 09:58:03 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-04-21 09:58:03 (GMT) |
commit | 9fa9221af7ca452d19a0754f38d81299ad749dbc (patch) | |
tree | b1a3b741d386f8a22cc808808c353091549e3c67 | |
parent | ea8bc5be8cea04da86b8df53cbde22b71f532585 (diff) | |
parent | 965a0d60fe28666471e9ffb99a7e97097254a4cc (diff) | |
download | Qt-9fa9221af7ca452d19a0754f38d81299ad749dbc.zip Qt-9fa9221af7ca452d19a0754f38d81299ad749dbc.tar.gz Qt-9fa9221af7ca452d19a0754f38d81299ad749dbc.tar.bz2 |
Merge branch 'kinetic-animations' into kinetic-statemachine
27 files changed, 233 insertions, 782 deletions
diff --git a/bin/snapshot b/bin/snapshot index ffad857..fa9a2ac 100644 --- a/bin/snapshot +++ b/bin/snapshot @@ -39,6 +39,7 @@ my @files = ( "corelib/animation/qsequentialanimationgroup.cpp", "corelib/animation/qsequentialanimationgroup.h", "corelib/animation/qsequentialanimationgroup_p.h", + "gui/animation/qguivariantanimation.cpp", "corelib/statemachine/statemachine.pri", "corelib/statemachine/qabstractstate.cpp", "corelib/statemachine/qabstractstate.h", @@ -142,7 +143,6 @@ my %animation_examples = ( "bomb.cpp", "bomb.h", "custompropertyanimation.h", - "custompropertyanimation_p.h", "custompropertyanimation.cpp", "graphicsscene.cpp", "graphicsscene.h", diff --git a/examples/animation/easing/window.cpp b/examples/animation/easing/window.cpp index c6ea360..bb45770 100644 --- a/examples/animation/easing/window.cpp +++ b/examples/animation/easing/window.cpp @@ -88,7 +88,7 @@ void Window::startAnimation() m_anim->setStartValue(QPointF(0, 0)); m_anim->setEndValue(QPointF(100, 100)); m_anim->setDuration(2000); - m_anim->setIterationCount(-1); // forever + m_anim->setLoopCount(-1); // forever m_anim->start(); } diff --git a/examples/animation/research/memberfunctions/qvalueanimation.cpp b/examples/animation/research/memberfunctions/qvalueanimation.cpp index 2fe9be9..58652ba 100644 --- a/examples/animation/research/memberfunctions/qvalueanimation.cpp +++ b/examples/animation/research/memberfunctions/qvalueanimation.cpp @@ -21,8 +21,8 @@ void QValueAnimationPrivate::initDefaultStartValue() { Q_Q(QValueAnimation); if (animProp && !q->startValue().isValid() - && ((currentTime == 0 && (currentIteration || currentIteration == 0)) - || (currentTime == duration && currentIteration == (iterationCount - 1)))) { + && (currentTime == 0 + || (currentTime == duration && currentLoop == (loopCount - 1)))) { setDefaultStartValue(animProp->read()); } } diff --git a/examples/animation/sub-attaq/custompropertyanimation.cpp b/examples/animation/sub-attaq/custompropertyanimation.cpp index 45997af..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,23 +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 && (currentIteration || currentIteration == 0)) - || (currentTime == duration && currentIteration == (iterationCount - 1)))) { - setDefaultStartValue(def); - } -} - - CustomPropertyAnimation::CustomPropertyAnimation(QObject *parent) : - QVariantAnimation(*new CustomPropertyAnimationPrivate, parent) + QVariantAnimation(parent), animProp(0) { } @@ -72,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; } /*! @@ -86,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); } @@ -99,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/qanimationstate.h b/examples/animation/sub-attaq/qanimationstate.h index fda1534..ddf5681 100644 --- a/examples/animation/sub-attaq/qanimationstate.h +++ b/examples/animation/sub-attaq/qanimationstate.h @@ -60,7 +60,7 @@ QT_MODULE(Gui) class QAnimationStatePrivate; -class Q_GUI_EXPORT QAnimationState : public QState +class QAnimationState : public QState { Q_OBJECT public: 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 \ diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 2b9e77d..71ef45c 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -55,15 +55,15 @@ QVariantAnimation and QAnimationGroup, instead. QAbstractAnimation provides an interface for the current time and - duration, the iteration count, and the state of an animation. These properties + duration, the loop count, and the state of an animation. These properties define the base functionality common to all animations in Qt. The virtual duration() function returns the local duration of the animation; i.e., for how long the animation should update the current time before looping. Subclasses can implement this function differently; for example, QVariantAnimation returns the duration of a simple animated property, whereas QAnimationGroup returns the duration of a set or sequence of - animations. You can also set a loop count by calling setIterationCount(); a - iteration count of 2 will let the animation run twice (the default value is + animations. You can also set a loop count by calling setLoopCount(); a + loop count of 2 will let the animation run twice (the default value is 1). Like QTimeLine, QAbstractAnimation also provides an interface for starting @@ -119,12 +119,12 @@ */ /*! - \fn QAbstractAnimation::currentIterationChanged(int currentIteration) + \fn QAbstractAnimation::currentLoopChanged(int currentLoop) - QAbstractAnimation emits this signal whenever the current iteration - changes. \a currentIteration is the current iteration. + QAbstractAnimation emits this signal whenever the current loop + changes. \a currentLoop is the current loop. - \sa currentIteration(), iterationCount() + \sa currentLoop(), loopCount() */ /*! @@ -245,7 +245,7 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) QAbstractAnimation::State oldState = state; int oldCurrentTime = currentTime; - int oldCurrentIteration = currentIteration; + int oldCurrentLoop = currentLoop; QAbstractAnimation::Direction oldDirection = direction; state = newState; @@ -274,7 +274,7 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) if (direction == QAbstractAnimation::Forward) q->setCurrentTime(0); else - q->setCurrentTime(iterationCount == -1 ? q->duration() : q->totalDuration()); + q->setCurrentTime(loopCount == -1 ? q->duration() : q->totalDuration()); } // Check if the setCurrentTime() function called stop(). @@ -302,8 +302,8 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) QUnifiedTimer::instance()->unregisterAnimation(q); - if (dura == -1 || iterationCount < 0 - || (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentIteration + 1)) == (dura * iterationCount)) + if (dura == -1 || loopCount < 0 + || (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * loopCount)) || (oldDirection == QAbstractAnimation::Backward && oldCurrentTime == 0)) { if (guard) emit q->finished(); @@ -459,10 +459,10 @@ void QAbstractAnimation::setDirection(Direction direction) if (state() == Stopped) { if (direction == Backward) { d->currentTime = duration(); - d->currentIteration = d->iterationCount - 1; + d->currentLoop = d->loopCount - 1; } else { d->currentTime = 0; - d->currentIteration = 0; + d->currentLoop = 0; } } updateDirection(direction); @@ -474,14 +474,14 @@ void QAbstractAnimation::setDirection(Direction direction) \brief the duration of the animation. If the duration is -1, it means that the duration is undefined. - In this case, iterationCount is ignored. + In this case, loopCount is ignored. */ /*! - \property QAbstractAnimation::iterationCount - \brief the iteration count of the animation + \property QAbstractAnimation::loopCount + \brief the loop count of the animation - This property describes the iteration count of the animation as an integer. + This property describes the loop count of the animation as an integer. By default this value is 1, indicating that the animation should run once only, and then stop. By changing it you can let the animation loop several times. With a value of 0, the animation will not @@ -490,34 +490,34 @@ void QAbstractAnimation::setDirection(Direction direction) It is not supported to have loop on an animation that has an undefined duration. It will only run once. */ -int QAbstractAnimation::iterationCount() const +int QAbstractAnimation::loopCount() const { Q_D(const QAbstractAnimation); - return d->iterationCount; + return d->loopCount; } -void QAbstractAnimation::setIterationCount(int iterationCount) +void QAbstractAnimation::setLoopCount(int loopCount) { Q_D(QAbstractAnimation); - d->iterationCount = iterationCount; + d->loopCount = loopCount; } /*! - \property QAbstractAnimation::currentIteration - \brief the current iteration of the animation + \property QAbstractAnimation::currentLoop + \brief the current loop of the animation - This property describes the current iteration of the animation. By default, - the animation's iteration count is 1, and so the current iteration will - always be 0. If the iteration count is 2 and the animation runs past its + This property describes the current loop of the animation. By default, + the animation's loop count is 1, and so the current loop will + always be 0. If the loop count is 2 and the animation runs past its duration, it will automatically rewind and restart at current time 0, and - current iteration 1, and so on. + current loop 1, and so on. - When the current iteration changes, QAbstractAnimation emits the - currentIterationChanged() signal. + When the current loop changes, QAbstractAnimation emits the + currentLoopChanged() signal. */ -int QAbstractAnimation::currentIteration() const +int QAbstractAnimation::currentLoop() const { Q_D(const QAbstractAnimation); - return d->currentIteration; + return d->currentLoop; } /*! @@ -525,7 +525,7 @@ int QAbstractAnimation::currentIteration() const This pure virtual function returns the duration of the animation, and defines for how long QAbstractAnimation should update the current - time. This duration is local, and does not include the iteration count. + time. This duration is local, and does not include the loop count. A return value of -1 indicates that the animation has no defined duration; the animation should run forever until stopped. This is useful for @@ -535,24 +535,24 @@ int QAbstractAnimation::currentIteration() const If the animation is a parallel QAnimationGroup, the duration will be the longest duration of all its animations. If the animation is a sequential QAnimationGroup, the duration will be the sum of the duration of all its animations. - \sa iterationCount + \sa loopCount */ /*! Returns the total and effective duration of the animation, including the - iteration count. + loop count. \sa duration(), currentTime */ int QAbstractAnimation::totalDuration() const { Q_D(const QAbstractAnimation); - if (d->iterationCount < 0) + if (d->loopCount < 0) return -1; int dura = duration(); if (dura == -1) return -1; - return dura * d->iterationCount; + return dura * d->loopCount; } /*! @@ -565,11 +565,11 @@ int QAbstractAnimation::totalDuration() const progresses. The animation's current time starts at 0, and ends at duration(). If the - animation's iterationCount is larger than 1, the current time will rewind and + animation's loopCount is larger than 1, the current time will rewind and start at 0 again for the consecutive loops. If the animation has a pause. currentTime will also include the duration of the pause. - \sa iterationCount + \sa loopCount */ int QAbstractAnimation::currentTime() const { @@ -583,31 +583,31 @@ void QAbstractAnimation::setCurrentTime(int msecs) // Calculate new time and loop. int dura = duration(); - int totalDura = (d->iterationCount < 0 || dura == -1) ? -1 : dura * d->iterationCount; + int totalDura = (d->loopCount < 0 || dura == -1) ? -1 : dura * d->loopCount; if (totalDura != -1) msecs = qMin(totalDura, msecs); d->totalCurrentTime = msecs; // Update new values. - int oldLoop = d->currentIteration; - d->currentIteration = ((dura <= 0) ? 0 : (msecs / dura)); - if (d->currentIteration == d->iterationCount) { + int oldLoop = d->currentLoop; + d->currentLoop = ((dura <= 0) ? 0 : (msecs / dura)); + if (d->currentLoop == d->loopCount) { //we're at the end d->currentTime = qMax(0, dura); - d->currentIteration = qMax(0, d->iterationCount - 1); + d->currentLoop = qMax(0, d->loopCount - 1); } else { if (d->direction == Forward) { d->currentTime = (dura <= 0) ? msecs : (msecs % dura); } else { d->currentTime = (dura <= 0) ? msecs : ((msecs - 1) % dura) + 1; if (d->currentTime == dura) - --d->currentIteration; + --d->currentLoop; } } updateCurrentTime(msecs); - if (d->currentIteration != oldLoop) - emit currentIterationChanged(d->currentIteration); + if (d->currentLoop != oldLoop) + emit currentLoopChanged(d->currentLoop); // All animations are responsible for stopping the animation when their // own end state is reached; in this case the animation is time driven, @@ -648,7 +648,7 @@ void QAbstractAnimation::start(DeletionPolicy policy) signal, and state() returns Stopped. The current time is not changed. If the animation stops by itself after reaching the end (i.e., - currentTime() == duration() and currentIteration() > iterationCount() - 1), the + currentTime() == duration() and currentLoop() > loopCount() - 1), the finished() signal is emitted. \sa start(), state() diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h index d6260cd..a7f0082 100644 --- a/src/corelib/animation/qabstractanimation.h +++ b/src/corelib/animation/qabstractanimation.h @@ -60,9 +60,9 @@ class Q_CORE_EXPORT QAbstractAnimation : public QObject { Q_OBJECT Q_PROPERTY(State state READ state NOTIFY stateChanged) - Q_PROPERTY(int iterationCount READ iterationCount WRITE setIterationCount) + Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount) Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime) - Q_PROPERTY(int currentIteration READ currentIteration NOTIFY currentIterationChanged) + Q_PROPERTY(int currentLoop READ currentLoop NOTIFY currentLoopChanged) Q_PROPERTY(Direction direction READ direction WRITE setDirection NOTIFY directionChanged) Q_PROPERTY(int duration READ duration) @@ -93,9 +93,9 @@ public: Direction direction() const; void setDirection(Direction direction); - int iterationCount() const; - void setIterationCount(int iterationCount); - int currentIteration() const; + int loopCount() const; + void setLoopCount(int loopCount); + int currentLoop() const; virtual int duration() const = 0; int totalDuration() const; @@ -105,7 +105,7 @@ public: Q_SIGNALS: void finished(); void stateChanged(QAbstractAnimation::State oldState, QAbstractAnimation::State newState); - void currentIterationChanged(int currentIteration); + void currentLoopChanged(int currentLoop); void directionChanged(QAbstractAnimation::Direction); public Q_SLOTS: diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index 28d7d71..666e6a7 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -77,8 +77,8 @@ public: deleteWhenStopped(false), totalCurrentTime(0), currentTime(0), - iterationCount(1), - currentIteration(0), + loopCount(1), + currentLoop(0), group(0) { } @@ -97,8 +97,8 @@ public: int totalCurrentTime; int currentTime; - int iterationCount; - int currentIteration; + int loopCount; + int currentLoop; QAnimationGroup *group; #ifdef QT_EXPERIMENTAL_SOLUTION diff --git a/src/corelib/animation/qparallelanimationgroup.cpp b/src/corelib/animation/qparallelanimationgroup.cpp index 993c577..407ffde 100644 --- a/src/corelib/animation/qparallelanimationgroup.cpp +++ b/src/corelib/animation/qparallelanimationgroup.cpp @@ -111,7 +111,7 @@ void QParallelAnimationGroup::updateCurrentTime(int) if (d->animations.isEmpty()) return; - if (d->currentIteration > d->lastIteration) { + if (d->currentLoop > d->lastLoop) { // simulate completion of the loop int dura = duration(); if (dura > 0) { @@ -119,7 +119,7 @@ void QParallelAnimationGroup::updateCurrentTime(int) animation->setCurrentTime(dura); // will stop } } - } else if (d->currentIteration < d->lastIteration) { + } else if (d->currentLoop < d->lastLoop) { // simulate completion of the loop seeking backwards foreach (QAbstractAnimation *animation, d->animations) { animation->setCurrentTime(0); @@ -127,11 +127,11 @@ void QParallelAnimationGroup::updateCurrentTime(int) } } - bool timeFwd = ((d->currentIteration == d->lastIteration && d->currentTime >= d->lastCurrentTime) - || d->currentIteration > d->lastIteration); + bool timeFwd = ((d->currentLoop == d->lastLoop && d->currentTime >= d->lastCurrentTime) + || d->currentLoop > d->lastLoop); #ifdef QANIMATION_DEBUG qDebug("QParallellAnimationGroup %5d: setCurrentTime(%d), loop:%d, last:%d, timeFwd:%d, lastcurrent:%d, %d", - __LINE__, d->currentTime, d->currentIteration, d->lastIteration, timeFwd, d->lastCurrentTime, state()); + __LINE__, d->currentTime, d->currentLoop, d->lastLoop, timeFwd, d->lastCurrentTime, state()); #endif // finally move into the actual time of the current loop foreach (QAbstractAnimation *animation, d->animations) { @@ -139,7 +139,7 @@ void QParallelAnimationGroup::updateCurrentTime(int) if (dura == -1 && d->isUncontrolledAnimationFinished(animation)) continue; if (dura == -1 || (d->currentTime <= dura && dura != 0) - || (dura == 0 && d->currentIteration != d->lastIteration)) { + || (dura == 0 && d->currentLoop != d->lastLoop)) { switch (state()) { case Running: animation->start(); @@ -165,7 +165,7 @@ void QParallelAnimationGroup::updateCurrentTime(int) if (d->currentTime > dura) animation->stop(); } - d->lastIteration = d->currentIteration; + d->lastLoop = d->currentLoop; d->lastCurrentTime = d->currentTime; } @@ -207,7 +207,7 @@ void QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished() Q_ASSERT(animation); int uncontrolledRunningCount = 0; - if (animation->duration() == -1 || animation->iterationCount() < 0) { + if (animation->duration() == -1 || animation->loopCount() < 0) { QHash<QAbstractAnimation *, int>::iterator it = uncontrolledFinishTime.begin(); while (it != uncontrolledFinishTime.end()) { if (it.key() == animation) { @@ -248,7 +248,7 @@ void QParallelAnimationGroupPrivate::connectUncontrolledAnimations() Q_Q(QParallelAnimationGroup); foreach (QAbstractAnimation *animation, animations) { - if (animation->duration() == -1 || animation->iterationCount() < 0) { + if (animation->duration() == -1 || animation->loopCount() < 0) { uncontrolledFinishTime[animation] = -1; QObject::connect(animation, SIGNAL(finished()), q, SLOT(_q_uncontrolledAnimationFinished())); } @@ -273,11 +273,11 @@ void QParallelAnimationGroup::updateDirection(QAbstractAnimation::Direction dire } } else { if (direction == Forward) { - d->lastIteration = 0; + d->lastLoop = 0; d->lastCurrentTime = 0; } else { - // Looping backwards with iterationCount == -1 does not really work well... - d->lastIteration = (d->iterationCount == -1 ? 0 : d->iterationCount - 1); + // Looping backwards with loopCount == -1 does not really work well... + d->lastLoop = (d->loopCount == -1 ? 0 : d->loopCount - 1); d->lastCurrentTime = duration(); } } diff --git a/src/corelib/animation/qparallelanimationgroup_p.h b/src/corelib/animation/qparallelanimationgroup_p.h index 8a4dc1b..f36d972 100644 --- a/src/corelib/animation/qparallelanimationgroup_p.h +++ b/src/corelib/animation/qparallelanimationgroup_p.h @@ -64,12 +64,12 @@ class QParallelAnimationGroupPrivate : public QAnimationGroupPrivate Q_DECLARE_PUBLIC(QParallelAnimationGroup) public: QParallelAnimationGroupPrivate() - : lastIteration(0), lastCurrentTime(0) + : lastLoop(0), lastCurrentTime(0) { } QHash<QAbstractAnimation*, int> uncontrolledFinishTime; - int lastIteration; + int lastLoop; int lastCurrentTime; bool isUncontrolledAnimationFinished(QAbstractAnimation *anim) const; diff --git a/src/corelib/animation/qpropertyanimation.h b/src/corelib/animation/qpropertyanimation.h index e5d5305..b619256 100644 --- a/src/corelib/animation/qpropertyanimation.h +++ b/src/corelib/animation/qpropertyanimation.h @@ -47,7 +47,6 @@ #else # include <QtCore/qvariantanimation.h> #endif -#include <QtCore/qvariant.h> QT_BEGIN_HEADER diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp index 879532c..61ff98d 100644 --- a/src/corelib/animation/qsequentialanimationgroup.cpp +++ b/src/corelib/animation/qsequentialanimationgroup.cpp @@ -77,7 +77,7 @@ bool QSequentialAnimationGroupPrivate::atEnd() const // 3. the current animation is the last one // 4. the current animation has reached its end const int animTotalCurrentTime = QAbstractAnimationPrivate::get(currentAnimation)->totalCurrentTime; - return (currentIteration == iterationCount - 1 + return (currentLoop == loopCount - 1 && direction == QAbstractAnimation::Forward && currentAnimation == animations.last() && animTotalCurrentTime == animationActualTotalDuration(currentAnimationIndex)); @@ -101,7 +101,7 @@ QSequentialAnimationGroupPrivate::AnimationIndex QSequentialAnimationGroupPrivat int duration = 0; // in case duration is -1, currentLoop will always be 0 - ret.timeOffset = currentIteration * q->duration(); + ret.timeOffset = currentLoop * q->duration(); for (int i = 0; i < animations.size(); ++i) { duration = animationActualTotalDuration(i); @@ -133,13 +133,13 @@ void QSequentialAnimationGroupPrivate::restart() { // restarting the group by making the first/last animation the current one if (direction == QAbstractAnimation::Forward) { - lastIteration = 0; + lastLoop = 0; if (currentAnimationIndex == 0) activateCurrentAnimation(); else setCurrentAnimation(0); } else { // direction == QAbstractAnimation::Backward - lastIteration = iterationCount - 1; + lastLoop = loopCount - 1; int index = animations.size() - 1; if (currentAnimationIndex == index) activateCurrentAnimation(); @@ -156,7 +156,7 @@ void QSequentialAnimationGroupPrivate::restart() */ void QSequentialAnimationGroupPrivate::advanceForwards(const AnimationIndex &newAnimationIndex) { - if (lastIteration < currentIteration) { + if (lastLoop < currentLoop) { // we need to fast forward to the end for (int i = currentAnimationIndex; i < animations.size(); ++i) { QAbstractAnimation *anim = animations.at(i); @@ -188,7 +188,7 @@ void QSequentialAnimationGroupPrivate::advanceForwards(const AnimationIndex &new */ void QSequentialAnimationGroupPrivate::rewindForwards(const AnimationIndex &newAnimationIndex) { - if (lastIteration > currentIteration) { + if (lastLoop > currentLoop) { // we need to fast rewind to the beginning for (int i = currentAnimationIndex; i >= 0 ; --i) { QAbstractAnimation *anim = animations.at(i); @@ -329,12 +329,12 @@ void QSequentialAnimationGroup::updateCurrentTime(int msecs) d->actualDuration.removeLast(); // newAnimationIndex.index is the new current animation - if (d->lastIteration < d->currentIteration - || (d->lastIteration == d->currentIteration && d->currentAnimationIndex < newAnimationIndex.index)) { + if (d->lastLoop < d->currentLoop + || (d->lastLoop == d->currentLoop && d->currentAnimationIndex < newAnimationIndex.index)) { // advancing with forward direction is the same as rewinding with backwards direction d->advanceForwards(newAnimationIndex); - } else if (d->lastIteration > d->currentIteration - || (d->lastIteration == d->currentIteration && d->currentAnimationIndex > newAnimationIndex.index)) { + } else if (d->lastLoop > d->currentLoop + || (d->lastLoop == d->currentLoop && d->currentAnimationIndex > newAnimationIndex.index)) { // rewinding with forward direction is the same as advancing with backwards direction d->rewindForwards(newAnimationIndex); } @@ -358,7 +358,7 @@ void QSequentialAnimationGroup::updateCurrentTime(int msecs) stop(); } - d->lastIteration = d->currentIteration; + d->lastLoop = d->currentLoop; } /*! @@ -505,7 +505,7 @@ void QSequentialAnimationGroupPrivate::animationInsertedAt(int index) setCurrentAnimation(0); // initialize the current animation if (currentAnimationIndex == index - && currentAnimation->currentTime() == 0 && currentAnimation->currentIteration() == 0) { + && currentAnimation->currentTime() == 0 && currentAnimation->currentLoop() == 0) { //in this case we simply insert an animation before the current one has actually started setCurrentAnimation(index); } @@ -513,7 +513,7 @@ void QSequentialAnimationGroupPrivate::animationInsertedAt(int index) //we update currentAnimationIndex in case it has changed (the animation pointer is still valid) currentAnimationIndex = animations.indexOf(currentAnimation); - if (index < currentAnimationIndex || currentIteration != 0) { + if (index < currentAnimationIndex || currentLoop != 0) { qWarning("QSequentialGroup::insertAnimationAt only supports to add animations after the current one."); return; //we're not affected because it is added after the current one } @@ -562,7 +562,7 @@ void QSequentialAnimationGroupPrivate::animationRemovedAt(int index) } //let's also update the total current time - totalCurrentTime = currentTime + iterationCount * q->duration(); + totalCurrentTime = currentTime + loopCount * q->duration(); } QT_END_NAMESPACE diff --git a/src/corelib/animation/qsequentialanimationgroup_p.h b/src/corelib/animation/qsequentialanimationgroup_p.h index 05d2a40..3ac90f8 100644 --- a/src/corelib/animation/qsequentialanimationgroup_p.h +++ b/src/corelib/animation/qsequentialanimationgroup_p.h @@ -64,7 +64,7 @@ class QSequentialAnimationGroupPrivate : public QAnimationGroupPrivate Q_DECLARE_PUBLIC(QSequentialAnimationGroup) public: QSequentialAnimationGroupPrivate() - : currentAnimation(0), currentAnimationIndex(-1), lastIteration(0) + : currentAnimation(0), currentAnimationIndex(-1), lastLoop(0) { } @@ -96,7 +96,7 @@ public: QList<int> actualDuration; void restart(); - int lastIteration; + int lastLoop; // handle time changes void rewindForwards(const AnimationIndex &newAnimationIndex); diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index 6b162ae..52e2901 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -279,7 +279,7 @@ QVariantAnimation::~QVariantAnimation() of the interpolated property. The easing curve is used with the interpolator, the interpolated() virtual - function, the animation's duration, and iterationCount, to control how the + function, the animation's duration, and loopCount, to control how the current value changes as the animation progresses. */ QEasingCurve QVariantAnimation::easingCurve() const diff --git a/src/corelib/animation/qvariantanimation.h b/src/corelib/animation/qvariantanimation.h index 7ce597f..69dbbf3 100644 --- a/src/corelib/animation/qvariantanimation.h +++ b/src/corelib/animation/qvariantanimation.h @@ -49,8 +49,7 @@ # include <QtCore/qeasingcurve.h> # include <QtCore/qabstractanimation.h> #endif -#include <QtCore/qlist.h> -#include <QtCore/qpoint.h> +#include <QtCore/qvector.h> #include <QtCore/qvariant.h> #include <QtCore/qpair.h> diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h index e468ac9..c51b471 100644 --- a/src/corelib/animation/qvariantanimation_p.h +++ b/src/corelib/animation/qvariantanimation_p.h @@ -97,7 +97,7 @@ public: bool atEnd() const { - return currentTime == duration && currentIteration == (iterationCount - 1); + return currentTime == duration && currentLoop == (loopCount - 1); } void setDefaultStartValue(const QVariant &value); diff --git a/src/gui/animation/animation.pri b/src/gui/animation/animation.pri index 3092117..27763ca 100644 --- a/src/gui/animation/animation.pri +++ b/src/gui/animation/animation.pri @@ -1,8 +1,3 @@ # Qt gui animation module -HEADERS += \ - animation/qitemanimation.h \ - animation/qitemanimation_p.h - -SOURCES += \ - animation/qitemanimation.cpp +SOURCES += animation/qguivariantanimation.cpp diff --git a/src/gui/animation/qitemanimation_p.h b/src/gui/animation/qguivariantanimation.cpp index 027c199..46ba251 100644 --- a/src/gui/animation/qitemanimation_p.h +++ b/src/gui/animation/qguivariantanimation.cpp @@ -39,45 +39,41 @@ ** ****************************************************************************/ -#ifndef QITEMANIMATION_P_H -#define QITEMANIMATION_P_H +#ifndef QT_NO_ANIMATION -// -// 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 "qitemanimation.h" +QT_BEGIN_NAMESPACE -#if defined(QT_EXPERIMENTAL_SOLUTION) -#include "qvariantanimation_p.h" +#ifdef QT_EXPERIMENTAL_SOLUTION +# include "qvariantanimation.h" +# include "qvariantanimation_p.h" #else -#include "private/qvariantanimation_p.h" +#include <QtCore/qvariantanimation.h> +#include <private/qvariantanimation_p.h> #endif -QT_BEGIN_NAMESPACE -class QItemAnimationPrivate : public QVariantAnimationPrivate +template<> Q_INLINE_TEMPLATE QColor _q_interpolate(const QColor &f,const QColor &t, qreal progress) { - Q_DECLARE_PUBLIC(QItemAnimation) -public: - QItemAnimationPrivate() : propertyName(QItemAnimation::None), - target(0) - { - } + return QColor(_q_interpolate(f.red(), t.red(), progress), + _q_interpolate(f.green(), t.green(), progress), + _q_interpolate(f.blue(), t.blue(), progress), + _q_interpolate(f.alpha(), t.alpha(), progress)); +} - void initDefaultStartValue(); +static int qRegisterGuiGetInterpolator() +{ + qRegisterAnimationInterpolator<QColor>(_q_interpolateVariant<QColor>); + return 1; +} +Q_CONSTRUCTOR_FUNCTION(qRegisterGuiGetInterpolator) - QItemAnimation::PropertyName propertyName; - QGraphicsItem *target; -}; +static int qUnregisterGuiGetInterpolator() +{ + qRegisterAnimationInterpolator<QColor>(0); + return 1; +} +Q_DESTRUCTOR_FUNCTION(qUnregisterGuiGetInterpolator) QT_END_NAMESPACE -#endif //QITEMANIMATION_P_H +#endif //QT_NO_ANIMATION diff --git a/src/gui/animation/qitemanimation.cpp b/src/gui/animation/qitemanimation.cpp deleted file mode 100644 index 484b386..0000000 --- a/src/gui/animation/qitemanimation.cpp +++ /dev/null @@ -1,361 +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 QtGui 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$ -** -****************************************************************************/ - -/*! - \class QItemAnimation - \brief The QItemAnimation class animates properties for QGraphicsItem - \since 4.5 - \ingroup animation - \preliminary - - This class is part of {The Animation Framework}. You can use QItemAnimation - by itself as a simple animation class, or as part of more complex - animations through QAnimationGroup. - - The most common way to use QItemAnimation is to construct an instance - of it by passing a pointer to a QGraphicsItem and the property you - would like to animate to QItemAnimation's constructor. - - The start value of the animation is optional. If you do not set any start - value, the animation will operate on the target's current property value - at the point when the animation was started. You can call setStartValue() - to set the start value, and setEndValue() to set the target value for - the animated property. - - You can choose to assign a target item by either calling setTargetItem() - or by passing a QGraphicsItem pointer to QVariantAnimation's constructor. - - \sa QVariantAnimation, QAnimationGroup, {The Animation Framework} -*/ - - -#ifndef QT_NO_ANIMATION - -#include "qitemanimation.h" -#include "qitemanimation_p.h" - -#include <QtCore/QMutex> -#ifdef QT_EXPERIMENTAL_SOLUTION -#include "qanimationgroup.h" -#else -#include <QtCore/QAnimationGroup> -#endif -#include <QtGui/QGraphicsItem> - - -QT_BEGIN_NAMESPACE - -typedef QPair<QGraphicsItem *, QItemAnimation::PropertyName> QItemAnimationPair; -typedef QHash<QItemAnimationPair, QItemAnimation*> QItemAnimationHash; -Q_GLOBAL_STATIC(QItemAnimationHash, _q_runningAnimations) -Q_GLOBAL_STATIC_WITH_ARGS(QMutex, guardHashLock, (QMutex::Recursive) ) - -void QItemAnimationPrivate::initDefaultStartValue() -{ - if (target && !defaultStartValue.isValid() && (atBeginning() || atEnd())) { - switch (propertyName) - { - case QItemAnimation::Position: - setDefaultStartValue(target->pos()); - break; - case QItemAnimation::Opacity: - setDefaultStartValue(target->opacity()); - break; - case QItemAnimation::RotationX: - setDefaultStartValue(target->xRotation()); - break; - case QItemAnimation::RotationY: - setDefaultStartValue(target->yRotation()); - break; - case QItemAnimation::RotationZ: - setDefaultStartValue(target->zRotation()); - break; - case QItemAnimation::ScaleFactorX: - setDefaultStartValue(target->xScale()); - break; - case QItemAnimation::ScaleFactorY: - setDefaultStartValue(target->yScale()); - break; - default: - break; - } - } -} - - -/*! - Construct a QItemAnimation object. \a parent is passed to QObject's - constructor. -*/ - -QItemAnimation::QItemAnimation(QObject *parent) : QVariantAnimation(*new QItemAnimationPrivate, parent) -{ -} - -/*! - Construct a QItemAnimation object. \a parent is passed to QObject's - constructor. The animation changes the property \a propertyName on \a - target. The default duration is 250ms. - - \sa targetItem, propertyName -*/ - -QItemAnimation::QItemAnimation(QGraphicsItem *target, PropertyName p, QObject *parent) : QVariantAnimation(*new QItemAnimationPrivate, parent) -{ - Q_D(QItemAnimation); - d->target = target; - d->propertyName = p; -} - -/*! - Destroys the QPropertyAnimation instance. - */ -QItemAnimation::~QItemAnimation() -{ - stop(); -} - -/*! - \property QItemAnimation::targetItem - \brief the target Graphics Item for this animation. - - This property defines the target item for this animation. - - \sa targetItem - */ - -QGraphicsItem *QItemAnimation::targetItem() const -{ - Q_D(const QItemAnimation); - return d->target; -} - -void QItemAnimation::setTargetItem(QGraphicsItem *item) -{ - Q_D(QItemAnimation); - d->target = item; -} - -/*! - \property QItemAnimation::propertyName - \brief the target property for this animation - - This property defines the target property for this animation. The - property is required for the animation to operate. - */ -QItemAnimation::PropertyName QItemAnimation::propertyName() const -{ - Q_D(const QItemAnimation); - return d->propertyName; -} - -void QItemAnimation::setPropertyName(PropertyName p) -{ - Q_D(QItemAnimation); - d->propertyName = p; -} - -/*! - This static function returns the list of running animations on \a item. - If item is 0, then it returns all QItemAnimations running on all QGraphicsItem. - */ -QList<QItemAnimation*> QItemAnimation::runningAnimations(QGraphicsItem *item) -{ - QMutexLocker locker(guardHashLock()); - QList<QItemAnimation*> animList = _q_runningAnimations()->values(); - if (item == 0) - return animList; - - QList<QItemAnimation*> ret; - - for (QList<QItemAnimation*>::const_iterator it = animList.constBegin(); it != animList.constEnd(); ++it) { - if ((*it)->targetItem() == item) - ret += *it; - } - - return ret; -} - -/*! - This static function returns the running animations on \a item and on \a property. - \a prop. - */ -QItemAnimation* QItemAnimation::runningAnimation(QGraphicsItem *item, PropertyName prop) -{ - QMutexLocker locker(guardHashLock()); - return _q_runningAnimations()->value(qMakePair(item, prop), 0 /*default value*/); -} - -/*! - \reimp - */ -bool QItemAnimation::event(QEvent *event) -{ - return QVariantAnimation::event(event); -} - -/*! - \reimp - */ -void QItemAnimation::updateCurrentValue(const QVariant &value) -{ - Q_D(QItemAnimation); - if (!d->target || d->state == Stopped) - return; - - switch (d->propertyName) - { - case Position: - d->target->setPos(qVariantValue<QPointF>(value)); - break; - case Opacity: - d->target->setOpacity(qVariantValue<qreal>(value)); - break; - case RotationX: - d->target->setXRotation(qVariantValue<qreal>(value)); - break; - case RotationY: - d->target->setYRotation(qVariantValue<qreal>(value)); - break; - case RotationZ: - d->target->setZRotation(qVariantValue<qreal>(value)); - break; - case ScaleFactorX: - d->target->setXScale(qVariantValue<qreal>(value)); - break; - case ScaleFactorY: - d->target->setYScale(qVariantValue<qreal>(value)); - break; - default: - qWarning("The property you're trying to animate is not managed by the item"); - break; - } -} - - -/*! - \reimp -*/ -void QItemAnimation::updateState(QAbstractAnimation::State oldState, - QAbstractAnimation::State newState) -{ - Q_D(QItemAnimation); - QVariantAnimation::updateState(oldState, newState); - QMutexLocker locker(guardHashLock()); - QItemAnimationHash *hash = _q_runningAnimations(); - QItemAnimationPair key(d->target, d->propertyName); - - //let's try to convert start and target values according to the type of the proerty - //we're animating - if (newState != Stopped) { - int type = QVariant::Invalid; - switch (d->propertyName) - { - case Position: - type = QVariant::PointF; - break; - case Opacity: - case RotationX: - case RotationY: - case RotationZ: - case ScaleFactorX: - case ScaleFactorY: - type = qMetaTypeId<qreal>(); - break; - case None: - default: - break; - - } - if (type != QVariant::Invalid) { - d->convertValues(type); - } - } - - if (newState == Running) { - if (hash->contains(key)) { - QItemAnimation *oldAnim = hash->value(key); - if (oldAnim != this) { - //we try to stop the top level group - QAbstractAnimation *current = oldAnim; - while(current->group() && current->state() != Stopped) current = current->group(); - current->stop(); - } - } - hash->insert(key, this); - // Initialize start value - d->initDefaultStartValue(); - - } else if (hash->value(key) == this) { - hash->remove(key); - } -} - -///TODO: should be placed somewhere else (in its own file) -template<> Q_INLINE_TEMPLATE QColor _q_interpolate(const QColor &f,const QColor &t, qreal progress) -{ - return QColor(_q_interpolate(f.red(), t.red(), progress), - _q_interpolate(f.green(), t.green(), progress), - _q_interpolate(f.blue(), t.blue(), progress), - _q_interpolate(f.alpha(), t.alpha(), progress)); -} - - - -static int qRegisterGuiGetInterpolator() -{ - qRegisterAnimationInterpolator<QColor>(_q_interpolateVariant<QColor>); - return 1; -} -Q_CONSTRUCTOR_FUNCTION(qRegisterGuiGetInterpolator) - -static int qUnregisterGuiGetInterpolator() -{ - qRegisterAnimationInterpolator<QColor>(0); - return 1; -} -Q_DESTRUCTOR_FUNCTION(qUnregisterGuiGetInterpolator) - -QT_END_NAMESPACE - -#include "moc_qitemanimation.cpp" - -#endif //QT_NO_ANIMATION diff --git a/src/gui/animation/qitemanimation.h b/src/gui/animation/qitemanimation.h deleted file mode 100644 index d630fe7..0000000 --- a/src/gui/animation/qitemanimation.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 QtGui 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 QITEMANIMATION_H -#define QITEMANIMATION_H - -#if defined(QT_EXPERIMENTAL_SOLUTION) -# include "qvariantanimation.h" -#else -# include <QtCore/qvariantanimation.h> -#endif - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -#ifndef QT_NO_ANIMATION - -class QGraphicsItem; - -class QItemAnimationPrivate; -class Q_GUI_EXPORT QItemAnimation : public QVariantAnimation -{ -public: - enum PropertyName - { - None, //default - Position, - Opacity, - RotationX, - RotationY, - RotationZ, - ScaleFactorX, - ScaleFactorY - }; - - Q_OBJECT - Q_PROPERTY(PropertyName propertyName READ propertyName WRITE setPropertyName) - Q_PROPERTY(QGraphicsItem* targetItem READ targetItem WRITE setTargetItem) /*NOTIFY targetItemChanged*/ - -public: - QItemAnimation(QObject *parent = 0); - QItemAnimation(QGraphicsItem *target, PropertyName p = None, QObject *parent = 0); - ~QItemAnimation(); - - QGraphicsItem *targetItem() const; - void setTargetItem(QGraphicsItem *item); - - PropertyName propertyName() const; - void setPropertyName(PropertyName); - - static QList<QItemAnimation*> runningAnimations(QGraphicsItem *item = 0); - static QItemAnimation* runningAnimation(QGraphicsItem *item, PropertyName prop); - -protected: - bool event(QEvent *event); - void updateCurrentValue(const QVariant &value); - void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState); - -private: - Q_DISABLE_COPY(QItemAnimation) - Q_DECLARE_PRIVATE(QItemAnimation) -}; - -#endif //QT_NO_ANIMATION - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif //QITEMANIMATION_H diff --git a/tests/auto/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/qanimationgroup/tst_qanimationgroup.cpp index ff5c3b4..a7d616a 100644 --- a/tests/auto/qanimationgroup/tst_qanimationgroup.cpp +++ b/tests/auto/qanimationgroup/tst_qanimationgroup.cpp @@ -207,7 +207,7 @@ void tst_QAnimationGroup::setCurrentTime() QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value"); QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value"); QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value"); - a2_s_o1->setIterationCount(3); + a2_s_o1->setLoopCount(3); sequence->addAnimation(a1_s_o1); sequence->addAnimation(a2_s_o1); sequence->addAnimation(a3_s_o1); @@ -224,7 +224,7 @@ void tst_QAnimationGroup::setCurrentTime() QVariantAnimation *a1_p_o1 = new QPropertyAnimation(&p_o1, "value"); QVariantAnimation *a1_p_o2 = new QPropertyAnimation(&p_o2, "value"); QVariantAnimation *a1_p_o3 = new QPropertyAnimation(&p_o3, "value"); - a1_p_o2->setIterationCount(3); + a1_p_o2->setLoopCount(3); parallel->addAnimation(a1_p_o1); parallel->addAnimation(a1_p_o2); parallel->addAnimation(a1_p_o3); @@ -233,7 +233,7 @@ void tst_QAnimationGroup::setCurrentTime() QCOMPARE(notTimeDriven->totalDuration(), -1); QVariantAnimation *loopsForever = new QPropertyAnimation(&t_o2, "value"); - loopsForever->setIterationCount(-1); + loopsForever->setLoopCount(-1); QCOMPARE(loopsForever->totalDuration(), -1); QParallelAnimationGroup group; @@ -281,11 +281,11 @@ void tst_QAnimationGroup::setCurrentTime() QCOMPARE(a1_s_o3->currentTime(), 0); QCOMPARE(a1_p_o1->currentTime(), 250); QCOMPARE(a1_p_o2->currentTime(), 0); - QCOMPARE(a1_p_o2->currentIteration(), 1); + QCOMPARE(a1_p_o2->currentLoop(), 1); QCOMPARE(a1_p_o3->currentTime(), 250); QCOMPARE(notTimeDriven->currentTime(), 250); QCOMPARE(loopsForever->currentTime(), 0); - QCOMPARE(loopsForever->currentIteration(), 1); + QCOMPARE(loopsForever->currentLoop(), 1); QCOMPARE(sequence->currentAnimation(), a2_s_o1); // Current time = 251 @@ -294,14 +294,14 @@ void tst_QAnimationGroup::setCurrentTime() QCOMPARE(sequence->currentTime(), 251); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 1); - QCOMPARE(a2_s_o1->currentIteration(), 0); + QCOMPARE(a2_s_o1->currentLoop(), 0); QCOMPARE(a3_s_o1->currentTime(), 0); QCOMPARE(sequence2->currentTime(), 251); QCOMPARE(a1_s_o2->currentTime(), 250); QCOMPARE(a1_s_o3->currentTime(), 1); QCOMPARE(a1_p_o1->currentTime(), 250); QCOMPARE(a1_p_o2->currentTime(), 1); - QCOMPARE(a1_p_o2->currentIteration(), 1); + QCOMPARE(a1_p_o2->currentLoop(), 1); QCOMPARE(a1_p_o3->currentTime(), 250); QCOMPARE(notTimeDriven->currentTime(), 251); QCOMPARE(loopsForever->currentTime(), 1); diff --git a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index c7f33b7..f2ab57a 100644 --- a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -71,8 +71,8 @@ private slots: void startGroupWithRunningChild(); void zeroDurationAnimation(); void stopUncontrolledAnimations(); - void iterationCount_data(); - void iterationCount(); + void loopCount_data(); + void loopCount(); void autoAdd(); }; @@ -194,7 +194,7 @@ void tst_QParallelAnimationGroup::setCurrentTime() QVariantAnimation *a1_p_o1 = new QPropertyAnimation(&p_o1, "value"); QVariantAnimation *a1_p_o2 = new QPropertyAnimation(&p_o2, "value"); QVariantAnimation *a1_p_o3 = new QPropertyAnimation(&p_o3, "value"); - a1_p_o2->setIterationCount(3); + a1_p_o2->setLoopCount(3); parallel->addAnimation(a1_p_o1); parallel->addAnimation(a1_p_o2); parallel->addAnimation(a1_p_o3); @@ -203,7 +203,7 @@ void tst_QParallelAnimationGroup::setCurrentTime() QCOMPARE(notTimeDriven->totalDuration(), -1); QVariantAnimation *loopsForever = new QPropertyAnimation(&t_o2, "value"); - loopsForever->setIterationCount(-1); + loopsForever->setLoopCount(-1); QCOMPARE(loopsForever->totalDuration(), -1); QParallelAnimationGroup group; @@ -233,18 +233,18 @@ void tst_QParallelAnimationGroup::setCurrentTime() QCOMPARE(group.currentTime(), 250); QCOMPARE(a1_p_o1->currentTime(), 250); QCOMPARE(a1_p_o2->currentTime(), 0); - QCOMPARE(a1_p_o2->currentIteration(), 1); + QCOMPARE(a1_p_o2->currentLoop(), 1); QCOMPARE(a1_p_o3->currentTime(), 250); QCOMPARE(notTimeDriven->currentTime(), 250); QCOMPARE(loopsForever->currentTime(), 0); - QCOMPARE(loopsForever->currentIteration(), 1); + QCOMPARE(loopsForever->currentLoop(), 1); // Current time = 251 group.setCurrentTime(251); QCOMPARE(group.currentTime(), 251); QCOMPARE(a1_p_o1->currentTime(), 250); QCOMPARE(a1_p_o2->currentTime(), 1); - QCOMPARE(a1_p_o2->currentIteration(), 1); + QCOMPARE(a1_p_o2->currentLoop(), 1); QCOMPARE(a1_p_o3->currentTime(), 250); QCOMPARE(notTimeDriven->currentTime(), 251); QCOMPARE(loopsForever->currentTime(), 1); @@ -589,7 +589,7 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation() group.stop(); - group.setIterationCount(4); + group.setLoopCount(4); stateChangedSpy1.clear(); stateChangedSpy2.clear(); @@ -625,7 +625,7 @@ void tst_QParallelAnimationGroup::stopUncontrolledAnimations() loopsForever.setStartValue(0); loopsForever.setEndValue(100); loopsForever.setDuration(100); - loopsForever.setIterationCount(-1); + loopsForever.setLoopCount(-1); QSignalSpy stateChangedSpy(&anim1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); @@ -670,10 +670,10 @@ struct AnimState { #define Stopped QAbstractAnimation::Stopped Q_DECLARE_METATYPE(AnimState) -void tst_QParallelAnimationGroup::iterationCount_data() +void tst_QParallelAnimationGroup::loopCount_data() { QTest::addColumn<bool>("directionBackward"); - QTest::addColumn<int>("setIterationCount"); + QTest::addColumn<int>("setLoopCount"); QTest::addColumn<int>("initialGroupTime"); QTest::addColumn<int>("currentGroupTime"); QTest::addColumn<AnimState>("expected1"); @@ -742,10 +742,10 @@ void tst_QParallelAnimationGroup::iterationCount_data() } -void tst_QParallelAnimationGroup::iterationCount() +void tst_QParallelAnimationGroup::loopCount() { QFETCH(bool, directionBackward); - QFETCH(int, setIterationCount); + QFETCH(int, setLoopCount); QFETCH(int, initialGroupTime); QFETCH(int, currentGroupTime); QFETCH(AnimState, expected1); @@ -763,7 +763,7 @@ void tst_QParallelAnimationGroup::iterationCount() anim2.setStartValue(0); anim2.setEndValue(100); anim2.setDuration(60); //total 120 - anim2.setIterationCount(2); + anim2.setLoopCount(2); TestAnimation anim3; anim3.setStartValue(0); @@ -774,7 +774,7 @@ void tst_QParallelAnimationGroup::iterationCount() group.addAnimation(&anim2); group.addAnimation(&anim3); - group.setIterationCount(setIterationCount); + group.setLoopCount(setLoopCount); if (initialGroupTime >= 0) group.setCurrentTime(initialGroupTime); if (directionBackward) diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index f61df49..2ab0605 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -144,7 +144,7 @@ void tst_QPropertyAnimation::construction() void tst_QPropertyAnimation::setCurrentTime_data() { QTest::addColumn<int>("duration"); - QTest::addColumn<int>("iterationCount"); + QTest::addColumn<int>("loopCount"); QTest::addColumn<int>("currentTime"); QTest::addColumn<int>("testCurrentTime"); QTest::addColumn<int>("testCurrentLoop"); @@ -177,7 +177,7 @@ void tst_QPropertyAnimation::setCurrentTime_data() void tst_QPropertyAnimation::setCurrentTime() { QFETCH(int, duration); - QFETCH(int, iterationCount); + QFETCH(int, loopCount); QFETCH(int, currentTime); QFETCH(int, testCurrentTime); QFETCH(int, testCurrentLoop); @@ -186,11 +186,11 @@ void tst_QPropertyAnimation::setCurrentTime() if (duration < 0) QTest::ignoreMessage(QtWarningMsg, "QVariantAnimation::setDuration: cannot set a negative duration"); animation.setDuration(duration); - animation.setIterationCount(iterationCount); + animation.setLoopCount(loopCount); animation.setCurrentTime(currentTime); QCOMPARE(animation.currentTime(), testCurrentTime); - QCOMPARE(animation.currentIteration(), testCurrentLoop); + QCOMPARE(animation.currentLoop(), testCurrentLoop); } void tst_QPropertyAnimation::statesAndSignals_data() @@ -208,7 +208,7 @@ void tst_QPropertyAnimation::statesAndSignals() QSignalSpy finishedSpy(anim, SIGNAL(finished())); QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); - QSignalSpy currentLoopSpy(anim, SIGNAL(currentIterationChanged(int))); + QSignalSpy currentLoopSpy(anim, SIGNAL(currentLoopChanged(int))); anim->setCurrentTime(1); anim->setCurrentTime(100); @@ -217,23 +217,23 @@ void tst_QPropertyAnimation::statesAndSignals() QCOMPARE(currentLoopSpy.count(), 0); QCOMPARE(anim->state(), QAnimationGroup::Stopped); - anim->setIterationCount(3); + anim->setLoopCount(3); anim->setCurrentTime(101); if (uncontrolled) QSKIP("Uncontrolled animations don't handle looping", SkipSingle); QCOMPARE(currentLoopSpy.count(), 1); - QCOMPARE(anim->currentIteration(), 1); + QCOMPARE(anim->currentLoop(), 1); anim->setCurrentTime(0); QCOMPARE(currentLoopSpy.count(), 2); - QCOMPARE(anim->currentIteration(), 0); + QCOMPARE(anim->currentLoop(), 0); anim->start(); QCOMPARE(anim->state(), QAnimationGroup::Running); QCOMPARE(runningSpy.count(), 1); //anim must have started - QCOMPARE(anim->currentIteration(), 0); + QCOMPARE(anim->currentLoop(), 0); runningSpy.clear(); anim->stop(); @@ -241,7 +241,7 @@ void tst_QPropertyAnimation::statesAndSignals() QCOMPARE(runningSpy.count(), 1); //anim must have stopped QCOMPARE(finishedSpy.count(), 0); QCOMPARE(anim->currentTime(), 0); - QCOMPARE(anim->currentIteration(), 0); + QCOMPARE(anim->currentLoop(), 0); QCOMPARE(currentLoopSpy.count(), 2); runningSpy.clear(); @@ -252,24 +252,24 @@ void tst_QPropertyAnimation::statesAndSignals() runningSpy.clear(); QCOMPARE(finishedSpy.count(), 1); QCOMPARE(anim->currentTime(), 100); - QCOMPARE(anim->currentIteration(), 2); + QCOMPARE(anim->currentLoop(), 2); QCOMPARE(currentLoopSpy.count(), 4); anim->start(); // auto-rewinds QCOMPARE(anim->state(), QAnimationGroup::Running); QCOMPARE(anim->currentTime(), 0); - QCOMPARE(anim->currentIteration(), 0); + QCOMPARE(anim->currentLoop(), 0); QCOMPARE(currentLoopSpy.count(), 5); QCOMPARE(runningSpy.count(), 1); // anim has started QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(anim->currentIteration(), 0); + QCOMPARE(anim->currentLoop(), 0); runningSpy.clear(); QTest::qWait(1000); QCOMPARE(currentLoopSpy.count(), 7); QCOMPARE(anim->state(), QAnimationGroup::Stopped); - QCOMPARE(anim->currentIteration(), 2); + QCOMPARE(anim->currentLoop(), 2); QCOMPARE(runningSpy.count(), 1); // anim has stopped QCOMPARE(finishedSpy.count(), 2); QCOMPARE(anim->currentTime(), 100); @@ -340,7 +340,7 @@ void tst_QPropertyAnimation::deletion2() QCOMPARE(runningSpy.count(), 1); QCOMPARE(finishedSpy.count(), 0); - //we can't call deletaLater directly because the delete would only happen in the next iteration of _this_ event loop + //we can't call deletaLater directly because the delete would only happen in the next loop of _this_ event loop QTimer::singleShot(0, object, SLOT(deleteLater())); QTest::qWait(50); diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index 18b57b2..0631343 100644 --- a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -173,7 +173,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime() QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value"); QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value"); QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value"); - a2_s_o1->setIterationCount(3); + a2_s_o1->setLoopCount(3); sequence->addAnimation(a1_s_o1); sequence->addAnimation(a2_s_o1); sequence->addAnimation(a3_s_o1); @@ -221,7 +221,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime() QCOMPARE(sequence->currentTime(), 251); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 1); - QCOMPARE(a2_s_o1->currentIteration(), 0); + QCOMPARE(a2_s_o1->currentLoop(), 0); QCOMPARE(a3_s_o1->currentTime(), 0); QCOMPARE(sequence2->currentTime(), 0); QCOMPARE(a1_s_o2->currentTime(), 0); @@ -233,7 +233,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime() QCOMPARE(sequence->currentTime(), 750); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 0); - QCOMPARE(a2_s_o1->currentIteration(), 2); + QCOMPARE(a2_s_o1->currentLoop(), 2); QCOMPARE(a3_s_o1->currentTime(), 0); QCOMPARE(sequence2->currentTime(), 0); QCOMPARE(a1_s_o2->currentTime(), 0); @@ -245,7 +245,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime() QCOMPARE(sequence->currentTime(), 1000); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentIteration(), 2); + QCOMPARE(a2_s_o1->currentLoop(), 2); QCOMPARE(a3_s_o1->currentTime(), 0); QCOMPARE(sequence2->currentTime(), 0); QCOMPARE(a1_s_o2->currentTime(), 0); @@ -257,7 +257,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime() QCOMPARE(sequence->currentTime(), 1010); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentIteration(), 2); + QCOMPARE(a2_s_o1->currentLoop(), 2); QCOMPARE(a3_s_o1->currentTime(), 10); QCOMPARE(sequence2->currentTime(), 0); QCOMPARE(a1_s_o2->currentTime(), 0); @@ -269,7 +269,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime() QCOMPARE(sequence->currentTime(), 1250); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentIteration(), 2); + QCOMPARE(a2_s_o1->currentLoop(), 2); QCOMPARE(a3_s_o1->currentTime(), 250); QCOMPARE(sequence2->currentTime(), 0); QCOMPARE(a1_s_o2->currentTime(), 0); @@ -281,7 +281,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime() QCOMPARE(sequence->currentTime(), 1250); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentIteration(), 2); + QCOMPARE(a2_s_o1->currentLoop(), 2); QCOMPARE(a3_s_o1->currentTime(), 250); QCOMPARE(sequence2->currentTime(), 250); QCOMPARE(a1_s_o2->currentTime(), 250); @@ -293,7 +293,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime() QCOMPARE(sequence->currentTime(), 1250); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentIteration(), 2); + QCOMPARE(a2_s_o1->currentLoop(), 2); QCOMPARE(a3_s_o1->currentTime(), 250); QCOMPARE(sequence2->currentTime(), 500); QCOMPARE(a1_s_o2->currentTime(), 250); @@ -305,7 +305,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime() QCOMPARE(sequence->currentTime(), 1250); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentIteration(), 2); + QCOMPARE(a2_s_o1->currentLoop(), 2); QCOMPARE(a3_s_o1->currentTime(), 250); QCOMPARE(sequence2->currentTime(), 500); QCOMPARE(a1_s_o2->currentTime(), 250); @@ -330,7 +330,7 @@ void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation() QCOMPARE(notTimeDriven->totalDuration(), -1); QVariantAnimation *loopsForever = new QPropertyAnimation(&t_o2, "value"); - loopsForever->setIterationCount(-1); + loopsForever->setLoopCount(-1); QCOMPARE(loopsForever->totalDuration(), -1); QSequentialAnimationGroup group; @@ -436,7 +436,7 @@ void tst_QSequentialAnimationGroup::seekingForwards() QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value"); QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value"); QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value"); - a2_s_o1->setIterationCount(3); + a2_s_o1->setLoopCount(3); sequence->addAnimation(a1_s_o1); sequence->addAnimation(a2_s_o1); sequence->addAnimation(a3_s_o1); @@ -476,7 +476,7 @@ void tst_QSequentialAnimationGroup::seekingForwards() QCOMPARE(sequence->currentTime(), 1250); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentIteration(), 2); + QCOMPARE(a2_s_o1->currentLoop(), 2); QCOMPARE(a3_s_o1->currentTime(), 250); QCOMPARE(sequence2->currentTime(), 250); QCOMPARE(a1_s_o2->currentTime(), 250); @@ -498,7 +498,7 @@ void tst_QSequentialAnimationGroup::seekingForwards() QCOMPARE(sequence->currentTime(), 1250); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentIteration(), 2); + QCOMPARE(a2_s_o1->currentLoop(), 2); QCOMPARE(a3_s_o1->currentTime(), 250); QCOMPARE(sequence2->currentTime(), 500); QCOMPARE(a1_s_o2->currentTime(), 250); @@ -516,7 +516,7 @@ void tst_QSequentialAnimationGroup::seekingBackwards() QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value"); QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value"); QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value"); - a2_s_o1->setIterationCount(3); + a2_s_o1->setLoopCount(3); sequence->addAnimation(a1_s_o1); sequence->addAnimation(a2_s_o1); sequence->addAnimation(a3_s_o1); @@ -540,7 +540,7 @@ void tst_QSequentialAnimationGroup::seekingBackwards() QCOMPARE(sequence->currentTime(), 1250); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentIteration(), 2); + QCOMPARE(a2_s_o1->currentLoop(), 2); QCOMPARE(a3_s_o1->currentTime(), 250); QCOMPARE(sequence2->currentTime(), 350); QCOMPARE(a1_s_o2->currentTime(), 250); @@ -564,7 +564,7 @@ void tst_QSequentialAnimationGroup::seekingBackwards() QCOMPARE(a2_s_o1->currentTime(), 0); QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children," "hence they don't reset from their current animation", Continue); - QCOMPARE(a2_s_o1->currentIteration(), 0); + QCOMPARE(a2_s_o1->currentLoop(), 0); QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children," "hence they don't reset from their current animation", Continue); QCOMPARE(a3_s_o1->currentTime(), 0); @@ -585,7 +585,7 @@ void tst_QSequentialAnimationGroup::seekingBackwards() QCOMPARE(sequence->currentTime(), 1250); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentIteration(), 2); + QCOMPARE(a2_s_o1->currentLoop(), 2); QCOMPARE(a3_s_o1->currentTime(), 250); QCOMPARE(sequence2->currentTime(), 500); QCOMPARE(a1_s_o2->currentTime(), 250); @@ -656,11 +656,11 @@ void tst_QSequentialAnimationGroup::pauseAndResume() QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value"); QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value"); QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value"); - a2_s_o1->setIterationCount(2); + a2_s_o1->setLoopCount(2); sequence->addAnimation(a1_s_o1); sequence->addAnimation(a2_s_o1); sequence->addAnimation(a3_s_o1); - sequence->setIterationCount(2); + sequence->setLoopCount(2); QSignalSpy a1StateChangedSpy(a1_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); QSignalSpy seqStateChangedSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); @@ -675,11 +675,11 @@ void tst_QSequentialAnimationGroup::pauseAndResume() group.setCurrentTime(1751); QCOMPARE(group.currentTime(), 1751); QCOMPARE(sequence->currentTime(), 751); - QCOMPARE(sequence->currentIteration(), 1); + QCOMPARE(sequence->currentLoop(), 1); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentIteration(), 1); - QCOMPARE(a3_s_o1->currentIteration(), 0); + QCOMPARE(a2_s_o1->currentLoop(), 1); + QCOMPARE(a3_s_o1->currentLoop(), 0); QCOMPARE(a3_s_o1->currentTime(), 1); QCOMPARE(group.state(), QAnimationGroup::Paused); @@ -723,11 +723,11 @@ void tst_QSequentialAnimationGroup::pauseAndResume() QVERIFY(group.currentTime() >= 1751); QVERIFY(sequence->currentTime() >= 751); - QCOMPARE(sequence->currentIteration(), 1); + QCOMPARE(sequence->currentLoop(), 1); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentIteration(), 1); - QCOMPARE(a3_s_o1->currentIteration(), 0); + QCOMPARE(a2_s_o1->currentLoop(), 1); + QCOMPARE(a3_s_o1->currentLoop(), 0); QVERIFY(a3_s_o1->currentTime() >= 1); QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running @@ -744,11 +744,11 @@ void tst_QSequentialAnimationGroup::pauseAndResume() QVERIFY(group.currentTime() >= 1751); QVERIFY(sequence->currentTime() >= 751); - QCOMPARE(sequence->currentIteration(), 1); + QCOMPARE(sequence->currentLoop(), 1); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentIteration(), 1); - QCOMPARE(a3_s_o1->currentIteration(), 0); + QCOMPARE(a2_s_o1->currentLoop(), 1); + QCOMPARE(a3_s_o1->currentLoop(), 0); QVERIFY(a3_s_o1->currentTime() >= 1); QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused @@ -780,11 +780,11 @@ void tst_QSequentialAnimationGroup::restart() animsStateChanged[i] = new QSignalSpy(anims[i], SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); } - anims[1]->setIterationCount(2); + anims[1]->setLoopCount(2); sequence->addAnimation(anims[0]); sequence->addAnimation(anims[1]); sequence->addAnimation(anims[2]); - sequence->setIterationCount(2); + sequence->setLoopCount(2); QSequentialAnimationGroup group; group.addAnimation(sequence); @@ -845,17 +845,17 @@ void tst_QSequentialAnimationGroup::looping() QSignalSpy a3Spy(a3_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); QSignalSpy seqSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); - a2_s_o1->setIterationCount(2); + a2_s_o1->setLoopCount(2); sequence->addAnimation(a1_s_o1); sequence->addAnimation(a2_s_o1); sequence->addAnimation(a3_s_o1); - sequence->setIterationCount(2); + sequence->setLoopCount(2); QSequentialAnimationGroup group; QSignalSpy groupSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); group.addAnimation(sequence); - group.setIterationCount(2); + group.setLoopCount(2); group.start(); group.pause(); @@ -864,12 +864,12 @@ void tst_QSequentialAnimationGroup::looping() group.setCurrentTime(1750); QCOMPARE(group.currentTime(), 1750); QCOMPARE(sequence->currentTime(), 750); - QCOMPARE(sequence->currentIteration(), 1); + QCOMPARE(sequence->currentLoop(), 1); QCOMPARE(a1_s_o1->currentTime(), 250); QCOMPARE(a2_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentIteration(), 1); + QCOMPARE(a2_s_o1->currentLoop(), 1); // this animation is at the beginning because it is the current one inside sequence - QCOMPARE(a3_s_o1->currentIteration(), 0); + QCOMPARE(a3_s_o1->currentLoop(), 0); QCOMPARE(a3_s_o1->currentTime(), 0); QCOMPARE(sequence->currentAnimation(), a3_s_o1); @@ -898,14 +898,14 @@ void tst_QSequentialAnimationGroup::looping() // Looping, current time = duration + 1 group.setCurrentTime(group.duration() + 1); QCOMPARE(group.currentTime(), 1); - QCOMPARE(group.currentIteration(), 1); + QCOMPARE(group.currentLoop(), 1); QCOMPARE(sequence->currentTime(), 1); - QCOMPARE(sequence->currentIteration(), 0); + QCOMPARE(sequence->currentLoop(), 0); QCOMPARE(a1_s_o1->currentTime(), 1); QCOMPARE(a2_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentIteration(), 1); + QCOMPARE(a2_s_o1->currentLoop(), 1); // this animation is at the end because it was run on the previous loop - QCOMPARE(a3_s_o1->currentIteration(), 0); + QCOMPARE(a3_s_o1->currentLoop(), 0); QCOMPARE(a3_s_o1->currentTime(), 250); QCOMPARE(group.state(), QAnimationGroup::Paused); @@ -1367,7 +1367,7 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation() group.addAnimation(anim1); group.addAnimation(anim2); group.addAnimation(anim3); - group.setIterationCount(2); + group.setLoopCount(2); group.start(); QCOMPARE(stateChangedSpy.count(), 2); @@ -1401,7 +1401,7 @@ void tst_QSequentialAnimationGroup::stopUncontrolledAnimations() loopsForever.setStartValue(0); loopsForever.setEndValue(100); loopsForever.setDuration(100); - loopsForever.setIterationCount(-1); + loopsForever.setLoopCount(-1); group.addAnimation(¬TimeDriven); group.addAnimation(&loopsForever); @@ -1592,11 +1592,11 @@ void tst_QSequentialAnimationGroup::currentAnimationWithZeroDuration() void tst_QSequentialAnimationGroup::insertAnimation() { QSequentialAnimationGroup group; - group.setIterationCount(2); + group.setLoopCount(2); QPropertyAnimation *anim = new QPropertyAnimation(&group); QCOMPARE(group.duration(), anim->duration()); group.setCurrentTime(300); - QCOMPARE(group.currentIteration(), 1); + QCOMPARE(group.currentLoop(), 1); //this will crash if the sequential group calls duration on the created animation new QPropertyAnimation(&group); |