MovementDirection and Reference enumerators are now QFlags (using Q_DECLARE_FLAGS), as suggested by aseigo

svn path=/trunk/KDE/kdelibs/; revision=1084090
This commit is contained in:
Bruno de Oliveira Abinader 2010-02-02 13:36:23 +00:00
parent 38bf1d8725
commit d69885df4d
5 changed files with 37 additions and 33 deletions

View File

@ -63,7 +63,7 @@ public:
/**
* Animation movement reference (used by \ref RotationAnimation).
*/
enum Reference {
enum ReferenceFlag {
Center = 0,
Up = 0x1,
Down = 0x2,
@ -71,10 +71,12 @@ public:
Right = 0x8
};
Q_DECLARE_FLAGS(Reference, ReferenceFlag)
/**
* Animation movement direction.
*/
enum MovementDirection {
enum MovementDirectionFlag {
MoveAny = 0,
MoveUp = 0x1,
MoveRight = 0x2,
@ -82,6 +84,8 @@ public:
MoveLeft = 0x8
};
Q_DECLARE_FLAGS(MovementDirection, MovementDirectionFlag)
/**
* Default constructor.
*

View File

@ -42,21 +42,21 @@ RotationStackedAnimation::~RotationStackedAnimation()
delete m_wLayout.data();
}
void RotationStackedAnimation::setMovementDirection(const qint8 &direction)
void RotationStackedAnimation::setMovementDirection(const Animation::MovementDirection &direction)
{
m_animDirection = direction;
QVector3D animDirection(0, 0, 0);
if ((m_animDirection & MoveUp) == MoveUp) {
if (m_animDirection.testFlag(MoveUp)) {
animDirection.setX(1);
} else if ((m_animDirection & MoveDown) == MoveDown) {
} else if (m_animDirection.testFlag(MoveDown)) {
animDirection.setX(-1);
}
if ((m_animDirection & MoveLeft) == MoveLeft) {
if (m_animDirection.testFlag(MoveLeft)) {
animDirection.setY(-1);
} else if ((m_animDirection & MoveRight) == MoveRight) {
} else if (m_animDirection.testFlag(MoveRight)) {
animDirection.setY(1);
}
@ -66,12 +66,12 @@ void RotationStackedAnimation::setMovementDirection(const qint8 &direction)
updateTransformations();
}
qint8 RotationStackedAnimation::movementDirection() const
Animation::MovementDirection RotationStackedAnimation::movementDirection() const
{
return m_animDirection;
}
void RotationStackedAnimation::setReference(const qint8 &reference)
void RotationStackedAnimation::setReference(const Animation::Reference &reference)
{
m_animReference = reference;
@ -84,18 +84,18 @@ void RotationStackedAnimation::setReference(const qint8 &reference)
QVector3D frontTransformOrigin(transformArea.width()/2, transformArea.height()/2, 0);
QVector3D backTransformOrigin(transformArea.width()/2, transformArea.height()/2, 0);
if ((m_animReference & Up) == Up) {
if (m_animReference.testFlag(Up)) {
frontTransformOrigin.setY(0);
backTransformOrigin.setY(0);
} else if ((m_animReference & Down) == Down) {
} else if (m_animReference.testFlag(Down)) {
frontTransformOrigin.setY(transformArea.height());
backTransformOrigin.setY(transformArea.height());
}
if ((m_animReference & Left) == Left) {
if (m_animReference.testFlag(Left)) {
frontTransformOrigin.setX(0);
backTransformOrigin.setX(0);
} else if ((m_animReference & Right) == Right) {
} else if (m_animReference.testFlag(Right)) {
frontTransformOrigin.setX(transformArea.width());
backTransformOrigin.setX(transformArea.width());
}
@ -106,7 +106,7 @@ void RotationStackedAnimation::setReference(const qint8 &reference)
updateTransformations();
}
qint8 RotationStackedAnimation::reference() const
Animation::Reference RotationStackedAnimation::reference() const
{
return m_animReference;
}

View File

@ -44,9 +44,9 @@ namespace Plasma {
class RotationStackedAnimation : public Animation
{
Q_OBJECT
Q_PROPERTY(qint8 movementDirection READ movementDirection WRITE setMovementDirection)
Q_PROPERTY(MovementDirection movementDirection READ movementDirection WRITE setMovementDirection)
Q_PROPERTY(Reference reference READ reference WRITE setReference)
Q_PROPERTY(QGraphicsLayoutItem* layout READ layout)
Q_PROPERTY(qint8 reference READ reference WRITE setReference)
Q_PROPERTY(QGraphicsWidget* backWidget READ backWidget WRITE setBackWidget)
public:
@ -59,24 +59,24 @@ public:
* MoveLeft, MoveRight) which can be combined (i.e. MoveUp|MoveLeft).
* @arg direction animation direction
*/
void setMovementDirection(const qint8 &direction);
void setMovementDirection(const Animation::MovementDirection &direction);
/**
* Get the animation movement direction.
*/
qint8 movementDirection() const;
Animation::MovementDirection movementDirection() const;
/**
* Set the animation rotation reference (e.g. Center, Up, Down, Left,
* Right) which can be combined (i.e. Center|Up).
* @arg reference animation reference
*/
void setReference(const qint8 &reference);
void setReference(const Animation::Reference &reference);
/**
* Get the animation rotation reference.
*/
qint8 reference() const;
Animation::Reference reference() const;
/**
* Get the layout where the widgetToAnimate and backWidget are.
@ -107,9 +107,9 @@ private:
void updateTransformations();
/** Animation reference (see \ref Animation::Reference) */
qint8 m_animReference;
Animation::Reference m_animReference;
/** Animation movement direction (see \ref Animation::MovementDirection) */
qint8 m_animDirection;
Animation::MovementDirection m_animDirection;
/** Object the animation(s) should act upon. */
QWeakPointer<QGraphicsWidget> m_backWidget;
/** Layout where widget would be added */

View File

@ -58,12 +58,12 @@ SlideAnimation::SlideAnimation(QObject *parent,
setEasingCurve(QEasingCurve::OutCirc);
}
void SlideAnimation::setMovementDirection(const qint8 &direction)
void SlideAnimation::setMovementDirection(const Animation::MovementDirection &direction)
{
m_animDirection = direction;
}
qint8 SlideAnimation::movementDirection() const
Animation::MovementDirection SlideAnimation::movementDirection() const
{
return m_animDirection;
}
@ -95,23 +95,23 @@ void SlideAnimation::updateState(QAbstractAnimation::State newState, QAbstractAn
bool moveAnyOnly = true;
if ((m_animDirection & MoveUp) == MoveUp) {
if (m_animDirection.testFlag(MoveUp)) {
newY -= actualDistance.x();
moveAnyOnly = false;
} else if ((m_animDirection & MoveDown) == MoveDown) {
} else if (m_animDirection.testFlag(MoveDown)) {
newY += actualDistance.x();
moveAnyOnly = false;
}
if ((m_animDirection & MoveRight) == MoveRight) {
if (m_animDirection.testFlag(MoveRight)) {
newX += actualDistance.x();
moveAnyOnly = false;
} else if ((m_animDirection & MoveLeft) == MoveLeft) {
} else if (m_animDirection.testFlag(MoveLeft)) {
newX -= actualDistance.x();
moveAnyOnly = false;
}
if (moveAnyOnly && (m_animDirection & MoveAny) == MoveAny) {
if (moveAnyOnly && m_animDirection.testFlag(MoveAny)) {
newX = actualDistance.x();
newY = actualDistance.y();
}

View File

@ -42,8 +42,8 @@ class SlideAnimationPrivate;
class SlideAnimation : public Animation
{
Q_OBJECT
Q_PROPERTY(qint8 movementDirection READ movementDirection WRITE setMovementDirection)
Q_PROPERTY(qreal distance READ distance WRITE setDistance)
Q_PROPERTY(MovementDirection movementDirection READ movementDirection WRITE setMovementDirection)
Q_PROPERTY(QPointF distancePointF READ distancePointF WRITE setDistancePointF)
public:
@ -68,12 +68,12 @@ public:
* Set the animation direction
* @arg direction animation direction
*/
void setMovementDirection(const qint8 &direction);
void setMovementDirection(const Animation::MovementDirection&direction);
/**
* Get the animation direction
*/
qint8 movementDirection() const;
Animation::MovementDirection movementDirection() const;
protected:
void updateCurrentTime(int currentTime);
@ -83,7 +83,7 @@ private:
/**
* Animation direction: where the animation will move.
*/
qint8 m_animDirection;
Animation::MovementDirection m_animDirection;
/**
* Animation distance: displacement factor for animations where