src/corelib/animation/qsequentialanimationgroup.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 30 5dc02b23752f
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
   477     // we ensure the direction is consistent with the group's direction
   477     // we ensure the direction is consistent with the group's direction
   478     currentAnimation->setDirection(direction);
   478     currentAnimation->setDirection(direction);
   479 
   479 
   480     // connects to the finish signal of uncontrolled animations
   480     // connects to the finish signal of uncontrolled animations
   481     if (currentAnimation->totalDuration() == -1)
   481     if (currentAnimation->totalDuration() == -1)
   482         QObject::connect(currentAnimation, SIGNAL(finished()), q, SLOT(_q_uncontrolledAnimationFinished()));
   482         connectUncontrolledAnimation(currentAnimation);
   483 
   483 
   484     currentAnimation->start();
   484     currentAnimation->start();
   485     if (!intermediate && state == QSequentialAnimationGroup::Paused)
   485     if (!intermediate && state == QSequentialAnimationGroup::Paused)
   486         currentAnimation->pause();
   486         currentAnimation->pause();
   487 }
   487 }
   494     // we trust the duration returned by the animation
   494     // we trust the duration returned by the animation
   495     while (actualDuration.size() < (currentAnimationIndex + 1))
   495     while (actualDuration.size() < (currentAnimationIndex + 1))
   496         actualDuration.append(-1);
   496         actualDuration.append(-1);
   497     actualDuration[currentAnimationIndex] = currentAnimation->currentTime();
   497     actualDuration[currentAnimationIndex] = currentAnimation->currentTime();
   498 
   498 
   499     QObject::disconnect(currentAnimation, SIGNAL(finished()), q, SLOT(_q_uncontrolledAnimationFinished()));
   499     disconnectUncontrolledAnimation(currentAnimation);
   500 
   500 
   501     if ((direction == QAbstractAnimation::Forward && currentAnimation == animations.last())
   501     if ((direction == QAbstractAnimation::Forward && currentAnimation == animations.last())
   502         || (direction == QAbstractAnimation::Backward && currentAnimationIndex == 0)) {
   502         || (direction == QAbstractAnimation::Backward && currentAnimationIndex == 0)) {
   503         // we don't handle looping of a group with undefined duration
   503         // we don't handle looping of a group with undefined duration
   504         q->stop();
   504         q->stop();
   541     \internal
   541     \internal
   542     This method is called whenever an animation is removed from
   542     This method is called whenever an animation is removed from
   543     the group at index \a index. The animation is no more listed when this
   543     the group at index \a index. The animation is no more listed when this
   544     method is called.
   544     method is called.
   545 */
   545 */
   546 void QSequentialAnimationGroupPrivate::animationRemovedAt(int index)
   546 void QSequentialAnimationGroupPrivate::animationRemoved(int index, QAbstractAnimation *anim)
   547 {
   547 {
   548     Q_Q(QSequentialAnimationGroup);
   548     Q_Q(QSequentialAnimationGroup);
   549     QAnimationGroupPrivate::animationRemovedAt(index);
   549     QAnimationGroupPrivate::animationRemoved(index, anim);
   550 
   550 
   551     Q_ASSERT(currentAnimation); // currentAnimation should always be set
   551     Q_ASSERT(currentAnimation); // currentAnimation should always be set
   552 
   552 
   553     if (actualDuration.size() > index)
   553     if (actualDuration.size() > index)
   554         actualDuration.removeAt(index);
   554         actualDuration.removeAt(index);
   555 
   555 
   556     const int currentIndex = animations.indexOf(currentAnimation);
   556     const int currentIndex = animations.indexOf(currentAnimation);
   557     if (currentIndex == -1) {
   557     if (currentIndex == -1) {
   558         //we're removing the current animation, let's update it to another one
   558         //we're removing the current animation
       
   559 
       
   560         disconnectUncontrolledAnimation(currentAnimation);
       
   561 
   559         if (index < animations.count())
   562         if (index < animations.count())
   560             setCurrentAnimation(index); //let's try to take the next one
   563             setCurrentAnimation(index); //let's try to take the next one
   561         else if (index > 0)
   564         else if (index > 0)
   562             setCurrentAnimation(index - 1);
   565             setCurrentAnimation(index - 1);
   563         else// case all animations were removed
   566         else// case all animations were removed