summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-04-21 09:58:03 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-04-21 09:58:03 (GMT)
commit9fa9221af7ca452d19a0754f38d81299ad749dbc (patch)
treeb1a3b741d386f8a22cc808808c353091549e3c67 /src
parentea8bc5be8cea04da86b8df53cbde22b71f532585 (diff)
parent965a0d60fe28666471e9ffb99a7e97097254a4cc (diff)
downloadQt-9fa9221af7ca452d19a0754f38d81299ad749dbc.zip
Qt-9fa9221af7ca452d19a0754f38d81299ad749dbc.tar.gz
Qt-9fa9221af7ca452d19a0754f38d81299ad749dbc.tar.bz2
Merge branch 'kinetic-animations' into kinetic-statemachine
Diffstat (limited to 'src')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp94
-rw-r--r--src/corelib/animation/qabstractanimation.h12
-rw-r--r--src/corelib/animation/qabstractanimation_p.h8
-rw-r--r--src/corelib/animation/qparallelanimationgroup.cpp24
-rw-r--r--src/corelib/animation/qparallelanimationgroup_p.h4
-rw-r--r--src/corelib/animation/qpropertyanimation.h1
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.cpp28
-rw-r--r--src/corelib/animation/qsequentialanimationgroup_p.h4
-rw-r--r--src/corelib/animation/qvariantanimation.cpp2
-rw-r--r--src/corelib/animation/qvariantanimation.h3
-rw-r--r--src/corelib/animation/qvariantanimation_p.h2
-rw-r--r--src/gui/animation/animation.pri7
-rw-r--r--src/gui/animation/qguivariantanimation.cpp (renamed from src/gui/animation/qitemanimation_p.h)56
-rw-r--r--src/gui/animation/qitemanimation.cpp361
-rw-r--r--src/gui/animation/qitemanimation.h111
15 files changed, 117 insertions, 600 deletions
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