API REVIEW: AnimId -> int

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=800804
This commit is contained in:
Davide Bettio 2008-04-24 21:26:36 +00:00
parent eba58a193d
commit 175cf065e7
7 changed files with 31 additions and 33 deletions

View File

@ -87,7 +87,7 @@ class AppletHandle : public QObject, public QGraphicsItem
Applet *m_applet;
qreal m_opacity;
FadeType m_anim;
Phase::AnimId m_animId;
int m_animId;
qreal m_angle;
qreal m_tempAngle;
qreal m_scaleWidth;

View File

@ -89,7 +89,7 @@ public:
KIcon icon;
EmptyGraphicsItem *toolBacker;
QTime stopwatch;
Plasma::Phase::AnimId animId;
int animId;
qreal animFrame;
};

View File

@ -88,7 +88,7 @@ public:
KIcon icon;
EmptyGraphicsItem *toolBacker;
QTime stopwatch;
Plasma::Phase::AnimId animId;
int animId;
qreal animFrame;
};

View File

@ -82,7 +82,7 @@ struct CustomAnimationState
int currentFrame;
int interval;
int currentInterval;
Phase::AnimId id;
int id;
QObject* receiver;
char* slot;
};
@ -104,7 +104,7 @@ class Phase::Private
qDeleteAll(animatedElements);
qDeleteAll(movingItems);
QMutableMapIterator<AnimId, CustomAnimationState*> it(customAnims);
QMutableMapIterator<int, CustomAnimationState*> it(customAnims);
while (it.hasNext()) {
delete it.value()->slot;
delete it.value();
@ -171,8 +171,8 @@ class Phase::Private
// and really making the code fun ;)
QMap<QGraphicsItem*, AnimationState*> animatedItems;
QMap<QGraphicsItem*, MovementState*> movingItems;
QMap<AnimId, ElementAnimationState*> animatedElements;
QMap<AnimId, CustomAnimationState*> customAnims;
QMap<int, ElementAnimationState*> animatedElements;
QMap<int, CustomAnimationState*> customAnims;
};
class PhaseSingleton
@ -230,7 +230,7 @@ void Phase::movingItemDestroyed(QObject* o)
void Phase::animatedElementDestroyed(QObject* o)
{
QMutableMapIterator<AnimId, ElementAnimationState*> it(d->animatedElements);
QMutableMapIterator<int, ElementAnimationState*> it(d->animatedElements);
while (it.hasNext()) {
it.next();
if (it.value()->qobj == o) {
@ -242,7 +242,7 @@ void Phase::animatedElementDestroyed(QObject* o)
void Phase::customAnimReceiverDestroyed(QObject* o)
{
QMutableMapIterator<AnimId, CustomAnimationState*> it(d->customAnims);
QMutableMapIterator<int, CustomAnimationState*> it(d->customAnims);
while (it.hasNext()) {
if (it.next().value()->receiver == o) {
delete it.value()->slot;
@ -342,7 +342,7 @@ void Phase::moveItem(QGraphicsItem* item, Movement movement, const QPoint &desti
}
}
Phase::AnimId Phase::customAnimation(int frames, int duration, Phase::CurveShape curve,
int Phase::customAnimation(int frames, int duration, Phase::CurveShape curve,
QObject* receiver, const char* slot)
{
if (frames < 1 || duration < 1 || !receiver || !slot) {
@ -378,9 +378,9 @@ Phase::AnimId Phase::customAnimation(int frames, int duration, Phase::CurveShape
return state->id;
}
void Phase::stopCustomAnimation(AnimId id)
void Phase::stopCustomAnimation(int id)
{
QMap<AnimId, CustomAnimationState*>::iterator it = d->customAnims.find(id);
QMap<int, CustomAnimationState*>::iterator it = d->customAnims.find(id);
if (it != d->customAnims.end()) {
delete [] it.value()->slot;
delete it.value();
@ -389,7 +389,7 @@ void Phase::stopCustomAnimation(AnimId id)
//kDebug() << "stopCustomAnimation(AnimId " << id << ") done";
}
Phase::AnimId Phase::animateElement(QGraphicsItem *item, ElementAnimation animation)
int Phase::animateElement(QGraphicsItem *item, ElementAnimation animation)
{
//kDebug() << "startElementAnimation(AnimId " << animation << ")";
ElementAnimationState *state = new ElementAnimationState;
@ -430,9 +430,9 @@ Phase::AnimId Phase::animateElement(QGraphicsItem *item, ElementAnimation animat
return state->id;
}
void Phase::stopElementAnimation(AnimId id)
void Phase::stopElementAnimation(int id)
{
QMap<AnimId, ElementAnimationState*>::iterator it = d->animatedElements.find(id);
QMap<int, ElementAnimationState*>::iterator it = d->animatedElements.find(id);
if (it != d->animatedElements.end()) {
delete it.value();
d->animatedElements.erase(it);
@ -440,9 +440,9 @@ void Phase::stopElementAnimation(AnimId id)
//kDebug() << "stopElementAnimation(AnimId " << id << ") done";
}
void Phase::setInitialPixmap(AnimId id, const QPixmap &pixmap)
void Phase::setInitialPixmap(int id, const QPixmap &pixmap)
{
QMap<AnimId, ElementAnimationState*>::iterator it = d->animatedElements.find(id);
QMap<int, ElementAnimationState*>::iterator it = d->animatedElements.find(id);
if (it == d->animatedElements.end()) {
kDebug() << "Phase::setInitialPixmap(" << id << ") found no entry for it!";
@ -452,9 +452,9 @@ void Phase::setInitialPixmap(AnimId id, const QPixmap &pixmap)
it.value()->pixmap = pixmap;
}
QPixmap Phase::currentPixmap(AnimId id)
QPixmap Phase::currentPixmap(int id)
{
QMap<AnimId, ElementAnimationState*>::const_iterator it = d->animatedElements.find(id);
QMap<int, ElementAnimationState*>::const_iterator it = d->animatedElements.find(id);
if (it == d->animatedElements.constEnd()) {
//kDebug() << "Phase::currentPixmap(" << id << ") found no entry for it!";

18
phase.h
View File

@ -72,8 +72,6 @@ public:
FastSlideOutMovement
};
typedef int AnimId;
/**
* Singleton accessor
**/
@ -99,7 +97,7 @@ public:
*
* @return an id that can be used to identify this animation.
*/
Q_INVOKABLE AnimId customAnimation(int frames, int duration, Phase::CurveShape curve,
Q_INVOKABLE int customAnimation(int frames, int duration, Phase::CurveShape curve,
QObject* receiver, const char* method);
/**
@ -109,12 +107,12 @@ public:
*
* @arg id the id of the animation as returned by customAnimation
*/
Q_INVOKABLE void stopCustomAnimation(AnimId id);
Q_INVOKABLE void stopCustomAnimation(int id);
Q_INVOKABLE AnimId animateElement(QGraphicsItem *obj, ElementAnimation);
Q_INVOKABLE void stopElementAnimation(AnimId id);
Q_INVOKABLE void setInitialPixmap(AnimId id, const QPixmap &pixmap);
Q_INVOKABLE QPixmap currentPixmap(AnimId id);
Q_INVOKABLE int animateElement(QGraphicsItem *obj, ElementAnimation);
Q_INVOKABLE void stopElementAnimation(int id);
Q_INVOKABLE void setInitialPixmap(int id, const QPixmap &pixmap);
Q_INVOKABLE QPixmap currentPixmap(int id);
/**
* Can be used to query if there are other animations happening. This way
@ -127,8 +125,8 @@ public:
Q_SIGNALS:
void animationFinished(QGraphicsItem *item, Plasma::Phase::Animation anim);
void movementFinished(QGraphicsItem *item);
void elementAnimationFinished(Plasma::Phase::AnimId id);
void customAnimationFinished(Plasma::Phase::AnimId id);
void elementAnimationFinished(int id);
void customAnimationFinished(int id);
protected:
void timerEvent(QTimerEvent *event);

View File

@ -230,7 +230,7 @@ bool IconAction::event(QEvent::Type type, const QPointF &pos)
return false;
}
Phase::AnimId IconAction::animationId() const
int IconAction::animationId() const
{
return m_animationId;
}

View File

@ -51,7 +51,7 @@ public:
void hide();
bool isVisible() const;
Phase::AnimId animationId() const;
int animationId() const;
QAction* action() const;
void paint(QPainter *painter) const;
@ -79,7 +79,7 @@ private:
bool m_selected;
bool m_visible;
Phase::AnimId m_animationId;
int m_animationId;
};
@ -171,7 +171,7 @@ public:
QColor textColor;
QColor shadowColor;
bool m_fadeIn;
Phase::AnimId m_hoverAnimId;
int m_hoverAnimId;
qreal m_hoverAlpha;
QSizeF iconSize;
QIcon icon;