diff options
Diffstat (limited to 'examples/animation/research/memberfunctions/qvalueanimation.cpp')
-rw-r--r-- | examples/animation/research/memberfunctions/qvalueanimation.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/examples/animation/research/memberfunctions/qvalueanimation.cpp b/examples/animation/research/memberfunctions/qvalueanimation.cpp new file mode 100644 index 0000000..2fe9be9 --- /dev/null +++ b/examples/animation/research/memberfunctions/qvalueanimation.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + + + +#include "qvalueanimation.h" +#include "qvalueanimation_p.h" + +QT_BEGIN_NAMESPACE + + +void QValueAnimationPrivate::initDefaultStartValue() +{ + Q_Q(QValueAnimation); + if (animProp && !q->startValue().isValid() + && ((currentTime == 0 && (currentIteration || currentIteration == 0)) + || (currentTime == duration && currentIteration == (iterationCount - 1)))) { + setDefaultStartValue(animProp->read()); + } +} + + +QValueAnimation::QValueAnimation(QObject *parent) : QVariantAnimation(*new QValueAnimationPrivate, parent) +{ +} + +QValueAnimation::~QValueAnimation() +{ +} + +void QValueAnimation::setProperty(AbstractProperty *animProp) +{ + Q_D(QValueAnimation); + d->animProp = animProp; +} + +/*! + \reimp + */ +void QValueAnimation::updateCurrentValue(const QVariant &value) +{ + Q_D(QValueAnimation); + if (state() == QAbstractAnimation::Stopped) + return; + + d->animProp->write(value); +} + + +/*! + \reimp +*/ +void QValueAnimation::updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState) +{ + Q_D(QValueAnimation); + // Initialize start value + if (oldState == QAbstractAnimation::Stopped && newState == QAbstractAnimation::Running) + d->initDefaultStartValue(); +} + + + +#include "moc_qvalueanimation.cpp" + +QT_END_NAMESPACE |