41#include <QtCore/qdebug.h>
56 return (currentLoop == loopCount - 1
93 ret.timeOffset += duration;
99 ret.timeOffset -= duration;
109 if (currentAnimationIndex == 0)
116 if (currentAnimationIndex ==
index)
147 for (
int i = currentAnimationIndex;
i < newAnimationIndex.
index; ++
i) {
165 for (
int i = currentAnimationIndex;
i >= 0 ; --
i) {
179 for (
int i = currentAnimationIndex;
i > newAnimationIndex.
index; --
i) {
247 if (index < 0 || index >
d->animations.size()) {
248 qWarning(
"QSequentialAnimationGroup::insertPause: index is out of bounds");
265 return d->currentAnimation;
270 return &d_func()->currentAnimation;
282 const int currentDuration = (*it)->totalDuration();
283 if (currentDuration == -1)
286 ret += currentDuration;
298 if (!
d->currentAnimation)
304 while (newAnimationIndex.
index <
d->actualDuration.size())
305 d->actualDuration.removeLast();
308 if (
d->lastLoop <
d->currentLoop
309 || (
d->lastLoop ==
d->currentLoop &&
d->currentAnimationIndex < newAnimationIndex.
index)) {
311 d->advanceForwards(newAnimationIndex);
312 }
else if (
d->lastLoop >
d->currentLoop
313 || (
d->lastLoop ==
d->currentLoop &&
d->currentAnimationIndex > newAnimationIndex.
index)) {
315 d->rewindForwards(newAnimationIndex);
318 d->setCurrentAnimation(newAnimationIndex.
index);
322 if (
d->currentAnimation) {
323 d->currentAnimation->setCurrentTime(newCurrentTime);
337 d->lastLoop =
d->currentLoop;
349 if (!
d->currentAnimation)
354 d->currentAnimation->stop();
357 if (oldState ==
d->currentAnimation->state()
359 d->currentAnimation->pause();
365 if (oldState ==
d->currentAnimation->state()
367 d->currentAnimation->start();
403 currentAnimationIndex = -1;
404 currentAnimation =
nullptr;
414 if (currentAnimation)
415 currentAnimation->stop();
417 currentAnimationIndex =
index;
420 emit q->currentAnimationChanged(currentAnimation);
430 currentAnimation->stop();
433 currentAnimation->setDirection(
direction);
436 if (currentAnimation->totalDuration() == -1)
439 currentAnimation->start();
441 currentAnimation->pause();
447 Q_ASSERT(qobject_cast<QAbstractAnimation *>(
q->sender()) == currentAnimation);
452 actualDuration[currentAnimationIndex] = currentAnimation->currentTime();
477 if (currentAnimation ==
nullptr) {
482 if (currentAnimationIndex ==
index
483 && currentAnimation->currentTime() == 0 && currentAnimation->currentLoop() == 0) {
491 if (
index < currentAnimationIndex || currentLoop != 0) {
492 qWarning(
"QSequentialGroup::insertAnimation only supports to add animations after the current one.");
508 if (!currentAnimation)
515 if (currentIndex == -1) {
526 }
else if (currentAnimationIndex >
index) {
527 currentAnimationIndex--;
537 if (currentIndex != -1) {
544 totalCurrentTime =
currentTime + loopCount *
q->duration();
549#include "moc_qsequentialanimationgroup.cpp"
static QAbstractAnimationPrivate * get(QAbstractAnimation *q)
State state
state of the animation.
Direction direction
the direction of the animation when it is in \l Running state.
State
This enum describes the state of the animation.
void stop()
Stops the animation.
int totalDuration() const
Returns the total and effective duration of the animation, including the loop count.
int currentTime
the current time and progress of the animation
void setCurrentTime(int msecs)
virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
This virtual function is called by QAbstractAnimation when the state of the animation is changed from...
Direction
This enum describes the direction of the animation when in \l Running state.
void pause()
Pauses the animation.
QList< QAbstractAnimation * > animations
void disconnectUncontrolledAnimation(QAbstractAnimation *anim)
void connectUncontrolledAnimation(QAbstractAnimation *anim)
virtual void animationRemoved(qsizetype, QAbstractAnimation *)
void addAnimation(QAbstractAnimation *animation)
Adds animation to this group.
void insertAnimation(int index, QAbstractAnimation *animation)
Inserts animation into this animation group at index.
bool event(QEvent *event) override
\reimp
qsizetype size() const noexcept
bool isEmpty() const noexcept
void removeAt(qsizetype i)
const_reference at(qsizetype i) const noexcept
void append(parameter_type t)
void activateCurrentAnimation(bool intermediate=false)
AnimationIndex indexForCurrentTime() const
int animationActualTotalDuration(int index) const
void advanceForwards(const AnimationIndex &newAnimationIndex)
void animationInsertedAt(qsizetype index) override
QList< int > actualDuration
void rewindForwards(const AnimationIndex &newAnimationIndex)
void animationRemoved(qsizetype index, QAbstractAnimation *anim) override
void setCurrentAnimation(int index, bool intermediate=false)
void _q_uncontrolledAnimationFinished()
QPauseAnimation * addPause(int msecs)
Adds a pause of msecs to this animation group.
QAbstractAnimation * currentAnimation
the animation in the current time.
void updateDirection(QAbstractAnimation::Direction direction) override
\reimp
void updateCurrentTime(int) override
\reimp
bool event(QEvent *event) override
\reimp
int duration() const override
\reimp
QPauseAnimation * insertPause(int index, int msecs)
Inserts a pause of msecs milliseconds at index in this animation group.
~QSequentialAnimationGroup()
Destroys the animation group.
QSequentialAnimationGroup(QObject *parent=nullptr)
Constructs a QSequentialAnimationGroup.
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) override
\reimp
QBindable< QAbstractAnimation * > bindableCurrentAnimation() const
QSet< QString >::iterator it
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
QList< QAbstractAnimation * >::ConstIterator AnimationListConstIt
constexpr const T & qMin(const T &a, const T &b)
GLdouble GLdouble GLdouble GLdouble q
QT_BEGIN_NAMESPACE typedef QList< QAbstractAnimation * >::ConstIterator AnimationListConstIt
static double currentTime()
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent