* consolidate the start() methods

* make some changes needed for bindings

svn path=/trunk/KDE/kdelibs/; revision=1038369
This commit is contained in:
Aaron J. Seigo 2009-10-21 07:51:11 +00:00
parent 172e467929
commit 8814c2b2c0
6 changed files with 43 additions and 55 deletions

View File

@ -119,7 +119,13 @@ void AbstractAnimation::setAngle(const qreal &angle)
d->angle = angle;
}
void AbstractAnimation::start()
{
QAbstractAnimation* anim = toQAbstractAnimation(parent());
if (anim) {
anim->start(QAbstractAnimation::DeleteWhenStopped);
}
}
} //namespace Plasma

View File

@ -63,15 +63,15 @@ public:
/* FIXME: find a better place and name for it. */
enum Reference{
Center,
Up,
Down,
Left,
Right
Center,
Up,
Down,
Left,
Right
};
AbstractAnimation(QObject *parent = 0);
explicit AbstractAnimation(QObject *parent = 0);
virtual ~AbstractAnimation();
/**
@ -175,7 +175,7 @@ public slots:
/**
* Start the animation.
*/
virtual void start() = 0;
virtual void start();
protected:

View File

@ -56,14 +56,6 @@ void Animation::setDuration(int duration)
d->duration = duration;
}
void Animation::start()
{
QAbstractAnimation* anim = toQAbstractAnimation(parent());
if (anim) {
anim->start(QAbstractAnimation::DeleteWhenStopped);
}
}
QAbstractAnimation* Animation::toQAbstractAnimation(QObject* parent)
{
//check if .setObject() was done

View File

@ -48,14 +48,9 @@ class PLASMA_EXPORT Animation : public AbstractAnimation
public:
Animation(QObject* parent = 0);
explicit Animation(QObject* parent = 0);
virtual ~Animation() = 0;
/**
* Start the animation.
*/
virtual void start();
/**
* Take the animation object and turn it into a QPropertyAnimation. Returns
* NULL on error. This function just does some boilerplate checking and then

View File

@ -68,6 +68,11 @@ int AnimationGroup::add(AbstractAnimation* elem)
return d->anims.count();
}
void AnimationGroup::remove(Plasma::AbstractAnimation* elem)
{
d->anims.removeAll(elem);
}
AbstractAnimation* AnimationGroup::at(int id) const
{
return d->anims.value(id);
@ -82,17 +87,6 @@ void AnimationGroup::remove(int id)
d->anims.removeAt(id);
}
void AnimationGroup::start()
{
QAbstractAnimation* anim = toQAbstractAnimation(parent());
if (anim){
/* FIXME: why to create and delete all the animations
* every single time it runs?
*/
anim->start(QAbstractAnimation::DeleteWhenStopped);
}
}
QAnimationGroup* AnimationGroup::toQAbstractAnimation(QObject* parent)
{
//if supplied, use parent given in args.

View File

@ -49,7 +49,7 @@ class PLASMA_EXPORT AnimationGroup : public AbstractAnimation
public:
AnimationGroup(QObject* parent = 0);
explicit AnimationGroup(QObject* parent = 0);
virtual ~AnimationGroup();
/**
@ -62,25 +62,6 @@ public:
*/
bool isParallel() const;
/**
* Add an Animation or AnimationGroup to the group
* @arg elem element to add
* @return id of element added
*/
int add(AbstractAnimation* elem);
/**
* Return element with given id
* @return id of element to get
*/
AbstractAnimation* at(int id) const;
/**
* Remove element with given id
* @arg id id of element to remove
*/
void remove(int id);
/**
* Take the animation object and turn it into a QAnimationGroup. More
* specifically, a QSerialAnimation or QParallelAnimation depending on
@ -90,9 +71,29 @@ public:
public Q_SLOTS:
/**
* Start the animation.
* Add an Animation or AnimationGroup to the group
* @arg elem element to add
* @return id of element added
*/
virtual void start();
Q_INVOKABLE int add(Plasma::AbstractAnimation* elem);
/**
* Remove an Animation or AnimationGroup from this group
* @arg eleme element to remove
*/
Q_INVOKABLE void remove(Plasma::AbstractAnimation* elem);
/**
* Return element with given id
* @return id of element to get
*/
Q_INVOKABLE AbstractAnimation* at(int id) const;
/**
* Remove element with given id
* @arg id id of element to remove
*/
Q_INVOKABLE void remove(int id);
private:
AnimationGroupPrivate * const d;