summaryrefslogtreecommitdiffstats
path: root/src/declarative/util
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-07-10 01:17:51 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-07-10 01:17:51 (GMT)
commit9c13caa3c99af01a9b4c3ff6e178e7dadb61741f (patch)
treeb69df0a23c4628359fc3740e09958980eda7478e /src/declarative/util
parentbb1bdcab28e4c52dcea37dfaaa435045b1985eeb (diff)
parent883da42f7c75775502c818aa456c8576d8457ff8 (diff)
downloadQt-9c13caa3c99af01a9b4c3ff6e178e7dadb61741f.zip
Qt-9c13caa3c99af01a9b4c3ff6e178e7dadb61741f.tar.gz
Qt-9c13caa3c99af01a9b4c3ff6e178e7dadb61741f.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui-gv
Conflicts: examples/itemviews/frozencolumn/main.cpp src/declarative/canvas/qsimplecanvas.cpp src/declarative/canvas/qsimplecanvas_p.h src/declarative/canvas/qsimplecanvasitem.h src/declarative/extra/qfxparticles.cpp src/declarative/fx/fx.pri src/declarative/fx/qfxblurfilter.h src/declarative/fx/qfxcontentwrapper.cpp src/declarative/fx/qfxflickable.cpp src/declarative/fx/qfxfocuspanel.h src/declarative/fx/qfxfocusrealm.h src/declarative/fx/qfxhighlightfilter.cpp src/declarative/fx/qfxhighlightfilter.h src/declarative/fx/qfximage.cpp src/declarative/fx/qfxitem.cpp src/declarative/fx/qfxitem.h src/declarative/fx/qfxrect.cpp src/declarative/fx/qfxreflectionfilter.h src/declarative/fx/qfxshadowfilter.cpp src/declarative/fx/qfxshadowfilter.h src/declarative/fx/qfxtext.cpp src/declarative/fx/qfxtext.h src/declarative/fx/qfxtextedit.cpp src/declarative/opengl/glbasicshaders.h src/declarative/test/qfxtestengine.cpp src/declarative/test/qfxtestengine.h src/declarative/test/qfxtestobjects.cpp src/declarative/test/qfxtestobjects.h src/declarative/test/qfxtestview.h src/declarative/util/qfxglobal.h src/declarative/util/qfxview.cpp src/gui/graphicsview/qgraphicsitem_p.h tools/qmlviewer/qmlviewer.cpp
Diffstat (limited to 'src/declarative/util')
-rw-r--r--src/declarative/util/qbindablemap.cpp182
-rw-r--r--src/declarative/util/qfxglobal.h3
-rw-r--r--src/declarative/util/qfxperf.cpp5
-rw-r--r--src/declarative/util/qfxperf_p.h (renamed from src/declarative/util/qfxperf.h)22
-rw-r--r--src/declarative/util/qfxview.cpp6
-rw-r--r--src/declarative/util/qmlanimation.cpp1062
-rw-r--r--src/declarative/util/qmlanimation.h193
-rw-r--r--src/declarative/util/qmlanimation_p.h98
-rw-r--r--src/declarative/util/qmlbehaviour.cpp259
-rw-r--r--src/declarative/util/qmlbehaviour.h95
-rw-r--r--src/declarative/util/qmlbind.cpp1
-rw-r--r--src/declarative/util/qmlbind.h3
-rw-r--r--src/declarative/util/qmlconnection.cpp2
-rw-r--r--src/declarative/util/qmlconnection.h3
-rw-r--r--src/declarative/util/qmldatetimeformatter.cpp368
-rw-r--r--src/declarative/util/qmldatetimeformatter.h115
-rw-r--r--src/declarative/util/qmlfollow.cpp69
-rw-r--r--src/declarative/util/qmlfollow.h8
-rw-r--r--src/declarative/util/qmlfont.cpp3
-rw-r--r--src/declarative/util/qmlfont.h3
-rw-r--r--src/declarative/util/qmllistmodel.cpp78
-rw-r--r--src/declarative/util/qmllistmodel.h29
-rw-r--r--src/declarative/util/qmlnullablevalue_p.h16
-rw-r--r--src/declarative/util/qmlopenmetaobject.cpp1
-rw-r--r--src/declarative/util/qmlpackage.cpp3
-rw-r--r--src/declarative/util/qmlpackage.h3
-rw-r--r--src/declarative/util/qmlscript.cpp2
-rw-r--r--src/declarative/util/qmlscript.h6
-rw-r--r--src/declarative/util/qmlsetproperties.cpp76
-rw-r--r--src/declarative/util/qmlsetproperties.h8
-rw-r--r--src/declarative/util/qmlstate.cpp206
-rw-r--r--src/declarative/util/qmlstate.h45
-rw-r--r--src/declarative/util/qmlstate_p.h50
-rw-r--r--src/declarative/util/qmlstategroup.cpp2
-rw-r--r--src/declarative/util/qmlstategroup.h3
-rw-r--r--src/declarative/util/qmlstateoperations.cpp225
-rw-r--r--src/declarative/util/qmlstateoperations.h33
-rw-r--r--src/declarative/util/qmltimeline.cpp940
-rw-r--r--src/declarative/util/qmltimeline_p.h224
-rw-r--r--src/declarative/util/qmltransition.cpp8
-rw-r--r--src/declarative/util/qmltransition.h6
-rw-r--r--src/declarative/util/qmltransitionmanager.cpp225
-rw-r--r--src/declarative/util/qmltransitionmanager_p.h (renamed from src/declarative/util/qbindablemap.h)60
-rw-r--r--src/declarative/util/qperformancelog.cpp5
-rw-r--r--src/declarative/util/qperformancelog_p.h (renamed from src/declarative/util/qperformancelog.h)5
-rw-r--r--src/declarative/util/util.pri14
46 files changed, 2241 insertions, 2532 deletions
diff --git a/src/declarative/util/qbindablemap.cpp b/src/declarative/util/qbindablemap.cpp
deleted file mode 100644
index c8c8ced..0000000
--- a/src/declarative/util/qbindablemap.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qbindablemap.h"
-#include <qmlopenmetaobject.h>
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-//QBindableMapMetaObject lets us listen for changes coming from QML
-//so we can emit the changed signal.
-class QBindableMapMetaObject : public QmlOpenMetaObject
-{
-public:
- QBindableMapMetaObject(QBindableMap *obj) : QmlOpenMetaObject(obj)
- {
- map = obj;
- }
-
-protected:
- virtual void propertyWrite(int index)
- {
- map->emitChanged(QLatin1String(name(index)));
- }
-
-private:
- QBindableMap *map;
-};
-
-/*!
- \class QBindableMap
- \brief The QBindableMap class allows you to set key-value pairs that can be used in bindings.
-
- QBindableMap provides a convenient way to expose domain data to the UI layer.
- The following example shows how you might declare data in C++ and then
- access it in QML.
-
- Setup in C++:
- \code
- //create our data
- QBindableMap ownerData;
- ownerData.setValue("name", QVariant(QString("John Smith")));
- ownerData.setValue("phone", QVariant(QString("555-5555")));
-
- //expose it to the UI layer
- QmlContext *ctxt = view->bindContext();
- ctxt->setProperty("owner", &data);
- \endcode
-
- Then, in QML:
- \code
- Text { text: owner.name }
- Text { text: owner.phone }
- \endcode
-
- The binding is dynamic - whenever a key's value is updated, anything bound to that
- key will be updated as well.
-
- To detect value changes made in the UI layer you can connect to the changed() signal.
- However, note that changed() is \b NOT emitted when changes are made by calling setValue()
- or clearValue() - it is only emitted when a value is updated from QML.
-*/
-
-// is there a more efficient way to store/return keys?
-// (or should we just provide an iterator or something else instead?)
-// can we provide a way to clear keys?
-// do we want to make any claims regarding key ordering?
-// should we have signals for insertion and and deletion -- becoming more model like
-// should we emit change for our own changes as well?
-// Bug or Feature?: values can be created in QML (owner.somethingElse = "Hello") will create somethingElse property. (need to verify if this is actually the case)
-// Bug or Feature?: all values are read-write (there are no read-only values)
-
-/*!
- Constructs a bindable map with parent object \a parent.
-*/
-QBindableMap::QBindableMap(QObject *parent)
-: QObject(parent)
-{
- m_mo = new QBindableMapMetaObject(this);
-}
-
-/*!
- Destroys the bindable map.
-*/
-QBindableMap::~QBindableMap()
-{
-}
-
-/*!
- Clears the value (if any) associated with \a key.
-*/
-void QBindableMap::clearValue(const QString &key)
-{
- //m_keys.remove(); //###
- m_mo->setValue(key.toLatin1(), QVariant());
- //emit changed(key);
-}
-
-/*!
- Returns the value associated with \a key.
-
- If no value has been set for this key (or if the value has been cleared),
- an invalid QVariant is returned.
-*/
-QVariant QBindableMap::value(const QString &key) const
-{
- return m_mo->value(key.toLatin1());
-}
-
-/*!
- Sets the value associated with \a key to \a value.
-
- If the key doesn't exist, it is automatically created.
-*/
-void QBindableMap::setValue(const QString &key, QVariant value)
-{
- if (!m_keys.contains(key))
- m_keys.append(key);
- m_mo->setValue(key.toLatin1(), value);
- //emit changed(key);
-}
-
-/*!
- Returns the list of keys.
-
- Keys that have been cleared will still appear in this list, even though their
- associated values are invalid QVariants.
-*/
-QStringList QBindableMap::keys() const
-{
- return m_keys;
-}
-
-/*!
- \fn void QBindableMap::changed(const QString &key)
- This signal is emitted whenever one of the values in the map is changed. \a key
- is the key corresponding to the value that was changed.
- */
-
-void QBindableMap::emitChanged(const QString &key)
-{
- emit changed(key);
-}
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qfxglobal.h b/src/declarative/util/qfxglobal.h
index 1f3d561f..9b4aee1 100644
--- a/src/declarative/util/qfxglobal.h
+++ b/src/declarative/util/qfxglobal.h
@@ -45,7 +45,6 @@
#include <QtCore/qglobal.h>
#include <QtCore/QObject>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -88,8 +87,8 @@ inline void QFx_setParent_noEvent(QObject *object, QObject *parent)
static_cast<QFx_DerivedObject *>(object)->setParent_noEvent(parent);
}
-
QT_END_NAMESPACE
QT_END_HEADER
+
#endif // QFXGLOBAL_H
diff --git a/src/declarative/util/qfxperf.cpp b/src/declarative/util/qfxperf.cpp
index e4f0c53..db56b37 100644
--- a/src/declarative/util/qfxperf.cpp
+++ b/src/declarative/util/qfxperf.cpp
@@ -39,10 +39,10 @@
**
****************************************************************************/
-#include "qfxperf.h"
-
+#include "private/qfxperf_p.h"
QT_BEGIN_NAMESPACE
+
Q_DEFINE_PERFORMANCE_LOG(QFxPerf, "QFx") {
Q_DEFINE_PERFORMANCE_METRIC(QmlParsing, "Compilation: QML Parsing")
Q_DEFINE_PERFORMANCE_METRIC(Compilation, " QML Compilation")
@@ -64,4 +64,5 @@ Q_DEFINE_PERFORMANCE_LOG(QFxPerf, "QFx") {
Q_DEFINE_PERFORMANCE_METRIC(QFxText_setText, " QFxText::setText")
Q_DEFINE_PERFORMANCE_METRIC(AddScript, "QmlScript::addScriptToEngine")
}
+
QT_END_NAMESPACE
diff --git a/src/declarative/util/qfxperf.h b/src/declarative/util/qfxperf_p.h
index 9fcf1d6..a1e38b7 100644
--- a/src/declarative/util/qfxperf.h
+++ b/src/declarative/util/qfxperf_p.h
@@ -38,17 +38,28 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef _QFXPERF_H_
-#define _QFXPERF_H_
+#ifndef QFXPERF_H
+#define QFXPERF_H
-#include "qperformancelog.h"
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+#include "private/qperformancelog_p.h"
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
Q_DECLARE_PERFORMANCE_LOG(QFxPerf) {
Q_DECLARE_PERFORMANCE_METRIC(QmlParsing)
@@ -73,9 +84,8 @@ Q_DECLARE_PERFORMANCE_LOG(QFxPerf) {
Q_DECLARE_PERFORMANCE_METRIC(AddScript)
}
-#endif // _QFXPERF_H_
-
-
QT_END_NAMESPACE
QT_END_HEADER
+
+#endif // QFXPERF_H
diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp
index 43c10bb..e8b324c 100644
--- a/src/declarative/util/qfxview.cpp
+++ b/src/declarative/util/qfxview.cpp
@@ -54,16 +54,16 @@
#include "qmlbindablevalue.h"
#include "qml.h"
#include "qfxitem.h"
-#include "qperformancelog.h"
-#include "qfxperf.h"
+#include "private/qperformancelog_p.h"
+#include "private/qfxperf_p.h"
#include "qfxview.h"
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcontext.h>
#include <QtDeclarative/qmldebugger.h>
-
QT_BEGIN_NAMESPACE
+
DEFINE_BOOL_CONFIG_OPTION(qmlDebugger, QML_DEBUGGER);
static QVariant stringToPixmap(const QString &str)
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index 7df249e..ff070c1 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -45,6 +45,7 @@
#include "qfile.h"
#include "qmlpropertyvaluesource.h"
#include "qml.h"
+#include "qmlinfo.h"
#include "qmlanimation_p.h"
#include "qmlbehaviour.h"
#include <QParallelAnimationGroup>
@@ -57,12 +58,6 @@
#include <private/qmlstringconverters_p.h>
#include <private/qvariantanimation_p.h>
-/* TODO:
- Check for any memory leaks
- easing should be a QEasingCurve-type property
- All other XXXs
-*/
-
QT_BEGIN_NAMESPACE
QEasingCurve stringToCurve(const QString &curve)
@@ -85,18 +80,22 @@ QEasingCurve stringToCurve(const QString &curve)
QString prop_str =
easeName.mid(idx + 1, easeName.length() - 1 - idx - 1);
normalizedCurve = easeName.left(idx);
+ if (!normalizedCurve.startsWith(QLatin1String("ease"))) {
+ qWarning("QEasingCurve: Easing function '%s' must start with 'ease'",
+ curve.toLatin1().constData());
+ }
props = prop_str.split(QLatin1Char(','));
}
- normalizedCurve = normalizedCurve.mid(4);
- //XXX optimize?
- int index = QEasingCurve::staticMetaObject.indexOfEnumerator("Type");
- QMetaEnum me = QEasingCurve::staticMetaObject.enumerator(index);
+ if (normalizedCurve.startsWith(QLatin1String("ease")))
+ normalizedCurve = normalizedCurve.mid(4);
+
+ static int index = QEasingCurve::staticMetaObject.indexOfEnumerator("Type");
+ static QMetaEnum me = QEasingCurve::staticMetaObject.enumerator(index);
int value = me.keyToValue(normalizedCurve.toLatin1().constData());
if (value < 0) {
- //XXX print line number
qWarning("QEasingCurve: Unknown easing curve '%s'",
curve.toLatin1().constData());
value = 0;
@@ -123,7 +122,6 @@ QEasingCurve stringToCurve(const QString &curve)
return easingCurve;
}
- //XXX optimize
if (propName == QLatin1String("amplitude")) {
easingCurve.setAmplitude(propValue);
} else if (propName == QLatin1String("period")) {
@@ -179,7 +177,7 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj
\code
Rect {
width: 100; height: 100
- x: NumericAnimation {
+ x: NumberAnimation {
running: MyMouse.pressed
from: 0; to: 100
}
@@ -192,7 +190,7 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj
or not the animation is running.
\code
- NumericAnimation { id: MyAnimation }
+ NumberAnimation { id: MyAnimation }
Text { text: MyAnimation.running ? "Animation is running" : "Animation is not running" }
\endcode
@@ -219,6 +217,21 @@ void QmlAbstractAnimationPrivate::commence()
}
}
+//### make static?
+QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str)
+{
+ Q_Q(QmlAbstractAnimation);
+ QmlMetaProperty prop = QmlMetaProperty::createProperty(obj, str);
+ if (!prop.isValid()) {
+ qmlInfo(q) << "Cannot animate non-existant property" << str;
+ return QmlMetaProperty();
+ } else if (!prop.isWritable()) {
+ qmlInfo(q) << "Cannot animate read-only property" << str;
+ return QmlMetaProperty();
+ }
+ return prop;
+}
+
void QmlAbstractAnimation::setRunning(bool r)
{
Q_D(QmlAbstractAnimation);
@@ -255,6 +268,44 @@ void QmlAbstractAnimation::setRunning(bool r)
emit runningChanged(d->running);
}
+/*!
+ \qmlproperty bool Animation::paused
+ This property holds whether the animation is currently paused.
+
+ The \c paused property can be set to declaratively control whether or not
+ an animation is paused.
+
+ Animations can also be paused and resumed imperatively from JavaScript
+ using the \c pause() and \c resume() methods.
+
+ By default, animations are not paused.
+*/
+bool QmlAbstractAnimation::isPaused() const
+{
+ Q_D(const QmlAbstractAnimation);
+ return d->paused;
+}
+
+void QmlAbstractAnimation::setPaused(bool p)
+{
+ Q_D(QmlAbstractAnimation);
+ if (d->paused == p)
+ return;
+
+ if (d->group) {
+ qWarning("QmlAbstractAnimation: setPaused() cannot be used on non-root animation nodes");
+ return;
+ }
+
+ d->paused = p;
+ if (d->paused)
+ qtAnimation()->pause();
+ else
+ qtAnimation()->resume();
+
+ emit pausedChanged(d->running);
+}
+
void QmlAbstractAnimation::classBegin()
{
Q_D(QmlAbstractAnimation);
@@ -311,7 +362,7 @@ void QmlAbstractAnimation::setFinishPlaying(bool f)
\code
Rect {
- rotation: NumericAnimation { running: true; repeat: true; from: 0 to: 360 }
+ rotation: NumberAnimation { running: true; repeat: true; from: 0 to: 360 }
}
\endcode
*/
@@ -333,6 +384,16 @@ void QmlAbstractAnimation::setRepeat(bool r)
emit repeatChanged(r);
}
+int QmlAbstractAnimation::currentTime()
+{
+ return qtAnimation()->currentTime();
+}
+
+void QmlAbstractAnimation::setCurrentTime(int time)
+{
+ qtAnimation()->setCurrentTime(time);
+}
+
QmlAnimationGroup *QmlAbstractAnimation::group() const
{
Q_D(const QmlAbstractAnimation);
@@ -380,7 +441,7 @@ void QmlAbstractAnimation::setTarget(QObject *o)
d->target = o;
if (d->target && !d->propertyName.isEmpty()) {
- d->userProperty = QmlMetaProperty(d->target, d->propertyName);
+ d->userProperty = d->createProperty(d->target, d->propertyName);
} else {
d->userProperty.invalidate();
}
@@ -409,7 +470,7 @@ void QmlAbstractAnimation::setProperty(const QString &n)
d->propertyName = n;
if (d->target && !d->propertyName.isEmpty()) {
- d->userProperty = QmlMetaProperty(d->target, d->propertyName);
+ d->userProperty = d->createProperty(d->target, d->propertyName);
} else {
d->userProperty.invalidate();
}
@@ -430,6 +491,30 @@ void QmlAbstractAnimation::start()
}
/*!
+ \qmlmethod Animation::pause()
+ \brief Pauses the animation.
+
+ If the animation is already paused, calling this method has no effect. The
+ \c paused property will be true following a call to \c pause().
+*/
+void QmlAbstractAnimation::pause()
+{
+ setPaused(true);
+}
+
+/*!
+ \qmlmethod Animation::resume()
+ \brief Resumes a paused animation.
+
+ If the animation is not paused, calling this method has no effect. The
+ \c paused property will be false following a call to \c resume().
+*/
+void QmlAbstractAnimation::resume()
+{
+ setPaused(false);
+}
+
+/*!
\qmlmethod Animation::stop()
\brief Stops the animation.
@@ -440,7 +525,7 @@ void QmlAbstractAnimation::start()
no further influence on property values. In this example animation
\code
Rect {
- x: NumericAnimation { from: 0; to: 100; duration: 500 }
+ x: NumberAnimation { from: 0; to: 100; duration: 500 }
}
\endcode
was stopped at time 250ms, the \c x property will have a value of 50.
@@ -478,7 +563,7 @@ void QmlAbstractAnimation::restart()
its end. In the following example,
\code
Rect {
- x: NumericAnimation { from: 0; to: 100; duration: 500 }
+ x: NumberAnimation { from: 0; to: 100; duration: 500 }
}
\endcode
calling \c stop() at time 250ms will result in the \c x property having
@@ -534,9 +619,9 @@ void QmlAbstractAnimation::timelineComplete()
A 500ms animation sequence, with a 100ms pause between two animations:
\code
SequentialAnimation {
- NumericAnimation { ... duration: 200 }
+ NumberAnimation { ... duration: 200 }
PauseAnimation { duration: 100 }
- NumericAnimation { ... duration: 200 }
+ NumberAnimation { ... duration: 200 }
}
\endcode
*/
@@ -604,15 +689,6 @@ void QmlPauseAnimation::setDuration(int duration)
emit durationChanged(duration);
}
-void QmlPauseAnimation::prepare(QmlMetaProperty &p)
-{
- Q_D(QmlPauseAnimation);
- if (d->userProperty.isNull)
- d->property = p;
- else
- d->property = d->userProperty;
-}
-
QAbstractAnimation *QmlPauseAnimation::qtAnimation()
{
Q_D(QmlPauseAnimation);
@@ -621,16 +697,16 @@ QAbstractAnimation *QmlPauseAnimation::qtAnimation()
/*!
\qmlclass ColorAnimation QmlColorAnimation
- \inherits Animation
+ \inherits PropertyAnimation
\brief The ColorAnimation allows you to animate color changes.
\code
ColorAnimation { from: "white"; to: "#c0c0c0"; duration: 100 }
\endcode
- The default property animated is \c color, but like other animations,
- this can be changed by setting \c property. The \c color property will
- still animate. XXX is this a bug?
+ When used in a transition, ColorAnimation will by default animate
+ all properties of type color that are changing. If a property or properties
+ are explicity set for the animation, then those will be used instead.
*/
/*!
\internal
@@ -644,56 +720,19 @@ QAbstractAnimation *QmlPauseAnimation::qtAnimation()
*/
QmlColorAnimation::QmlColorAnimation(QObject *parent)
-: QmlAbstractAnimation(*(new QmlColorAnimationPrivate), parent)
+: QmlPropertyAnimation(parent)
{
- Q_D(QmlColorAnimation);
+ Q_D(QmlPropertyAnimation);
d->init();
+ d->interpolatorType = QMetaType::QColor;
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
+ d->defaultToInterpolatorType = true;
}
QmlColorAnimation::~QmlColorAnimation()
{
}
-void QmlColorAnimationPrivate::init()
-{
- Q_Q(QmlColorAnimation);
- ca = new QmlTimeLineValueAnimator(q);
- ca->setStartValue(QVariant(0.0f));
- ca->setEndValue(QVariant(1.0f));
-}
-
-/*!
- \qmlproperty int ColorAnimation::duration
- This property holds the duration of the color transition, in milliseconds.
-
- The default value is 250.
-*/
-/*!
- \property QmlColorAnimation::duration
- \brief the duration of the transition, in milliseconds.
-
- The default value is 250.
-*/
-int QmlColorAnimation::duration() const
-{
- Q_D(const QmlColorAnimation);
- return d->ca->duration();
-}
-
-void QmlColorAnimation::setDuration(int duration)
-{
- if (duration < 0) {
- qWarning("QmlColorAnimation: Cannot set a duration of < 0");
- return;
- }
-
- Q_D(QmlColorAnimation);
- if (d->ca->duration() == duration)
- return;
- d->ca->setDuration(duration);
- emit durationChanged(duration);
-}
-
/*!
\qmlproperty color ColorAnimation::from
This property holds the starting color.
@@ -704,18 +743,13 @@ void QmlColorAnimation::setDuration(int duration)
*/
QColor QmlColorAnimation::from() const
{
- Q_D(const QmlColorAnimation);
- return d->fromValue;
+ Q_D(const QmlPropertyAnimation);
+ return d->from.value<QColor>();
}
void QmlColorAnimation::setFrom(const QColor &f)
{
- Q_D(QmlColorAnimation);
- if (d->fromIsDefined && f == d->fromValue)
- return;
- d->fromValue = f;
- d->fromIsDefined = f.isValid();
- emit fromChanged(f);
+ QmlPropertyAnimation::setFrom(f);
}
/*!
@@ -728,202 +762,15 @@ void QmlColorAnimation::setFrom(const QColor &f)
*/
QColor QmlColorAnimation::to() const
{
- Q_D(const QmlColorAnimation);
- return d->toValue;
+ Q_D(const QmlPropertyAnimation);
+ return d->to.value<QColor>();
}
void QmlColorAnimation::setTo(const QColor &t)
{
- Q_D(QmlColorAnimation);
- if (d->toIsDefined && t == d->toValue)
- return;
- d->toValue = t;
- d->toIsDefined = t.isValid();
- emit toChanged(t);
-}
-
-/*!
- \qmlproperty string ColorAnimation::easing
- This property holds the easing curve used for the transition.
-
- Each channel of the color is eased using the same easing curve.
- See NumericAnimation::easing for a full discussion of easing,
- and a list of available curves.
-*/
-QString QmlColorAnimation::easing() const
-{
- Q_D(const QmlColorAnimation);
- return d->easing;
-}
-
-void QmlColorAnimation::setEasing(const QString &e)
-{
- Q_D(QmlColorAnimation);
- if (d->easing == e)
- return;
-
- d->easing = e;
- d->ca->setEasingCurve(stringToCurve(d->easing));
- emit easingChanged(e);
-}
-
-/*!
- \qmlproperty list<Item> ColorAnimation::filter
- This property holds the items selected to be affected by this animation (all if not set).
- \sa exclude
-*/
-QList<QObject *> *QmlColorAnimation::filter()
-{
- Q_D(QmlColorAnimation);
- return &d->filter;
-}
-
-/*!
- \qmlproperty list<Item> ColorAnimation::exclude
- This property holds the items not to be affected by this animation.
- \sa filter
-*/
-QList<QObject *> *QmlColorAnimation::exclude()
-{
- Q_D(QmlColorAnimation);
- return &d->exclude;
-}
-
-void QmlColorAnimation::prepare(QmlMetaProperty &p)
-{
- Q_D(QmlColorAnimation);
- if (d->userProperty.isNull)
- d->property = p;
- else
- d->property = d->userProperty;
- d->fromSourced = false;
- d->value.QmlTimeLineValue::setValue(0.);
- d->ca->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped);
- d->ca->setFromSourcedValue(&d->fromSourced);
+ QmlPropertyAnimation::setTo(t);
}
-QAbstractAnimation *QmlColorAnimation::qtAnimation()
-{
- Q_D(QmlColorAnimation);
- return d->ca;
-}
-
-void QmlColorAnimation::transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QmlColorAnimation);
- Q_UNUSED(direction);
-
- struct NTransitionData : public QmlTimeLineValue
- {
- QmlStateActions actions;
- void write(QmlMetaProperty &property, const QVariant &color)
- {
- if (property.propertyType() == QVariant::Color) {
- property.write(color);
- }
- }
-
- void setValue(qreal v)
- {
- QmlTimeLineValue::setValue(v);
- for (int ii = 0; ii < actions.count(); ++ii) {
- Action &action = actions[ii];
-
- QColor to(action.toValue.value<QColor>());
-
- if (v == 1.) {
- write(action.property, to);
- } else {
- if (action.fromValue.isNull()) {
- action.fromValue = action.property.read();
- if (action.fromValue.isNull())
- action.fromValue = QVariant(QColor());
- }
-
- QColor from(action.fromValue.value<QColor>());
-
- QVariant newColor = QmlColorAnimationPrivate::colorInterpolator(&from, &to, v);
- write(action.property, newColor);
- }
- }
- }
- };
-
- //XXX should we get rid of this?
- QStringList props;
- props << QLatin1String("color");
- if (!d->propertyName.isEmpty() && !props.contains(d->propertyName))
- props.append(d->propertyName);
-
- NTransitionData *data = new NTransitionData;
-
- QSet<QObject *> objs;
- for (int ii = 0; ii < actions.count(); ++ii) {
- Action &action = actions[ii];
-
- QObject *obj = action.property.object();
- QString propertyName = action.property.name();
-
- if ((d->filter.isEmpty() || d->filter.contains(obj)) &&
- (!d->exclude.contains(obj)) && props.contains(propertyName) &&
- (!target() || target() == obj)) {
- objs.insert(obj);
- Action myAction = action;
-
- if (d->fromIsDefined) {
- myAction.fromValue = QVariant(d->fromValue);
- } else {
- myAction.fromValue = QVariant();
- }
- if (d->toIsDefined)
- myAction.toValue = QVariant(d->toValue);
-
- modified << action.property;
- data->actions << myAction;
- action.fromValue = myAction.toValue;
- }
- }
-
- if (d->toValue.isValid() && target() && !objs.contains(target())) {
- QObject *obj = target();
- for (int jj = 0; jj < props.count(); ++jj) {
- Action myAction;
- myAction.property = QmlMetaProperty(obj, props.at(jj));
-
- if (d->fromIsDefined)
- myAction.fromValue = QVariant(d->fromValue);
-
- myAction.toValue = QVariant(d->toValue);
- myAction.bv = 0;
- myAction.event = 0;
- data->actions << myAction;
- }
- }
-
- if (data->actions.count())
- d->ca->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped);
- else
- delete data;
-}
-
-QVariantAnimation::Interpolator QmlColorAnimationPrivate::colorInterpolator = 0;
-
-void QmlColorAnimationPrivate::valueChanged(qreal v)
-{
- if (!fromSourced) {
- if (!fromIsDefined) {
- fromValue = qvariant_cast<QColor>(property.read());
- }
- fromSourced = true;
- }
-
- if (property.propertyType() == QVariant::Color) {
- QVariant newColor = colorInterpolator(&fromValue, &toValue, v);
- property.write(newColor);
- }
-}
QML_DEFINE_TYPE(QmlColorAnimation,ColorAnimation)
/*!
@@ -1187,10 +1034,14 @@ void QmlSetPropertyAction::transition(QmlStateActions &actions,
QObject *obj = action.property.object();
QString propertyName = action.property.name();
-
- if ((d->filter.isEmpty() || d->filter.contains(obj)) &&
- (!d->exclude.contains(obj)) && props.contains(propertyName) &&
- (!target() || target() == obj)) {
+ QObject *sObj = action.specifiedObject;
+ QString sPropertyName = action.specifiedProperty;
+ bool same = (obj == sObj);
+
+ if ((d->filter.isEmpty() || d->filter.contains(obj) || (!same && d->filter.contains(sObj))) &&
+ (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
+ (props.contains(propertyName) || (!same && props.contains(sPropertyName))) &&
+ (!target() || target() == obj || (!same && target() == sObj))) {
objs.insert(obj);
Action myAction = action;
@@ -1207,7 +1058,9 @@ void QmlSetPropertyAction::transition(QmlStateActions &actions,
QObject *obj = target();
for (int jj = 0; jj < props.count(); ++jj) {
Action myAction;
- myAction.property = QmlMetaProperty(obj, props.at(jj));
+ myAction.property = d->createProperty(obj, props.at(jj));
+ if (!myAction.property.isValid())
+ continue;
myAction.toValue = d->value;
data->actions << myAction;
}
@@ -1249,7 +1102,7 @@ void QmlParentChangeActionPrivate::init()
void QmlParentChangeActionPrivate::doAction()
{
- //XXX property.write(value);
+ //### property.write(value);
}
void QmlParentChangeAction::prepare(QmlMetaProperty &p)
@@ -1261,7 +1114,7 @@ void QmlParentChangeAction::prepare(QmlMetaProperty &p)
else
d->property = d->userProperty;
- //XXX
+ //###
}
QAbstractAnimation *QmlParentChangeAction::qtAnimation()
@@ -1333,391 +1186,82 @@ void QmlParentChangeAction::transition(QmlStateActions &actions,
QML_DEFINE_TYPE(QmlParentChangeAction,ParentChangeAction)
/*!
- \qmlclass NumericAnimation QmlNumericAnimation
- \inherits Animation
- \brief The NumericAnimation allows you to animate changes in properties of type qreal.
+ \qmlclass NumberAnimation QmlNumberAnimation
+ \inherits PropertyAnimation
+ \brief The NumberAnimation allows you to animate changes in properties of type qreal.
Animate a set of properties over 200ms, from their values in the start state to
their values in the end state of the transition:
\code
- NumericAnimation { properties: "x,y,scale"; duration: 200 }
+ NumberAnimation { properties: "x,y,scale"; duration: 200 }
\endcode
*/
/*!
\internal
- \class QmlNumericAnimation
+ \class QmlNumberAnimation
\ingroup group_animation
\ingroup group_states
- \brief The QmlNumericAnimation class allows you to animate changes in properties of type qreal.
+ \brief The QmlNumberAnimation class allows you to animate changes in properties of type qreal.
- A QmlNumericAnimation object can be instantiated in Qml using the tag
- \l{xmlNumericAnimation} {&lt;NumericAnimation&gt;}.
+ A QmlNumberAnimation object can be instantiated in Qml using the tag
+ \l{xmlNumberAnimation} {&lt;NumberAnimation&gt;}.
*/
-QmlNumericAnimation::QmlNumericAnimation(QObject *parent)
-: QmlAbstractAnimation(*(new QmlNumericAnimationPrivate), parent)
+QmlNumberAnimation::QmlNumberAnimation(QObject *parent)
+: QmlPropertyAnimation(parent)
{
- Q_D(QmlNumericAnimation);
+ Q_D(QmlPropertyAnimation);
d->init();
+ d->interpolatorType = QMetaType::QReal;
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
}
-QmlNumericAnimation::~QmlNumericAnimation()
-{
-}
-
-void QmlNumericAnimationPrivate::init()
-{
- Q_Q(QmlNumericAnimation);
- na = new QmlTimeLineValueAnimator(q);
- na->setStartValue(QVariant(0.0f));
- na->setEndValue(QVariant(1.0f));
-}
-
-/*!
- \qmlproperty int NumericAnimation::duration
- This property holds the duration of the transition, in milliseconds.
-
- The default value is 250.
-*/
-/*!
- \property QmlNumericAnimation::duration
- \brief the duration of the transition, in milliseconds.
-
- The default value is 250.
-*/
-int QmlNumericAnimation::duration() const
-{
- Q_D(const QmlNumericAnimation);
- return d->na->duration();
-}
-
-void QmlNumericAnimation::setDuration(int duration)
+QmlNumberAnimation::~QmlNumberAnimation()
{
- if (duration < 0) {
- qWarning("QmlNumericAnimation: Cannot set a duration of < 0");
- return;
- }
-
- Q_D(QmlNumericAnimation);
- if (d->na->duration() == duration)
- return;
- d->na->setDuration(duration);
- emit durationChanged(duration);
}
/*!
- \qmlproperty real NumericAnimation::from
+ \qmlproperty real NumberAnimation::from
This property holds the starting value.
If not set, then the value defined in the start state of the transition.
*/
/*!
- \property QmlNumericAnimation::from
+ \property QmlNumberAnimation::from
\brief the starting value.
*/
-qreal QmlNumericAnimation::from() const
+qreal QmlNumberAnimation::from() const
{
- Q_D(const QmlNumericAnimation);
- return d->from;
+ Q_D(const QmlPropertyAnimation);
+ return d->from.toDouble();
}
-void QmlNumericAnimation::setFrom(qreal f)
+void QmlNumberAnimation::setFrom(qreal f)
{
- Q_D(QmlNumericAnimation);
- if (!d->from.isNull && f == d->from)
- return;
- d->from = f;
- emit fromChanged(f);
+ QmlPropertyAnimation::setFrom(f);
}
/*!
- \qmlproperty real NumericAnimation::to
+ \qmlproperty real NumberAnimation::to
This property holds the ending value.
If not set, then the value defined in the end state of the transition.
*/
/*!
- \property QmlNumericAnimation::to
+ \property QmlNumberAnimation::to
\brief the ending value.
*/
-qreal QmlNumericAnimation::to() const
+qreal QmlNumberAnimation::to() const
{
- Q_D(const QmlNumericAnimation);
- return d->to;
+ Q_D(const QmlPropertyAnimation);
+ return d->to.toDouble();
}
-void QmlNumericAnimation::setTo(qreal t)
+void QmlNumberAnimation::setTo(qreal t)
{
- Q_D(QmlNumericAnimation);
- if (!d->to.isNull && t == d->to)
- return;
- d->to = t;
- emit toChanged(t);
+ QmlPropertyAnimation::setTo(t);
}
-/*!
- \qmlproperty string NumericAnimation::easing
- \brief the easing curve used for the transition.
-
- Available values are:
-
- \list
- \i \e easeNone - Easing equation function for a simple linear tweening, with no easing.
- \i \e easeInQuad - Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity.
- \i \e easeOutQuad - Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity.
- \i \e easeInOutQuad - Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInQuad - Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInCubic - Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity.
- \i \e easeOutCubic - Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity.
- \i \e easeInOutCubic - Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInCubic - Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInQuart - Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity.
- \i \e easeOutQuart - Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity.
- \i \e easeInOutQuart - Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInQuart - Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInQuint - Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity.
- \i \e easeOutQuint - Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity.
- \i \e easeInOutQuint - Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInQuint - Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInSine - Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity.
- \i \e easeOutSine - Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity.
- \i \e easeInOutSine - Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInSine - Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInExpo - Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity.
- \i \e easeOutExpo - Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity.
- \i \e easeInOutExpo - Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInExpo - Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity.
- \i \e easeOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity.
- \i \e easeInOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity. The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
- \i \e easeOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out: decelerating from zero velocity. The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
- \i \e easeInOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
- \i \e easeOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity.
- \i \e easeInOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity.
- \i \e easeInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity.
- \i \e easeInOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration.
- \endlist
-*/
-
-/*!
- \property QmlNumericAnimation::easing
- This property holds the easing curve to use.
-
- \sa QEasingCurve
-*/
-QString QmlNumericAnimation::easing() const
-{
- Q_D(const QmlNumericAnimation);
- return d->easing;
-}
-
-void QmlNumericAnimation::setEasing(const QString &e)
-{
- Q_D(QmlNumericAnimation);
- if (d->easing == e)
- return;
-
- d->easing = e;
- d->na->setEasingCurve(stringToCurve(d->easing));
- emit easingChanged(e);
-}
-
-/*!
- \qmlproperty string NumericAnimation::properties
- This property holds the properties this animation should be applied to.
-
- This is a comma-separated list of properties that should use
- this animation when they change.
-*/
-/*!
- \property QmlNumericAnimation::properties
- \brief the properties this animation should be applied to.
-
- properties holds a comma-separated list of properties that should use
- this animation when they change.
-*/
-QString QmlNumericAnimation::properties() const
-{
- Q_D(const QmlNumericAnimation);
- return d->properties;
-}
-
-void QmlNumericAnimation::setProperties(const QString &prop)
-{
- Q_D(QmlNumericAnimation);
- if (d->properties == prop)
- return;
-
- d->properties = prop;
- emit propertiesChanged(prop);
-}
-
-/*!
- \qmlproperty list<Item> NumericAnimation::filter
- This property holds the items selected to be affected by this animation (all if not set).
- \sa exclude
-*/
-QList<QObject *> *QmlNumericAnimation::filter()
-{
- Q_D(QmlNumericAnimation);
- return &d->filter;
-}
-
-/*!
- \qmlproperty list<Item> NumericAnimation::exclude
- This property holds the items not to be affected by this animation.
- \sa filter
-*/
-QList<QObject *> *QmlNumericAnimation::exclude()
-{
- Q_D(QmlNumericAnimation);
- return &d->exclude;
-}
-
-void QmlNumericAnimationPrivate::valueChanged(qreal r)
-{
- if (!fromSourced) {
- if (from.isNull) {
- fromValue = qvariant_cast<qreal>(property.read());
- } else {
- fromValue = from;
- }
- fromSourced = true;
- }
-
- if (r == 1.) {
- property.write(to.value);
- } else {
- qreal val = fromValue + (to-fromValue) * r;
- property.write(val);
- }
-}
-
-void QmlNumericAnimation::prepare(QmlMetaProperty &p)
-{
- Q_D(QmlNumericAnimation);
- if (d->userProperty.isNull)
- d->property = p;
- else
- d->property = d->userProperty;
- d->fromSourced = false;
- d->value.QmlTimeLineValue::setValue(0.);
- d->na->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped);
- d->na->setFromSourcedValue(&d->fromSourced);
-}
-
-QAbstractAnimation *QmlNumericAnimation::qtAnimation()
-{
- Q_D(QmlNumericAnimation);
- return d->na;
-}
-
-void QmlNumericAnimation::transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QmlNumericAnimation);
- Q_UNUSED(direction);
-
- struct NTransitionData : public QmlTimeLineValue
- {
- QmlStateActions actions;
- void setValue(qreal v)
- {
- QmlTimeLineValue::setValue(v);
- for (int ii = 0; ii < actions.count(); ++ii) {
- Action &action = actions[ii];
-
- QmlBehaviour::_ignore = true;
- if (v == 1.)
- action.property.write(action.toValue.toDouble());
- else {
- if (action.fromValue.isNull()) {
- action.fromValue = action.property.read();
- if (action.fromValue.isNull()) {
- action.fromValue = QVariant(0.);
- }
- }
- qreal start = action.fromValue.toDouble();
- qreal end = action.toValue.toDouble();
- qreal val = start + (end-start) * v;
- action.property.write(val);
- }
- QmlBehaviour::_ignore = false;
- }
- }
- };
-
- QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
- for (int ii = 0; ii < props.count(); ++ii)
- props[ii] = props.at(ii).trimmed();
- if (!d->propertyName.isEmpty() && !props.contains(d->propertyName))
- props.append(d->propertyName);
-
- if (d->userProperty.isValid() && props.isEmpty() && !target()) {
- props.append(d->userProperty.value.name());
- d->target = d->userProperty.value.object();
- }
-
- NTransitionData *data = new NTransitionData;
-
- QSet<QObject *> objs;
- for (int ii = 0; ii < actions.count(); ++ii) {
- Action &action = actions[ii];
-
- QObject *obj = action.property.object();
- QString propertyName = action.property.name();
-
- if ((d->filter.isEmpty() || d->filter.contains(obj)) &&
- (!d->exclude.contains(obj)) && props.contains(propertyName) &&
- (!target() || target() == obj)) {
- objs.insert(obj);
- Action myAction = action;
- if (d->from.isValid()) {
- myAction.fromValue = QVariant(d->from);
- } else {
- myAction.fromValue = QVariant();
- }
- if (d->to.isValid())
- myAction.toValue = QVariant(d->to);
-
- modified << action.property;
-
- data->actions << myAction;
- action.fromValue = myAction.toValue;
- }
- }
-
- if (d->to.isValid() && target() && !objs.contains(target())) {
- QObject *obj = target();
- for (int jj = 0; jj < props.count(); ++jj) {
- Action myAction;
- myAction.property = QmlMetaProperty(obj, props.at(jj));
-
- if (d->from.isValid())
- myAction.fromValue = QVariant(d->from);
-
- myAction.toValue = QVariant(d->to);
- myAction.bv = 0;
- myAction.event = 0;
- data->actions << myAction;
- }
- }
-
- if (data->actions.count()) {
- d->na->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped);
- } else {
- delete data;
- }
-}
-
-QML_DEFINE_TYPE(QmlNumericAnimation,NumericAnimation)
+QML_DEFINE_TYPE(QmlNumberAnimation,NumberAnimation)
QmlAnimationGroup::QmlAnimationGroup(QObject *parent)
: QmlAbstractAnimation(*(new QmlAnimationGroupPrivate), parent)
@@ -1746,8 +1290,8 @@ QmlList<QmlAbstractAnimation *> *QmlAnimationGroup::animations()
\code
SequentialAnimation {
- NumericAnimation { target: MyItem; property: "x"; to: 100 }
- NumericAnimation { target: MyItem; property: "x"; to: 0 }
+ NumberAnimation { target: MyItem; property: "x"; to: 100 }
+ NumberAnimation { target: MyItem; property: "x"; to: 0 }
}
\endcode
@@ -1796,23 +1340,15 @@ void QmlSequentialAnimation::transition(QmlStateActions &actions,
from = d->animations.count() - 1;
}
- //### needed for Behavior
+ //needed for Behavior
if (d->userProperty.isValid() && d->propertyName.isEmpty() && !target()) {
for (int i = 0; i < d->animations.count(); ++i)
d->animations.at(i)->setTarget(d->userProperty);
}
- //XXX removing and readding isn't ideal; we do it to get around the problem mentioned below.
- for (int i = d->ag->animationCount()-1; i >= 0; --i)
- d->ag->takeAnimationAt(i);
-
for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) {
d->animations.at(ii)->transition(actions, modified, direction);
- d->ag->addAnimation(d->animations.at(ii)->qtAnimation());
}
-
- //XXX changing direction means all the animations play in reverse, while we only want the ordering reversed.
- //d->ag->setDirection(direction == Backward ? QAbstractAnimation::Backward : QAbstractAnimation::Forward);
}
QML_DEFINE_TYPE(QmlSequentialAnimation,SequentialAnimation)
@@ -1829,8 +1365,8 @@ QML_DEFINE_TYPE(QmlSequentialAnimation,SequentialAnimation)
\code
ParallelAnimation {
- NumericAnimation { target: MyItem; property: "x"; to: 100 }
- NumericAnimation { target: MyItem; property: "y"; to: 100 }
+ NumberAnimation { target: MyItem; property: "x"; to: 100 }
+ NumberAnimation { target: MyItem; property: "y"; to: 100 }
}
\endcode
@@ -1886,7 +1422,7 @@ void QmlParallelAnimation::transition(QmlStateActions &actions,
{
Q_D(QmlAnimationGroup);
- //### needed for Behavior
+ //needed for Behavior
if (d->userProperty.isValid() && d->propertyName.isEmpty() && !target()) {
for (int i = 0; i < d->animations.count(); ++i)
d->animations.at(i)->setTarget(d->userProperty);
@@ -1899,20 +1435,12 @@ void QmlParallelAnimation::transition(QmlStateActions &actions,
QML_DEFINE_TYPE(QmlParallelAnimation,ParallelAnimation)
-QVariant QmlVariantAnimationPrivate::interpolateVariant(const QVariant &from, const QVariant &to, qreal progress)
-{
- if (from.userType() != to.userType())
- return QVariant();
-
- QVariantAnimation::Interpolator interpolator = QVariantAnimationPrivate::getInterpolator(from.userType());
- return interpolator(from.constData(), to.constData(), progress);
-}
-
//convert a variant from string type to another animatable type
-void QmlVariantAnimationPrivate::convertVariant(QVariant &variant, QVariant::Type type)
+void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type)
{
if (variant.type() != QVariant::String) {
- variant.convert(type);
+ if ((uint)type < QVariant::UserType)
+ variant.convert((QVariant::Type)type);
return;
}
@@ -1946,15 +1474,20 @@ void QmlVariantAnimationPrivate::convertVariant(QVariant &variant, QVariant::Typ
break;
}
default:
- variant.convert(type);
+ if ((uint)type >= QVariant::UserType) {
+ QmlMetaType::StringConverter converter = QmlMetaType::customStringConverter(type);
+ if (converter)
+ variant = converter(variant.toString());
+ } else
+ variant.convert((QVariant::Type)type);
break;
}
}
/*!
- \qmlclass VariantAnimation QmlVariantAnimation
+ \qmlclass PropertyAnimation QmlPropertyAnimation
\inherits Animation
- \brief The VariantAnimation allows you to animate changes in properties of type QVariant.
+ \brief The PropertyAnimation allows you to animate property changes.
Animate a size property over 200ms, from its current size to 20-by-20:
\code
@@ -1962,51 +1495,51 @@ void QmlVariantAnimationPrivate::convertVariant(QVariant &variant, QVariant::Typ
\endcode
*/
-QmlVariantAnimation::QmlVariantAnimation(QObject *parent)
-: QmlAbstractAnimation(*(new QmlVariantAnimationPrivate), parent)
+QmlPropertyAnimation::QmlPropertyAnimation(QObject *parent)
+: QmlAbstractAnimation(*(new QmlPropertyAnimationPrivate), parent)
{
- Q_D(QmlVariantAnimation);
+ Q_D(QmlPropertyAnimation);
d->init();
}
-QmlVariantAnimation::~QmlVariantAnimation()
+QmlPropertyAnimation::~QmlPropertyAnimation()
{
}
-void QmlVariantAnimationPrivate::init()
+void QmlPropertyAnimationPrivate::init()
{
- Q_Q(QmlVariantAnimation);
+ Q_Q(QmlPropertyAnimation);
va = new QmlTimeLineValueAnimator(q);
va->setStartValue(QVariant(0.0f));
va->setEndValue(QVariant(1.0f));
}
/*!
- \qmlproperty int VariantAnimation::duration
+ \qmlproperty int PropertyAnimation::duration
This property holds the duration of the transition, in milliseconds.
The default value is 250.
*/
/*!
- \property QmlVariantAnimation::duration
+ \property QmlPropertyAnimation::duration
\brief the duration of the transition, in milliseconds.
The default value is 250.
*/
-int QmlVariantAnimation::duration() const
+int QmlPropertyAnimation::duration() const
{
- Q_D(const QmlVariantAnimation);
+ Q_D(const QmlPropertyAnimation);
return d->va->duration();
}
-void QmlVariantAnimation::setDuration(int duration)
+void QmlPropertyAnimation::setDuration(int duration)
{
if (duration < 0) {
- qWarning("QmlVariantAnimation: Cannot set a duration of < 0");
+ qWarning("QmlPropertyAnimation: Cannot set a duration of < 0");
return;
}
- Q_D(QmlVariantAnimation);
+ Q_D(QmlPropertyAnimation);
if (d->va->duration() == duration)
return;
d->va->setDuration(duration);
@@ -2014,23 +1547,23 @@ void QmlVariantAnimation::setDuration(int duration)
}
/*!
- \qmlproperty real VariantAnimation::from
+ \qmlproperty real PropertyAnimation::from
This property holds the starting value.
If not set, then the value defined in the start state of the transition.
*/
/*!
- \property QmlVariantAnimation::from
+ \property QmlPropertyAnimation::from
\brief the starting value.
*/
-QVariant QmlVariantAnimation::from() const
+QVariant QmlPropertyAnimation::from() const
{
- Q_D(const QmlVariantAnimation);
+ Q_D(const QmlPropertyAnimation);
return d->from;
}
-void QmlVariantAnimation::setFrom(const QVariant &f)
+void QmlPropertyAnimation::setFrom(const QVariant &f)
{
- Q_D(QmlVariantAnimation);
+ Q_D(QmlPropertyAnimation);
if (d->fromIsDefined && f == d->from)
return;
d->from = f;
@@ -2039,23 +1572,23 @@ void QmlVariantAnimation::setFrom(const QVariant &f)
}
/*!
- \qmlproperty real VariantAnimation::to
+ \qmlproperty real PropertyAnimation::to
This property holds the ending value.
If not set, then the value defined in the end state of the transition.
*/
/*!
- \property QmlVariantAnimation::to
+ \property QmlPropertyAnimation::to
\brief the ending value.
*/
-QVariant QmlVariantAnimation::to() const
+QVariant QmlPropertyAnimation::to() const
{
- Q_D(const QmlVariantAnimation);
+ Q_D(const QmlPropertyAnimation);
return d->to;
}
-void QmlVariantAnimation::setTo(const QVariant &t)
+void QmlPropertyAnimation::setTo(const QVariant &t)
{
- Q_D(QmlVariantAnimation);
+ Q_D(QmlPropertyAnimation);
if (d->toIsDefined && t == d->to)
return;
d->to = t;
@@ -2064,28 +1597,71 @@ void QmlVariantAnimation::setTo(const QVariant &t)
}
/*!
- \qmlproperty string VariantAnimation::easing
- This property holds the easing curve used for the transition.
+ \qmlproperty string PropertyAnimation::easing
+ \brief the easing curve used for the transition.
+
+ Available values are:
- See NumericAnimation::easing for a full discussion of easing,
- and a list of available curves.
+ \list
+ \i \e easeNone - Easing equation function for a simple linear tweening, with no easing.
+ \i \e easeInQuad - Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity.
+ \i \e easeOutQuad - Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity.
+ \i \e easeInOutQuad - Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInQuad - Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeInCubic - Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity.
+ \i \e easeOutCubic - Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity.
+ \i \e easeInOutCubic - Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInCubic - Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeInQuart - Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity.
+ \i \e easeOutQuart - Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity.
+ \i \e easeInOutQuart - Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInQuart - Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeInQuint - Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity.
+ \i \e easeOutQuint - Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity.
+ \i \e easeInOutQuint - Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInQuint - Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeInSine - Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity.
+ \i \e easeOutSine - Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity.
+ \i \e easeInOutSine - Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInSine - Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeInExpo - Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity.
+ \i \e easeOutExpo - Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity.
+ \i \e easeInOutExpo - Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInExpo - Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity.
+ \i \e easeOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity.
+ \i \e easeInOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity. The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
+ \i \e easeOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out: decelerating from zero velocity. The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
+ \i \e easeInOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
+ \i \e easeOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity.
+ \i \e easeInOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity.
+ \i \e easeInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity.
+ \i \e easeInOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration.
+ \endlist
*/
/*!
- \property QmlVariantAnimation::easing
+ \property QmlPropertyAnimation::easing
\brief the easing curve to use.
\sa QEasingCurve
*/
-QString QmlVariantAnimation::easing() const
+QString QmlPropertyAnimation::easing() const
{
- Q_D(const QmlVariantAnimation);
+ Q_D(const QmlPropertyAnimation);
return d->easing;
}
-void QmlVariantAnimation::setEasing(const QString &e)
+void QmlPropertyAnimation::setEasing(const QString &e)
{
- Q_D(QmlVariantAnimation);
+ Q_D(QmlPropertyAnimation);
if (d->easing == e)
return;
@@ -2095,28 +1671,28 @@ void QmlVariantAnimation::setEasing(const QString &e)
}
/*!
- \qmlproperty string VariantAnimation::properties
+ \qmlproperty string PropertyAnimation::properties
This property holds the properties this animation should be applied to.
This is a comma-separated list of properties that should use
this animation when they change.
*/
/*!
- \property QmlVariantAnimation::properties
+ \property QmlPropertyAnimation::properties
\brief the properties this animation should be applied to
properties holds a copy separated list of properties that should use
this animation when they change.
*/
-QString QmlVariantAnimation::properties() const
+QString QmlPropertyAnimation::properties() const
{
- Q_D(const QmlVariantAnimation);
+ Q_D(const QmlPropertyAnimation);
return d->properties;
}
-void QmlVariantAnimation::setProperties(const QString &prop)
+void QmlPropertyAnimation::setProperties(const QString &prop)
{
- Q_D(QmlVariantAnimation);
+ Q_D(QmlPropertyAnimation);
if (d->properties == prop)
return;
@@ -2125,32 +1701,34 @@ void QmlVariantAnimation::setProperties(const QString &prop)
}
/*!
- \qmlproperty list<Item> VariantAnimation::filter
+ \qmlproperty list<Item> PropertyAnimation::filter
This property holds the items selected to be affected by this animation (all if not set).
\sa exclude
*/
-QList<QObject *> *QmlVariantAnimation::filter()
+QList<QObject *> *QmlPropertyAnimation::filter()
{
- Q_D(QmlVariantAnimation);
+ Q_D(QmlPropertyAnimation);
return &d->filter;
}
/*!
- \qmlproperty list<Item> VariantAnimation::exclude
+ \qmlproperty list<Item> PropertyAnimation::exclude
This property holds the items not to be affected by this animation.
\sa filter
*/
-QList<QObject *> *QmlVariantAnimation::exclude()
+QList<QObject *> *QmlPropertyAnimation::exclude()
{
- Q_D(QmlVariantAnimation);
+ Q_D(QmlPropertyAnimation);
return &d->exclude;
}
-void QmlVariantAnimationPrivate::valueChanged(qreal r)
+void QmlPropertyAnimationPrivate::valueChanged(qreal r)
{
if (!fromSourced) {
if (!fromIsDefined) {
from = property.read();
+ convertVariant(from, interpolatorType ? interpolatorType : property.propertyType());
+ //### check for invalid variant if using property type
}
fromSourced = true;
}
@@ -2158,28 +1736,34 @@ void QmlVariantAnimationPrivate::valueChanged(qreal r)
if (r == 1.) {
property.write(to);
} else {
- QVariant val = interpolateVariant(from, to, r);
- property.write(val);
+ if (interpolator)
+ property.write(interpolator(from.constData(), to.constData(), r));
}
}
-QAbstractAnimation *QmlVariantAnimation::qtAnimation()
+QAbstractAnimation *QmlPropertyAnimation::qtAnimation()
{
- Q_D(QmlVariantAnimation);
+ Q_D(QmlPropertyAnimation);
return d->va;
}
-void QmlVariantAnimation::prepare(QmlMetaProperty &p)
+void QmlPropertyAnimation::prepare(QmlMetaProperty &p)
{
- Q_D(QmlVariantAnimation);
+ Q_D(QmlPropertyAnimation);
if (d->userProperty.isNull)
d->property = p;
else
d->property = d->userProperty;
- d->convertVariant(d->to, (QVariant::Type)d->property.propertyType());
+ int propType = d->property.propertyType();
+ d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : propType);
if (d->fromIsDefined)
- d->convertVariant(d->from, (QVariant::Type)d->property.propertyType());
+ d->convertVariant(d->from, d->interpolatorType ? d->interpolatorType : propType);
+
+ if (!d->interpolatorType) {
+ //### check for invalid variants
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(propType);
+ }
d->fromSourced = false;
d->value.QmlTimeLineValue::setValue(0.);
@@ -2187,44 +1771,69 @@ void QmlVariantAnimation::prepare(QmlMetaProperty &p)
d->va->setFromSourcedValue(&d->fromSourced);
}
-void QmlVariantAnimation::transition(QmlStateActions &actions,
+void QmlPropertyAnimation::transition(QmlStateActions &actions,
QmlMetaProperties &modified,
TransitionDirection direction)
{
- Q_D(QmlVariantAnimation);
+ Q_D(QmlPropertyAnimation);
Q_UNUSED(direction);
- struct NTransitionData : public QmlTimeLineValue
+ struct PropertyUpdater : public QmlTimeLineValue
{
QmlStateActions actions;
+ int interpolatorType; //for Number/ColorAnimation
+ int prevInterpolatorType; //for generic
+ QVariantAnimation::Interpolator interpolator;
+ bool reverse;
void setValue(qreal v)
{
+ if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1
+ v = 1 - v;
QmlTimeLineValue::setValue(v);
for (int ii = 0; ii < actions.count(); ++ii) {
Action &action = actions[ii];
+ QmlBehaviour::_ignore = true;
if (v == 1.)
action.property.write(action.toValue);
else {
if (action.fromValue.isNull()) {
action.fromValue = action.property.read();
- /*if (action.fromValue.isNull())
- action.fromValue = QVariant(0.);*/ //XXX can we give a default value for any type?
+ if (interpolatorType)
+ QmlPropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType);
+ }
+ if (!interpolatorType) {
+ int propType = action.property.propertyType();
+ if (!prevInterpolatorType || prevInterpolatorType != propType) {
+ prevInterpolatorType = propType;
+ interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType);
+ }
}
- QVariant val = QmlVariantAnimationPrivate::interpolateVariant(action.fromValue, action.toValue, v);
- action.property.write(val);
+ if (interpolator)
+ action.property.write(interpolator(action.fromValue.constData(), action.toValue.constData(), v));
}
+ QmlBehaviour::_ignore = false;
}
}
};
- QStringList props = d->properties.split(QLatin1Char(','));
+ QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
for (int ii = 0; ii < props.count(); ++ii)
props[ii] = props.at(ii).trimmed();
if (!d->propertyName.isEmpty() && !props.contains(d->propertyName))
props.append(d->propertyName);
- NTransitionData *data = new NTransitionData;
+ bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false;
+
+ if (d->userProperty.isValid() && props.isEmpty() && !target()) {
+ props.append(d->userProperty.value.name());
+ d->target = d->userProperty.value.object();
+ }
+
+ PropertyUpdater *data = new PropertyUpdater;
+ data->interpolatorType = d->interpolatorType;
+ data->interpolator = d->interpolator;
+ data->reverse = direction == Backward ? true : false;
QSet<QObject *> objs;
for (int ii = 0; ii < actions.count(); ++ii) {
@@ -2232,10 +1841,15 @@ void QmlVariantAnimation::transition(QmlStateActions &actions,
QObject *obj = action.property.object();
QString propertyName = action.property.name();
-
- if ((d->filter.isEmpty() || d->filter.contains(obj)) &&
- (!d->exclude.contains(obj)) && props.contains(propertyName) &&
- (!target() || target() == obj)) {
+ QObject *sObj = action.specifiedObject;
+ QString sPropertyName = action.specifiedProperty;
+ bool same = (obj == sObj);
+
+ if ((d->filter.isEmpty() || d->filter.contains(obj) || (!same && d->filter.contains(sObj))) &&
+ (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
+ (props.contains(propertyName) || (!same && props.contains(sPropertyName))
+ || (useType && action.property.propertyType() == d->interpolatorType)) &&
+ (!target() || target() == obj || (!same && target() == sObj))) {
objs.insert(obj);
Action myAction = action;
@@ -2247,8 +1861,8 @@ void QmlVariantAnimation::transition(QmlStateActions &actions,
if (d->toIsDefined)
myAction.toValue = d->to;
- d->convertVariant(myAction.fromValue, (QVariant::Type)myAction.property.propertyType());
- d->convertVariant(myAction.toValue, (QVariant::Type)myAction.property.propertyType());
+ d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+ d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
modified << action.property;
@@ -2261,17 +1875,16 @@ void QmlVariantAnimation::transition(QmlStateActions &actions,
QObject *obj = target();
for (int jj = 0; jj < props.count(); ++jj) {
Action myAction;
- myAction.property = QmlMetaProperty(obj, props.at(jj));
+ myAction.property = d->createProperty(obj, props.at(jj));
+ if (!myAction.property.isValid())
+ continue;
if (d->fromIsDefined) {
- d->convertVariant(d->from, (QVariant::Type)myAction.property.propertyType());
+ d->convertVariant(d->from, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
myAction.fromValue = d->from;
}
-
- d->convertVariant(d->to, (QVariant::Type)myAction.property.propertyType());
+ d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
myAction.toValue = d->to;
- myAction.bv = 0;
- myAction.event = 0;
data->actions << myAction;
}
}
@@ -2283,7 +1896,6 @@ void QmlVariantAnimation::transition(QmlStateActions &actions,
}
}
-//XXX whats the best name for this? (just Animation?)
-QML_DEFINE_TYPE(QmlVariantAnimation,VariantAnimation)
+QML_DEFINE_TYPE(QmlPropertyAnimation,PropertyAnimation)
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlanimation.h b/src/declarative/util/qmlanimation.h
index 5ab9dda..91c1898 100644
--- a/src/declarative/util/qmlanimation.h
+++ b/src/declarative/util/qmlanimation.h
@@ -65,6 +65,7 @@ class QmlAbstractAnimation : public QmlPropertyValueSource, public QmlParserStat
Q_INTERFACES(QmlParserStatus)
Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
+ Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
Q_PROPERTY(bool finishPlaying READ finishPlaying WRITE setFinishPlaying NOTIFY finishPlayingChanged())
Q_PROPERTY(bool repeat READ repeat WRITE setRepeat NOTIFY repeatChanged)
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
@@ -78,11 +79,16 @@ public:
bool isRunning() const;
void setRunning(bool);
+ bool isPaused() const;
+ void setPaused(bool);
bool finishPlaying() const;
void setFinishPlaying(bool);
bool repeat() const;
void setRepeat(bool);
+ int currentTime();
+ void setCurrentTime(int);
+
QmlAnimationGroup *group() const;
void setGroup(QmlAnimationGroup *);
@@ -100,6 +106,7 @@ Q_SIGNALS:
void started();
void completed();
void runningChanged(bool);
+ void pausedChanged(bool);
void repeatChanged(bool);
void targetChanged(QObject *, const QString &);
void finishPlayingChanged(bool);
@@ -107,6 +114,8 @@ Q_SIGNALS:
public Q_SLOTS:
void restart();
void start();
+ void pause();
+ void resume();
void stop();
void complete();
@@ -125,8 +134,6 @@ private Q_SLOTS:
void timelineComplete();
};
-QML_DECLARE_TYPE(QmlAbstractAnimation)
-
class QmlPauseAnimationPrivate;
class QmlPauseAnimation : public QmlAbstractAnimation
{
@@ -147,56 +154,7 @@ Q_SIGNALS:
protected:
virtual QAbstractAnimation *qtAnimation();
- virtual void prepare(QmlMetaProperty &);
};
-QML_DECLARE_TYPE(QmlPauseAnimation)
-
-class QmlColorAnimationPrivate;
-class QmlColorAnimation : public QmlAbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlColorAnimation)
- Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
- Q_PROPERTY(QColor from READ from WRITE setFrom NOTIFY fromChanged)
- Q_PROPERTY(QColor to READ to WRITE setTo NOTIFY toChanged)
- Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged)
- Q_PROPERTY(QList<QObject *>* filter READ filter)
- Q_PROPERTY(QList<QObject *>* exclude READ exclude)
-
-public:
- QmlColorAnimation(QObject *parent=0);
- virtual ~QmlColorAnimation();
-
- int duration() const;
- void setDuration(int);
-
- QColor from() const;
- void setFrom(const QColor &);
-
- QColor to() const;
- void setTo(const QColor &);
-
- QString easing() const;
- void setEasing(const QString &);
-
- QList<QObject *> *filter();
-
- QList<QObject *> *exclude();
-
-protected:
- virtual void transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation();
- virtual void prepare(QmlMetaProperty &);
-
-Q_SIGNALS:
- void durationChanged(int);
- void fromChanged(const QColor &);
- void toChanged(const QColor &);
- void easingChanged(const QString &);
-};
-QML_DECLARE_TYPE(QmlColorAnimation)
class QmlRunScriptActionPrivate;
class QmlRunScriptAction : public QmlAbstractAnimation
@@ -224,7 +182,6 @@ Q_SIGNALS:
protected:
virtual QAbstractAnimation *qtAnimation();
};
-QML_DECLARE_TYPE(QmlRunScriptAction)
class QmlSetPropertyActionPrivate;
class QmlSetPropertyAction : public QmlAbstractAnimation
@@ -261,7 +218,6 @@ protected:
virtual QAbstractAnimation *qtAnimation();
virtual void prepare(QmlMetaProperty &);
};
-QML_DECLARE_TYPE(QmlSetPropertyAction)
class QmlParentChangeActionPrivate;
class QmlParentChangeAction : public QmlAbstractAnimation
@@ -282,34 +238,33 @@ protected:
virtual QAbstractAnimation *qtAnimation();
virtual void prepare(QmlMetaProperty &);
};
-QML_DECLARE_TYPE(QmlParentChangeAction)
-class QmlNumericAnimationPrivate;
-class QmlNumericAnimation : public QmlAbstractAnimation
+class QmlPropertyAnimationPrivate;
+class QmlPropertyAnimation : public QmlAbstractAnimation
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QmlNumericAnimation)
+ Q_DECLARE_PRIVATE(QmlPropertyAnimation)
Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
- Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
- Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
+ Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged)
+ Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged)
Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged)
Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
Q_PROPERTY(QList<QObject *>* filter READ filter)
Q_PROPERTY(QList<QObject *>* exclude READ exclude)
public:
- QmlNumericAnimation(QObject *parent=0);
- virtual ~QmlNumericAnimation();
+ QmlPropertyAnimation(QObject *parent=0);
+ virtual ~QmlPropertyAnimation();
int duration() const;
void setDuration(int);
- qreal from() const;
- void setFrom(qreal);
+ QVariant from() const;
+ void setFrom(const QVariant &);
- qreal to() const;
- void setTo(qreal);
+ QVariant to() const;
+ void setTo(const QVariant &);
QString easing() const;
void setEasing(const QString &);
@@ -329,19 +284,48 @@ protected:
Q_SIGNALS:
void durationChanged(int);
- void fromChanged(qreal);
- void toChanged(qreal);
+ void fromChanged(QVariant);
+ void toChanged(QVariant);
void easingChanged(const QString &);
void propertiesChanged(const QString &);
};
-QML_DECLARE_TYPE(QmlNumericAnimation)
-#if 0
-class QmlDiscreteAnimation : public QmlAbstractAnimation
+class QmlColorAnimation : public QmlPropertyAnimation
{
-Q_OBJECT
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QmlPropertyAnimation)
+ Q_PROPERTY(QColor from READ from WRITE setFrom NOTIFY fromChanged)
+ Q_PROPERTY(QColor to READ to WRITE setTo NOTIFY toChanged)
+
+public:
+ QmlColorAnimation(QObject *parent=0);
+ virtual ~QmlColorAnimation();
+
+ QColor from() const;
+ void setFrom(const QColor &);
+
+ QColor to() const;
+ void setTo(const QColor &);
+};
+
+class QmlNumberAnimation : public QmlPropertyAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QmlPropertyAnimation)
+
+ Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
+ Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
+
+public:
+ QmlNumberAnimation(QObject *parent=0);
+ virtual ~QmlNumberAnimation();
+
+ qreal from() const;
+ void setFrom(qreal);
+
+ qreal to() const;
+ void setTo(qreal);
};
-#endif
class QmlAnimationGroupPrivate;
class QmlAnimationGroup : public QmlAbstractAnimation
@@ -375,7 +359,6 @@ protected:
virtual QAbstractAnimation *qtAnimation();
virtual void prepare(QmlMetaProperty &);
};
-QML_DECLARE_TYPE(QmlSequentialAnimation)
class QmlParallelAnimation : public QmlAnimationGroup
{
@@ -393,62 +376,20 @@ protected:
virtual QAbstractAnimation *qtAnimation();
virtual void prepare(QmlMetaProperty &);
};
-QML_DECLARE_TYPE(QmlParallelAnimation)
-
-class QmlVariantAnimationPrivate;
-class QmlVariantAnimation : public QmlAbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlVariantAnimation)
-
- Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
- Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged)
- Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged)
- Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged)
- Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QList<QObject *>* filter READ filter)
- Q_PROPERTY(QList<QObject *>* exclude READ exclude)
-
-public:
- QmlVariantAnimation(QObject *parent=0);
- virtual ~QmlVariantAnimation();
-
- int duration() const;
- void setDuration(int);
-
- QVariant from() const;
- void setFrom(const QVariant &);
-
- QVariant to() const;
- void setTo(const QVariant &);
-
- QString easing() const;
- void setEasing(const QString &);
-
- QString properties() const;
- void setProperties(const QString &);
-
- QList<QObject *> *filter();
- QList<QObject *> *exclude();
-
-protected:
- virtual void transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation();
- virtual void prepare(QmlMetaProperty &);
-
-Q_SIGNALS:
- void durationChanged(int);
- void fromChanged(QVariant);
- void toChanged(QVariant);
- void easingChanged(const QString &);
- void propertiesChanged(const QString &);
-};
-QML_DECLARE_TYPE(QmlVariantAnimation)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlAbstractAnimation)
+QML_DECLARE_TYPE(QmlPauseAnimation)
+QML_DECLARE_TYPE(QmlRunScriptAction)
+QML_DECLARE_TYPE(QmlSetPropertyAction)
+QML_DECLARE_TYPE(QmlParentChangeAction)
+QML_DECLARE_TYPE(QmlPropertyAnimation)
+QML_DECLARE_TYPE(QmlColorAnimation)
+QML_DECLARE_TYPE(QmlNumberAnimation)
+QML_DECLARE_TYPE(QmlSequentialAnimation)
+QML_DECLARE_TYPE(QmlParallelAnimation)
+
QT_END_HEADER
#endif // QMLANIMATION_H
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index e5a7384..87d480f 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -42,6 +42,17 @@
#ifndef QMLANIMATION_P_H
#define QMLANIMATION_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <private/qobject_p.h>
#include <private/qmlnullablevalue_p.h>
#include <private/qvariantanimation_p.h>
@@ -52,7 +63,7 @@
#include <QtDeclarative/qmlanimation.h>
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qmlcontext.h>
-#include <QtDeclarative/qmltimelinevalueproxy.h>
+#include <private/qmltimeline_p.h>
QT_BEGIN_NAMESPACE
@@ -172,11 +183,12 @@ class QmlAbstractAnimationPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QmlAbstractAnimation)
public:
QmlAbstractAnimationPrivate()
- : running(false), finishPlaying(false), repeat(false),
+ : running(false), paused(false), finishPlaying(false), repeat(false),
connectedTimeLine(false), componentComplete(true), startOnCompletion(false),
target(0), group(0) {}
bool running;
+ bool paused;
bool finishPlaying;
bool repeat;
bool connectedTimeLine;
@@ -192,6 +204,8 @@ public:
QmlMetaProperty property;
QmlAnimationGroup *group;
+
+ QmlMetaProperty createProperty(QObject *obj, const QString &str);
};
class QmlPauseAnimationPrivate : public QmlAbstractAnimationPrivate
@@ -206,40 +220,6 @@ public:
QPauseAnimation *pa;
};
-class QmlColorAnimationPrivate : public QmlAbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QmlColorAnimation)
-public:
- QmlColorAnimationPrivate()
- : QmlAbstractAnimationPrivate(), fromSourced(false), fromIsDefined(false), toIsDefined(false),
- ca(0), value(this, &QmlColorAnimationPrivate::valueChanged)
- {
- if (!colorInterpolator)
- colorInterpolator = QVariantAnimationPrivate::getInterpolator(QVariant::Color);
- }
-
- void init();
-
- QString easing;
-
- QColor fromValue;
- QColor toValue;
-
- QList<QObject *> filter;
- QList<QObject *> exclude;
-
- bool fromSourced;
- bool fromIsDefined;
- bool toIsDefined;
-
- QmlTimeLineValueAnimator *ca;
- virtual void valueChanged(qreal);
-
- QmlTimeLineValueProxy<QmlColorAnimationPrivate> value;
-
- static QVariantAnimation::Interpolator colorInterpolator;
-};
-
class QmlRunScriptActionPrivate : public QmlAbstractAnimationPrivate
{
Q_DECLARE_PUBLIC(QmlRunScriptAction)
@@ -294,32 +274,6 @@ public:
QActionAnimation *cpa;
};
-class QmlNumericAnimationPrivate : public QmlAbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QmlNumericAnimation)
-public:
- QmlNumericAnimationPrivate()
- : QmlAbstractAnimationPrivate(), fromSourced(false), na(0), value(this, &QmlNumericAnimationPrivate::valueChanged) {}
-
- void init();
-
- QmlNullableValue<qreal> from;
- QmlNullableValue<qreal> to;
-
- QString easing;
-
- QString properties;
- QList<QObject *> filter;
- QList<QObject *> exclude;
-
- bool fromSourced;
- qreal fromValue;
- QmlTimeLineValueAnimator *na;
- virtual void valueChanged(qreal);
-
- QmlTimeLineValueProxy<QmlNumericAnimationPrivate> value;
-};
-
class QmlAnimationGroupPrivate : public QmlAbstractAnimationPrivate
{
Q_DECLARE_PUBLIC(QmlAnimationGroup)
@@ -359,13 +313,14 @@ public:
QAnimationGroup *ag;
};
-class QmlVariantAnimationPrivate : public QmlAbstractAnimationPrivate
+class QmlPropertyAnimationPrivate : public QmlAbstractAnimationPrivate
{
- Q_DECLARE_PUBLIC(QmlVariantAnimation)
+ Q_DECLARE_PUBLIC(QmlPropertyAnimation)
public:
- QmlVariantAnimationPrivate()
+ QmlPropertyAnimationPrivate()
: QmlAbstractAnimationPrivate(), fromSourced(false), fromIsDefined(false), toIsDefined(false),
- va(0), value(this, &QmlVariantAnimationPrivate::valueChanged) {}
+ defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0),
+ value(this, &QmlPropertyAnimationPrivate::valueChanged) {}
void init();
@@ -381,16 +336,19 @@ public:
bool fromSourced;
bool fromIsDefined;
bool toIsDefined;
+ bool defaultToInterpolatorType;
+ int interpolatorType;
+ QVariantAnimation::Interpolator interpolator;
QmlTimeLineValueAnimator *va;
virtual void valueChanged(qreal);
- QmlTimeLineValueProxy<QmlVariantAnimationPrivate> value;
+ QmlTimeLineValueProxy<QmlPropertyAnimationPrivate> value;
static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress);
- static void convertVariant(QVariant &variant, QVariant::Type type);
+ static void convertVariant(QVariant &variant, int type);
};
-#endif // QMLANIMATION_P_H
-
QT_END_NAMESPACE
+
+#endif // QMLANIMATION_P_H
diff --git a/src/declarative/util/qmlbehaviour.cpp b/src/declarative/util/qmlbehaviour.cpp
deleted file mode 100644
index 3617541..0000000
--- a/src/declarative/util/qmlbehaviour.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qobject_p.h>
-#include "qmlanimation.h"
-#include "qmltransition.h"
-#include "qmlbehaviour.h"
-#include <QtDeclarative/qmlcontext.h>
-#include <QtCore/qparallelanimationgroup.h>
-
-QT_BEGIN_NAMESPACE
-
-QML_DEFINE_TYPE(QmlBehaviour,Behavior)
-
-class QmlBehaviourData : public QObject
-{
-Q_OBJECT
-public:
- QmlBehaviourData(QObject *parent)
- : QObject(parent) {}
-
- Q_PROPERTY(QVariant endValue READ endValue NOTIFY valuesChanged);
- Q_PROPERTY(QVariant startValue READ startValue NOTIFY valuesChanged);
- QVariant endValue() const { return e; }
- QVariant startValue() const { return s; }
-
- QVariant e;
- QVariant s;
-
-Q_SIGNALS:
- void valuesChanged();
-
-private:
- friend class QmlBehaviour;
-};
-
-class QmlBehaviourPrivate : public QObjectPrivate
-{
-public:
- QmlBehaviourPrivate()
- : context(0), valueData(0), operations(this) {}
- QmlMetaProperty property;
- QVariant currentValue;
-
- QVariant fromValue;
- QVariant toValue;
- QmlContext *context;
- QmlBehaviourData *valueData;
- class AnimationList : public QmlConcreteList<QmlAbstractAnimation *>
- {
- public:
- AnimationList(QmlBehaviourPrivate *parent) : _parent(parent) {}
- virtual void append(QmlAbstractAnimation *a)
- {
- QmlConcreteList<QmlAbstractAnimation *>::append(a);
- _parent->group->addAnimation(a->qtAnimation());
- if (_parent->property.isValid()) {
- a->setTarget(_parent->property);
- }
- }
- virtual void clear() { QmlConcreteList<QmlAbstractAnimation *>::clear(); } //###
- private:
- QmlBehaviourPrivate *_parent;
- };
- AnimationList operations;
- QParallelAnimationGroup *group;
-};
-
-/*!
- \qmlclass Behavior QmlBehaviour
- \brief The Behavior element allows you to specify a default animation for a property change.
-
- In example below, the rect will use a bounce easing curve over 200 millisecond for any changes to its y property:
- \code
- Rect {
- width: 20; height: 20
- color: "#00ff00"
- y: 200 //initial value
- y: Behavior {
- NumericAnimation {
- easing: "easeOutBounce(amplitude:100)"
- duration: 200
- }
- }
- }
- \endcode
-*/
-
-QmlBehaviour::QmlBehaviour(QObject *parent)
-: QmlPropertyValueSource(*(new QmlBehaviourPrivate), parent)
-{
- Q_D(QmlBehaviour);
- d->valueData = new QmlBehaviourData(this);
- d->group = new QParallelAnimationGroup(this);
-}
-
-/*!
- \qmlproperty QVariant Behavior::fromValue
- This property holds a selector specifying a starting value for the behavior
-
- If you only want the behavior to apply when the change starts at a
- specific value you can specify fromValue. This selector is used in conjunction
- with the toValue selector.
-*/
-
-QVariant QmlBehaviour::fromValue() const
-{
- Q_D(const QmlBehaviour);
- return d->fromValue;
-}
-
-void QmlBehaviour::setFromValue(const QVariant &v)
-{
- Q_D(QmlBehaviour);
- d->fromValue = v;
-}
-
-/*!
- \qmlproperty QVariant Behavior::toValue
- This property holds a selector specifying a ending value for the behavior
-
- If you only want the behavior to apply when the change ends at a
- specific value you can specify toValue. This selector is used in conjunction
- with the fromValue selector.
-*/
-
-QVariant QmlBehaviour::toValue() const
-{
- Q_D(const QmlBehaviour);
- return d->toValue;
-}
-
-void QmlBehaviour::setToValue(const QVariant &v)
-{
- Q_D(QmlBehaviour);
- d->toValue = v;
-}
-
-QmlList<QmlAbstractAnimation *>* QmlBehaviour::operations()
-{
- Q_D(QmlBehaviour);
- return &d->operations;
-}
-
-QmlBehaviour::~QmlBehaviour()
-{
- //### do we need any other cleanup here?
-}
-
-bool QmlBehaviour::_ignore = false;
-void QmlBehaviour::propertyValueChanged()
-{
- Q_D(QmlBehaviour);
- if (_ignore)
- return;
-
- QVariant newValue = d->property.read();
-
- if ((!fromValue().isValid() || fromValue() == d->currentValue) &&
- (!toValue().isValid() || toValue() == newValue)) {
-
- //### does this clean up everything needed?
- d->group->stop();
-
- d->valueData->e = newValue;
- d->valueData->s = d->currentValue;
- emit d->valueData->valuesChanged();
-
- QmlStateOperation::ActionList actions;
- Action action;
- action.property = d->property;
- action.fromValue = d->currentValue;
- action.toValue = newValue;
- actions << action;
-
- _ignore = true;
- d->property.write(d->currentValue);
-
- QList<QmlMetaProperty> after;
- for (int ii = 0; ii < d->operations.count(); ++ii) {
- d->operations.at(ii)->transition(actions, after, QmlAbstractAnimation::Forward);
- }
- d->group->start();
- if (!after.contains(d->property))
- d->property.write(newValue);
- _ignore = false;
- }
-
- d->currentValue = newValue;
-}
-
-void QmlBehaviour::setTarget(const QmlMetaProperty &property)
-{
- Q_D(QmlBehaviour);
- d->property = property;
- d->currentValue = property.read();
- d->property.connectNotifier(this, SLOT(propertyValueChanged()));
- for (int ii = 0; ii < d->operations.count(); ++ii) {
- d->operations.at(ii)->setTarget(property);
- }
-}
-
-void QmlBehaviour::classBegin()
-{
- Q_D(QmlBehaviour);
- if (!d->context) {
- d->context = new QmlContext(qmlContext(this), this);
- d->context->addDefaultObject(d->valueData);
- }
- d->context->activate();
-}
-
-void QmlBehaviour::classComplete()
-{
- Q_D(QmlBehaviour);
- d->context->deactivate();
-}
-
-#include "qmlbehaviour.moc"
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlbehaviour.h b/src/declarative/util/qmlbehaviour.h
deleted file mode 100644
index 7cc83b2..0000000
--- a/src/declarative/util/qmlbehaviour.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLBEHAVIOUR_H
-#define QMLBEHAVIOUR_H
-
-#include <QtDeclarative/qmlpropertyvaluesource.h>
-#include <QtDeclarative/qml.h>
-#include <QtDeclarative/qmlstate.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QmlAbstractAnimation;
-class QmlBehaviourPrivate;
-class Q_DECLARATIVE_EXPORT QmlBehaviour : public QmlPropertyValueSource,
- public QmlParserStatus
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlBehaviour)
- Q_INTERFACES(QmlParserStatus)
-
- Q_PROPERTY(QVariant from READ fromValue WRITE setFromValue)
- Q_PROPERTY(QVariant to READ toValue WRITE setToValue)
- Q_CLASSINFO("DefaultProperty", "operations")
- Q_PROPERTY(QmlList<QmlAbstractAnimation *>* operations READ operations)
-
-public:
- QmlBehaviour(QObject *parent=0);
- ~QmlBehaviour();
-
- QVariant fromValue() const;
- void setFromValue(const QVariant &);
- QVariant toValue() const;
- void setToValue(const QVariant &);
- virtual void setTarget(const QmlMetaProperty &);
-
- QmlList<QmlAbstractAnimation *>* operations();
-
- static bool _ignore;
-
-protected:
- virtual void classBegin();
- virtual void classComplete();
-
-private Q_SLOTS:
- void propertyValueChanged();
-};
-QML_DECLARE_TYPE(QmlBehaviour)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLBEHAVIOUR_H
diff --git a/src/declarative/util/qmlbind.cpp b/src/declarative/util/qmlbind.cpp
index b45d07d..bb342bc 100644
--- a/src/declarative/util/qmlbind.cpp
+++ b/src/declarative/util/qmlbind.cpp
@@ -52,6 +52,7 @@
#include "qmlbind.h"
QT_BEGIN_NAMESPACE
+
class QmlBindPrivate : public QObjectPrivate
{
public:
diff --git a/src/declarative/util/qmlbind.h b/src/declarative/util/qmlbind.h
index b7b77f2..731cdf8 100644
--- a/src/declarative/util/qmlbind.h
+++ b/src/declarative/util/qmlbind.h
@@ -82,10 +82,11 @@ public:
private:
void eval();
};
-QML_DECLARE_TYPE(QmlBind)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlBind)
+
QT_END_HEADER
#endif
diff --git a/src/declarative/util/qmlconnection.cpp b/src/declarative/util/qmlconnection.cpp
index 6c7b158..95f4573 100644
--- a/src/declarative/util/qmlconnection.cpp
+++ b/src/declarative/util/qmlconnection.cpp
@@ -46,8 +46,8 @@
#include <QtDeclarative/qmlcontext.h>
#include <QtCore/qdebug.h>
-
QT_BEGIN_NAMESPACE
+
class QmlConnectionPrivate : public QObjectPrivate
{
public:
diff --git a/src/declarative/util/qmlconnection.h b/src/declarative/util/qmlconnection.h
index d61659f..dcaac34 100644
--- a/src/declarative/util/qmlconnection.h
+++ b/src/declarative/util/qmlconnection.h
@@ -81,10 +81,11 @@ private:
void connectIfValid();
void componentComplete();
};
-QML_DECLARE_TYPE(QmlConnection)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlConnection)
+
QT_END_HEADER
#endif
diff --git a/src/declarative/util/qmldatetimeformatter.cpp b/src/declarative/util/qmldatetimeformatter.cpp
deleted file mode 100644
index ad0e473..0000000
--- a/src/declarative/util/qmldatetimeformatter.cpp
+++ /dev/null
@@ -1,368 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmldatetimeformatter.h"
-#include "private/qobject_p.h"
-#include <QtCore/qlocale.h>
-
-QT_BEGIN_NAMESPACE
-//TODO: may need optimisation as the QDateTime member may not be needed?
-// be able to set a locale?
-
-class QmlDateTimeFormatterPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlDateTimeFormatter)
-public:
- QmlDateTimeFormatterPrivate() : locale(QLocale::system()), longStyle(false), classComplete(true) {}
-
- void updateText();
-
- QDateTime dateTime;
- QDate date;
- QTime time;
- QLocale locale;
- QString dateTimeText;
- QString dateText;
- QString timeText;
- QString dateTimeFormat; //set for convienience?
- QString dateFormat;
- QString timeFormat;
- bool longStyle;
- bool classComplete;
-};
-
-/*!
- \qmlclass DateTimeFormatter QmlDateTimeFormatter
- \brief The DateTimeFormatter allows you to control the format of a date string.
-
- \code
- DateTimeFormatter { id: Formatter; date: System.date }
- Text { text: Formatter.dateText }
- \endcode
-
- By default, the text properties (dateText, timeText, and dateTimeText) will return the
- date and time using the current system locale's format.
-*/
-
-/*!
- \internal
- \class QmlDateTimeFormatter
- \ingroup group_utility
- \brief The QmlDateTimeFormatter class allows you to format a date string.
-*/
-
-QmlDateTimeFormatter::QmlDateTimeFormatter(QObject *parent)
-: QObject(*(new QmlDateTimeFormatterPrivate), parent)
-{
-}
-
-QmlDateTimeFormatter::~QmlDateTimeFormatter()
-{
-}
-
-/*!
- \qmlproperty string DateTimeFormatter::dateText
- \qmlproperty string DateTimeFormatter::timeText
- \qmlproperty string DateTimeFormatter::dateTimeText
-
- Formatted text representations of the \c date, \c time,
- and \c {date and time}, respectively.
-
- If there is no explictly specified format the DateTimeFormatter
- will use the system locale's default 'short' setting.
-
- \code
- // specify source date (assuming today is February 19, 2009)
- DateTimeFormatter { id: formatter; dateTime: Today.date }
-
- // display the full date and time
- Text { text: formatter.dateText }
- \endcode
-
- Would be equivalent to the following for a US English locale:
-
- \code
- // display the date
- Text { text: "2/19/09" }
- \endcode
-*/
-QString QmlDateTimeFormatter::dateTimeText() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->dateTimeText;
-}
-
-QString QmlDateTimeFormatter::dateText() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->dateText;
-}
-
-QString QmlDateTimeFormatter::timeText() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->timeText;
-}
-
-/*!
- \qmlproperty date DateTimeFormatter::date
- \qmlproperty time DateTimeFormatter::time
- \qmlproperty datetime DateTimeFormatter::dateTime
-
- The source date and time to be used by the formatter.
-
- \code
- // setting the date and time
- DateTimeFormatter { date: System.date; time: System.time }
- \endcode
-
- For convienience it is possible to set the datetime property to set both the date and the time.
- \code
- // setting the datetime
- DateTimeFormatter { dateTime: System.dateTime }
- \endcode
-
- There can only be one instance of date and time per formatter; if date, time, and dateTime are all
- set the actual date and time used is not guaranteed.
-
- \note If no date is set, dateTimeText will be just the date;
- If no time is set, the dateTimeText will be just the time.
-
-*/
-QDate QmlDateTimeFormatter::date() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->date;
-}
-
-QTime QmlDateTimeFormatter::time() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->time;
-}
-
-QDateTime QmlDateTimeFormatter::dateTime() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->dateTime;
-}
-
-/*!
- \qmlproperty string DateTimeFormatter::dateFormat
- \qmlproperty string DateTimeFormatter::timeFormat
- \qmlproperty string DateTimeFormatter::dateTimeFormat
-
- Specifies a custom format which the DateTime Formatter can use.
-
- If there is no explictly specified format the DateTimeFormatter
- will use the system locale's default 'short' setting.
-
- The text's format may be modified by setting:
- \list
- \i \c dateFormat
- \i \c timeFormat
- \i \c dateTimeFormat
- \endlist
-
- If only the format for date is defined, the time and dateTime formats will be defined
- as the system locale default and likewise for the others.
-
- Syntax for the format is based on the QDateTime::toString() formatting options.
-
- \code
- // Format the date such that the dateText is: '1997-12-12'
- DateTimeFormatter { id: formatter; dateTime: Today.dateTime; formatDate: "yyyy-MM-d" }
- \endcode
-
- Assigning an empty string to a particular format will reset it.
-*/
-QString QmlDateTimeFormatter::dateTimeFormat() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->dateTimeFormat;
-}
-
-QString QmlDateTimeFormatter::dateFormat() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->dateFormat;
-}
-
-QString QmlDateTimeFormatter::timeFormat() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->timeFormat;
-}
-
-/*!
- \qmlproperty bool DateTimeFormatter::longStyle
-
- This property causes the formatter to use the system locale's long format rather than short format
- by default.
-
- This setting is off by default.
-*/
-bool QmlDateTimeFormatter::longStyle() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->longStyle;
-}
-
-void QmlDateTimeFormatter::setDateTime(const QDateTime &dateTime)
-{
- Q_D(QmlDateTimeFormatter);
- if (d->dateTime == dateTime)
- return;
- d->dateTime = dateTime;
- d->date = d->dateTime.date();
- d->time = d->dateTime.time();
- d->updateText();
-}
-
-void QmlDateTimeFormatter::setTime(const QTime &time)
-{
- Q_D(QmlDateTimeFormatter);
- if (d->dateTime.time() == time)
- return;
- d->time = time;
- d->dateTime.setTime(time);
- d->updateText();
-}
-
-void QmlDateTimeFormatter::setDate(const QDate &date)
-{
- Q_D(QmlDateTimeFormatter);
- if (d->dateTime.date() == date)
- return;
- d->date = date;
- bool clearTime = d->dateTime.time().isValid() ? false : true; //because setting date generates default time
- d->dateTime.setDate(date);
- if (clearTime)
- d->dateTime.setTime(QTime());
- d->updateText();
-}
-
-//DateTime formatting may be a combination of date and time?
-void QmlDateTimeFormatter::setDateTimeFormat(const QString &format)
-{
- Q_D(QmlDateTimeFormatter);
- //no format checking
- d->dateTimeFormat = format;
- d->updateText();
-}
-
-void QmlDateTimeFormatter::setDateFormat(const QString &format)
-{
- Q_D(QmlDateTimeFormatter);
- //no format checking
- d->dateFormat = format;
- d->updateText();
-}
-
-void QmlDateTimeFormatter::setTimeFormat(const QString &format)
-{
- Q_D(QmlDateTimeFormatter);
- //no format checking
- d->timeFormat = format;
- d->updateText();
-}
-
-void QmlDateTimeFormatter::setLongStyle(bool longStyle)
-{
- Q_D(QmlDateTimeFormatter);
- d->longStyle = longStyle;
- d->updateText();
-}
-
-void QmlDateTimeFormatterPrivate::updateText()
-{
- Q_Q(QmlDateTimeFormatter);
- if (!classComplete)
- return;
-
- QString str;
- QString str1;
- QString str2;
-
- Qt::DateFormat defaultFormat = longStyle ? Qt::SystemLocaleLongDate : Qt::SystemLocaleShortDate;
-
- if (dateFormat.isEmpty())
- str1 = date.toString(defaultFormat);
- else
- str1 = date.toString(dateFormat);
-
- if (timeFormat.isEmpty())
- str2 = time.toString(defaultFormat);
- else
- str2 = time.toString(timeFormat);
-
- if (dateTimeFormat.isEmpty())
- str = dateTime.toString(defaultFormat);
- //else if (!formatTime.isEmpty() && !formatDate.isEmpty())
- // str = str1 + QLatin1Char(' ') + str2;
- else
- str = dateTime.toString(dateTimeFormat);
-
- if (dateTimeText == str && dateText == str1 && timeText == str2)
- return;
-
- dateTimeText = str;
- dateText = str1;
- timeText = str2;
-
- emit q->textChanged();
-}
-
-void QmlDateTimeFormatter::classBegin()
-{
- Q_D(QmlDateTimeFormatter);
- d->classComplete = false;
-}
-
-void QmlDateTimeFormatter::classComplete()
-{
- Q_D(QmlDateTimeFormatter);
- d->classComplete = true;
- d->updateText();
-}
-
-QML_DEFINE_TYPE(QmlDateTimeFormatter, DateTimeFormatter)
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmldatetimeformatter.h b/src/declarative/util/qmldatetimeformatter.h
deleted file mode 100644
index 84b27e3..0000000
--- a/src/declarative/util/qmldatetimeformatter.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLDATETIMEFORMATTER_H
-#define QMLDATETIMEFORMATTER_H
-
-#include <QtCore/qdatetime.h>
-#include <QtDeclarative/qml.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QmlDateTimeFormatterPrivate;
-class Q_DECLARATIVE_EXPORT QmlDateTimeFormatter : public QObject, public QmlParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QmlParserStatus)
-
- Q_PROPERTY(QString dateText READ dateText NOTIFY textChanged)
- Q_PROPERTY(QString timeText READ timeText NOTIFY textChanged)
- Q_PROPERTY(QString dateTimeText READ dateTimeText NOTIFY textChanged)
- Q_PROPERTY(QDate date READ date WRITE setDate)
- Q_PROPERTY(QTime time READ time WRITE setTime)
- Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime)
- Q_PROPERTY(QString dateFormat READ dateFormat WRITE setDateFormat)
- Q_PROPERTY(QString timeFormat READ timeFormat WRITE setTimeFormat)
- Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat)
- Q_PROPERTY(bool longStyle READ longStyle WRITE setLongStyle)
-public:
- QmlDateTimeFormatter(QObject *parent=0);
- ~QmlDateTimeFormatter();
-
- QString dateTimeText() const;
- QString dateText() const;
- QString timeText() const;
-
- QDate date() const;
- void setDate(const QDate &);
-
- QTime time() const;
- void setTime(const QTime &);
-
- QDateTime dateTime() const;
- void setDateTime(const QDateTime &);
-
- QString dateTimeFormat() const;
- void setDateTimeFormat(const QString &);
-
- QString dateFormat() const;
- void setDateFormat(const QString &);
-
- QString timeFormat() const;
- void setTimeFormat(const QString &);
-
- bool longStyle() const;
- void setLongStyle(bool);
-
- virtual void classBegin();
- virtual void classComplete();
-
-Q_SIGNALS:
- void textChanged();
-
-private:
- Q_DISABLE_COPY(QmlDateTimeFormatter)
- Q_DECLARE_PRIVATE(QmlDateTimeFormatter)
-};
-
-QML_DECLARE_TYPE(QmlDateTimeFormatter)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp
index d1ecac4..b8e6685 100644
--- a/src/declarative/util/qmlfollow.cpp
+++ b/src/declarative/util/qmlfollow.cpp
@@ -40,13 +40,14 @@
****************************************************************************/
#include <limits.h>
+#include <math.h>
#include <QtCore/qdebug.h>
#include "private/qobject_p.h"
#include "qmlfollow.h"
#include "private/qmlanimation_p.h"
-
QT_BEGIN_NAMESPACE
+
QML_DEFINE_TYPE(QmlFollow,Follow)
class QmlFollowPrivate : public QObjectPrivate
@@ -55,7 +56,7 @@ class QmlFollowPrivate : public QObjectPrivate
public:
QmlFollowPrivate()
: sourceValue(0), maxVelocity(0), lastTime(0)
- , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.005), enabled(true), mode(Track), clock(this) {}
+ , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.005), modulus(0.0), enabled(true), mode(Track), clock(this) {}
QmlMetaProperty property;
qreal currentValue;
@@ -68,6 +69,7 @@ public:
qreal damping;
qreal velocity;
qreal epsilon;
+ qreal modulus;
bool enabled;
enum Mode {
@@ -92,14 +94,25 @@ void QmlFollowPrivate::tick(int time)
int elapsed = time - lastTime;
if (!elapsed)
return;
+ qreal srcVal = sourceValue;
+ if (modulus != 0.0) {
+ currentValue = fmod(currentValue, modulus);
+ srcVal = fmod(srcVal, modulus);
+ }
if (mode == Spring) {
- if (elapsed < 10) // capped at 100fps.
+ if (elapsed < 16) // capped at 62fps.
return;
// Real men solve the spring DEs using RK4.
// We'll do something much simpler which gives a result that looks fine.
- int count = (elapsed+5) / 10;
+ int count = (elapsed+8) / 16;
for (int i = 0; i < count; ++i) {
- qreal diff = sourceValue - currentValue;
+ qreal diff = srcVal - currentValue;
+ if (modulus != 0.0 && qAbs(diff) > modulus / 2) {
+ if (diff < 0)
+ diff += modulus;
+ else
+ diff -= modulus;
+ }
velocity = velocity + spring * diff - damping * velocity;
// The following line supports mass. Not sure its worth the extra divisions.
// velocity = velocity + spring / mass * diff - damping / mass * velocity;
@@ -110,25 +123,40 @@ void QmlFollowPrivate::tick(int time)
else if (velocity < -maxVelocity)
velocity = -maxVelocity;
}
- currentValue += velocity * 10.0 / 1000.0;
+ currentValue += velocity * 16.0 / 1000.0;
+ if (modulus != 0.0) {
+ currentValue = fmod(currentValue, modulus);
+ if (currentValue < 0.0)
+ currentValue += modulus;
+ }
}
- if (qAbs(velocity) < epsilon && qAbs(sourceValue - currentValue) < epsilon) {
+ if (qAbs(velocity) < epsilon && qAbs(srcVal - currentValue) < epsilon) {
velocity = 0.0;
- currentValue = sourceValue;
+ currentValue = srcVal;
clock.stop();
}
- lastTime = time - (elapsed - count * 10);
+ lastTime = time - (elapsed - count * 16);
} else {
qreal moveBy = elapsed * velocityms;
- qreal diff = sourceValue - currentValue;
+ qreal diff = srcVal - currentValue;
+ if (modulus != 0.0 && qAbs(diff) > modulus / 2) {
+ if (diff < 0)
+ diff += modulus;
+ else
+ diff -= modulus;
+ }
if (diff > 0) {
currentValue += moveBy;
+ if (modulus != 0.0)
+ currentValue = fmod(currentValue, modulus);
if (currentValue > sourceValue) {
currentValue = sourceValue;
clock.stop();
}
} else {
currentValue -= moveBy;
+ if (modulus != 0.0 && currentValue < 0.0)
+ currentValue = fmod(currentValue, modulus) + modulus;
if (currentValue < sourceValue) {
currentValue = sourceValue;
clock.stop();
@@ -183,7 +211,7 @@ void QmlFollowPrivate::stop()
y: SequentialAnimation {
running: true
repeat: true
- NumericAnimation {
+ NumberAnimation {
to: 200
easing: "easeOutBounce(amplitude:100)"
duration: 2000
@@ -326,6 +354,25 @@ void QmlFollow::setEpsilon(qreal epsilon)
}
/*!
+ \qmlproperty qreal Follow::modulus
+ This property holds the modulus value.
+
+ Setting a \a modulus forces the target value to "wrap around" at the modulus.
+ For example, setting the modulus to 360 will cause a value of 370 to wrap around to 10.
+*/
+qreal QmlFollow::modulus() const
+{
+ Q_D(const QmlFollow);
+ return d->modulus;
+}
+
+void QmlFollow::setModulus(qreal modulus)
+{
+ Q_D(QmlFollow);
+ d->modulus = modulus;
+}
+
+/*!
\qmlproperty qreal Follow::followValue
The current value.
*/
diff --git a/src/declarative/util/qmlfollow.h b/src/declarative/util/qmlfollow.h
index 72d6df5..07e15e9 100644
--- a/src/declarative/util/qmlfollow.h
+++ b/src/declarative/util/qmlfollow.h
@@ -64,8 +64,10 @@ class Q_DECLARATIVE_EXPORT QmlFollow : public QmlPropertyValueSource,
Q_PROPERTY(qreal spring READ spring WRITE setSpring)
Q_PROPERTY(qreal damping READ damping WRITE setDamping)
Q_PROPERTY(qreal epsilon READ epsilon WRITE setEpsilon)
+ Q_PROPERTY(qreal modulus READ modulus WRITE setModulus)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
Q_PROPERTY(qreal followValue READ value NOTIFY valueChanged)
+ Q_PROPERTY(qreal modulus READ modulus WRITE setModulus NOTIFY modulusChanged)
public:
QmlFollow(QObject *parent=0);
@@ -83,6 +85,8 @@ public:
void setDamping(qreal damping);
qreal epsilon() const;
void setEpsilon(qreal epsilon);
+ qreal modulus() const;
+ void setModulus(qreal modulus);
bool enabled() const;
void setEnabled(bool enabled);
@@ -92,10 +96,10 @@ Q_SIGNALS:
void valueChanged(qreal);
};
-QML_DECLARE_TYPE(QmlFollow)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlFollow)
+
QT_END_HEADER
#endif // QFXFOLLOW_H
diff --git a/src/declarative/util/qmlfont.cpp b/src/declarative/util/qmlfont.cpp
index c537a83..3075b82 100644
--- a/src/declarative/util/qmlfont.cpp
+++ b/src/declarative/util/qmlfont.cpp
@@ -43,8 +43,8 @@
#include "qfont.h"
#include "qmlfont.h"
-
QT_BEGIN_NAMESPACE
+
class QmlFontPrivate : public QObjectPrivate
{
public:
@@ -144,4 +144,5 @@ QFont QmlFont::font() const
Q_D(const QmlFont);
return d->font;
}
+
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlfont.h b/src/declarative/util/qmlfont.h
index c4c86e2..e85b8d3 100644
--- a/src/declarative/util/qmlfont.h
+++ b/src/declarative/util/qmlfont.h
@@ -83,10 +83,11 @@ public:
Q_SIGNALS:
void updated();
};
-QML_DECLARE_TYPE(QmlFont)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlFont)
+
QT_END_HEADER
#endif // QMLFONT_H
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp
index cc85661..f5f76b0 100644
--- a/src/declarative/util/qmllistmodel.cpp
+++ b/src/declarative/util/qmllistmodel.cpp
@@ -49,6 +49,8 @@
#include <qmlbindablevalue.h>
#include "qmllistmodel.h"
+Q_DECLARE_METATYPE(QListModelInterface *)
+
QT_BEGIN_NAMESPACE
#define DATA_ROLE_ID 1
@@ -67,8 +69,6 @@ struct ListModelData
ListInstruction *instructions() const { return (ListInstruction *)((char *)this + sizeof(ListModelData)); }
};
-Q_DECLARE_METATYPE(QListModelInterface *)
-
/*!
\qmlclass ListModel
\brief The ListModel element defines a free-form list data source.
@@ -169,31 +169,6 @@ Q_DECLARE_METATYPE(QListModelInterface *)
*/
-struct ModelNode;
-class ListModel : public QListModelInterface
-{
- Q_OBJECT
-public:
- ListModel(QObject *parent=0);
-
- virtual QList<int> roles() const;
- virtual QString toString(int role) const;
- Q_PROPERTY(int count READ count)
- virtual int count() const;
- virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const;
-
-private:
- QVariant valueForNode(ModelNode *) const;
- mutable QStringList roleStrings;
- friend class ListModelParser;
- friend struct ModelNode;
-
- void checkRoles() const;
- void addRole(const QString &) const;
- mutable bool _rolesOk;
- ModelNode *_root;
-};
-
class ModelObject : public QObject
{
Q_OBJECT
@@ -220,9 +195,9 @@ struct ModelNode
QList<QVariant> values;
QHash<QString, ModelNode *> properties;
- ListModel *model() {
+ QmlListModel *model() {
if (!modelCache) {
- modelCache = new ListModel;
+ modelCache = new QmlListModel;
modelCache->_root = this;
}
return modelCache;
@@ -240,22 +215,25 @@ struct ModelNode
return objectCache;
}
- ListModel *modelCache;
+ QmlListModel *modelCache;
ModelObject *objectCache;
};
-Q_DECLARE_METATYPE(ModelNode *)
ModelObject::ModelObject(ModelNode *node)
: _node(node), _haveProperties(false), _mo(new QmlOpenMetaObject(this))
{
}
-ListModel::ListModel(QObject *parent)
+QmlListModel::QmlListModel(QObject *parent)
: QListModelInterface(parent), _rolesOk(false), _root(0)
{
}
-void ListModel::checkRoles() const
+QmlListModel::~QmlListModel()
+{
+}
+
+void QmlListModel::checkRoles() const
{
if (_rolesOk)
return;
@@ -271,13 +249,13 @@ void ListModel::checkRoles() const
_rolesOk = true;
}
-void ListModel::addRole(const QString &role) const
+void QmlListModel::addRole(const QString &role) const
{
if (!roleStrings.contains(role))
roleStrings << role;
}
-QList<int> ListModel::roles() const
+QList<int> QmlListModel::roles() const
{
checkRoles();
QList<int> rv;
@@ -286,7 +264,7 @@ QList<int> ListModel::roles() const
return rv;
}
-QString ListModel::toString(int role) const
+QString QmlListModel::toString(int role) const
{
checkRoles();
if (role < roleStrings.count())
@@ -295,7 +273,7 @@ QString ListModel::toString(int role) const
return QString();
}
-QVariant ListModel::valueForNode(ModelNode *node) const
+QVariant QmlListModel::valueForNode(ModelNode *node) const
{
QObject *rv = 0;
@@ -328,7 +306,7 @@ QVariant ListModel::valueForNode(ModelNode *node) const
return QVariant();
}
-QHash<int,QVariant> ListModel::data(int index, const QList<int> &roles) const
+QHash<int,QVariant> QmlListModel::data(int index, const QList<int> &roles) const
{
checkRoles();
QHash<int, QVariant> rv;
@@ -353,13 +331,13 @@ QHash<int,QVariant> ListModel::data(int index, const QList<int> &roles) const
return rv;
}
-int ListModel::count() const
+int QmlListModel::count() const
{
if (!_root) return 0;
return _root->values.count();
}
-class ListModelParser : public QmlCustomParser
+class QmlListModelParser : public QmlCustomParser
{
public:
QByteArray compile(const QList<QmlCustomParserProperty> &, bool *ok);
@@ -367,7 +345,7 @@ public:
void setCustomData(QObject *, const QByteArray &);
};
-bool ListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data)
+bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data)
{
QList<QVariant> values = prop.assignedValues();
for(int ii = 0; ii < values.count(); ++ii) {
@@ -434,7 +412,7 @@ bool ListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList
return true;
}
-QByteArray ListModelParser::compile(const QList<QmlCustomParserProperty> &customProps, bool *ok)
+QByteArray QmlListModelParser::compile(const QList<QmlCustomParserProperty> &customProps, bool *ok)
{
*ok = true;
QList<ListInstruction> instr;
@@ -471,9 +449,9 @@ QByteArray ListModelParser::compile(const QList<QmlCustomParserProperty> &custom
return rv;
}
-void ListModelParser::setCustomData(QObject *obj, const QByteArray &d)
+void QmlListModelParser::setCustomData(QObject *obj, const QByteArray &d)
{
- ListModel *rv = static_cast<ListModel *>(obj);
+ QmlListModel *rv = static_cast<QmlListModel *>(obj);
ModelNode *root = new ModelNode;
rv->_root = root;
@@ -519,16 +497,14 @@ void ListModelParser::setCustomData(QObject *obj, const QByteArray &d)
}
}
-QML_DECLARE_TYPE(ListModel)
-QML_DEFINE_CUSTOM_TYPE(ListModel, ListModel, ListModelParser)
+QML_DEFINE_CUSTOM_TYPE(QmlListModel, ListModel, QmlListModelParser)
// ### FIXME
-class ListElement : public QObject
+class QmlListElement : public QObject
{
Q_OBJECT
};
-QML_DECLARE_TYPE(ListElement)
-QML_DEFINE_TYPE(ListElement,ListElement)
+QML_DEFINE_TYPE(QmlListElement,ListElement)
static void dump(ModelNode *node, int ind)
{
@@ -567,4 +543,8 @@ ModelNode::~ModelNode()
}
QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(ModelNode *)
+QML_DECLARE_TYPE(QmlListElement)
+
#include "qmllistmodel.moc"
diff --git a/src/declarative/util/qmllistmodel.h b/src/declarative/util/qmllistmodel.h
index ddf1e13..39edbe4 100644
--- a/src/declarative/util/qmllistmodel.h
+++ b/src/declarative/util/qmllistmodel.h
@@ -51,16 +51,43 @@
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qlistmodelinterface.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+struct ModelNode;
+class QmlListModel : public QListModelInterface
+{
+ Q_OBJECT
+ Q_PROPERTY(int count READ count)
+
+public:
+ QmlListModel(QObject *parent=0);
+ ~QmlListModel();
+
+ virtual QList<int> roles() const;
+ virtual QString toString(int role) const;
+ virtual int count() const;
+ virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const;
+
+private:
+ QVariant valueForNode(ModelNode *) const;
+ mutable QStringList roleStrings;
+ friend class QmlListModelParser;
+ friend struct ModelNode;
+
+ void checkRoles() const;
+ void addRole(const QString &) const;
+ mutable bool _rolesOk;
+ ModelNode *_root;
+};
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlListModel)
+
QT_END_HEADER
#endif // QMLLISTMODEL_H
diff --git a/src/declarative/util/qmlnullablevalue_p.h b/src/declarative/util/qmlnullablevalue_p.h
index f16ddd6..6455642 100644
--- a/src/declarative/util/qmlnullablevalue_p.h
+++ b/src/declarative/util/qmlnullablevalue_p.h
@@ -42,6 +42,19 @@
#ifndef QMLNULLABLEVALUE_P_H
#define QMLNULLABLEVALUE_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
template<typename T>
struct QmlNullableValue
{
@@ -63,5 +76,6 @@ struct QmlNullableValue
T value;
};
-#endif // QMLNULLABLEVALUE_P_H
+QT_END_NAMESPACE
+#endif // QMLNULLABLEVALUE_P_H
diff --git a/src/declarative/util/qmlopenmetaobject.cpp b/src/declarative/util/qmlopenmetaobject.cpp
index d0dd817..7305362 100644
--- a/src/declarative/util/qmlopenmetaobject.cpp
+++ b/src/declarative/util/qmlopenmetaobject.cpp
@@ -43,7 +43,6 @@
#include "private/qmetaobjectbuilder_p.h"
#include <QDebug>
-
QT_BEGIN_NAMESPACE
class QmlOpenMetaObjectPrivate
diff --git a/src/declarative/util/qmlpackage.cpp b/src/declarative/util/qmlpackage.cpp
index e527c1f..eec769e 100644
--- a/src/declarative/util/qmlpackage.cpp
+++ b/src/declarative/util/qmlpackage.cpp
@@ -42,8 +42,8 @@
#include "private/qobject_p.h"
#include "qmlpackage.h"
-
QT_BEGIN_NAMESPACE
+
class QmlPackagePrivate : public QObjectPrivate
{
public:
@@ -150,4 +150,5 @@ QmlPackageAttached *QmlPackage::qmlAttachedProperties(QObject *o)
QML_DEFINE_TYPE(QmlPackage, Package)
QT_END_NAMESPACE
+
#include "qmlpackage.moc"
diff --git a/src/declarative/util/qmlpackage.h b/src/declarative/util/qmlpackage.h
index 9f1d94f..9f7a623 100644
--- a/src/declarative/util/qmlpackage.h
+++ b/src/declarative/util/qmlpackage.h
@@ -77,10 +77,11 @@ public:
static QmlPackageAttached *qmlAttachedProperties(QObject *);
};
-QML_DECLARE_TYPE(QmlPackage)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlPackage)
+
QT_END_HEADER
#endif // QMLPACKAGE_H
diff --git a/src/declarative/util/qmlscript.cpp b/src/declarative/util/qmlscript.cpp
index ab095b1..07cc1d5 100644
--- a/src/declarative/util/qmlscript.cpp
+++ b/src/declarative/util/qmlscript.cpp
@@ -55,7 +55,7 @@
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QtDeclarative/qmlinfo.h>
-#include <qfxperf.h>
+#include <private/qfxperf_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/util/qmlscript.h b/src/declarative/util/qmlscript.h
index 09ebc2c..4ba4f6b 100644
--- a/src/declarative/util/qmlscript.h
+++ b/src/declarative/util/qmlscript.h
@@ -47,6 +47,7 @@
#include <QtDeclarative/qml.h>
QT_BEGIN_HEADER
+
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
@@ -73,8 +74,11 @@ public:
private Q_SLOTS:
void replyFinished();
};
-QML_DECLARE_TYPE(QmlScript)
QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QmlScript)
+
QT_END_HEADER
+
#endif
diff --git a/src/declarative/util/qmlsetproperties.cpp b/src/declarative/util/qmlsetproperties.cpp
index cb97ed9..6464e33 100644
--- a/src/declarative/util/qmlsetproperties.cpp
+++ b/src/declarative/util/qmlsetproperties.cpp
@@ -47,9 +47,10 @@
#include <private/qmlcustomparser_p.h>
#include <private/qmlparser_p.h>
#include <QtDeclarative/qmlexpression.h>
-
+#include <QtDeclarative/qmlbindablevalue.h>
QT_BEGIN_NAMESPACE
+
/*!
\qmlclass SetProperties QmlSetProperties
\brief The SetProperties element describes new property values for a state.
@@ -113,7 +114,8 @@ class QmlSetPropertiesPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QmlSetProperties)
public:
- QmlSetPropertiesPrivate() : object(0), decoded(true), restore(true) {}
+ QmlSetPropertiesPrivate() : object(0), decoded(true), restore(true),
+ isExplicit(false) {}
QObject *object;
QByteArray data;
@@ -121,6 +123,7 @@ public:
void decode();
bool restore;
+ bool isExplicit;
QList<QPair<QByteArray, QVariant> > properties;
QList<QPair<QByteArray, QmlExpression *> > expressions;
@@ -205,6 +208,7 @@ QmlSetPropertiesParser::compile(const QList<QmlCustomParserProperty> &props,
void QmlSetPropertiesPrivate::decode()
{
+ Q_Q(QmlSetProperties);
if (decoded)
return;
@@ -221,7 +225,7 @@ void QmlSetPropertiesPrivate::decode()
ds >> data;
if (isScript) {
- QmlExpression *expression = new QmlExpression(qmlContext(object), data.toString(), object);
+ QmlExpression *expression = new QmlExpression(qmlContext(q), data.toString(), object);
expression->setTrackChange(false);
expressions << qMakePair(name, expression);
} else {
@@ -278,39 +282,19 @@ void QmlSetProperties::setRestoreEntryValues(bool v)
d->restore = v;
}
-QmlMetaProperty
-QmlSetPropertiesPrivate::property(const QByteArray &property)
+QmlMetaProperty
+QmlSetPropertiesPrivate::property(const QByteArray &property)
{
Q_Q(QmlSetProperties);
- QList<QByteArray> path = property.split('.');
-
- QObject *obj = this->object;
-
- for (int jj = 0; jj < path.count() - 1; ++jj) {
- const QByteArray &pathName = path.at(jj);
- QmlMetaProperty prop(obj, QLatin1String(pathName));
- QObject *objVal = QmlMetaType::toQObject(prop.read());
- if (!objVal) {
- qmlInfo(q) << obj->metaObject()->className()
- << "has no object property named" << pathName;
- return QmlMetaProperty();
- }
- obj = objVal;
- }
-
- const QByteArray &name = path.last();
- QmlMetaProperty prop(obj, QLatin1String(name));
+ QmlMetaProperty prop = QmlMetaProperty::createProperty(object, QString::fromLatin1(property));
if (!prop.isValid()) {
- qmlInfo(q) << obj->metaObject()->className()
- << "has no property named" << name;
+ qmlInfo(q) << "Cannot assign to non-existant property" << property;
return QmlMetaProperty();
} else if (!prop.isWritable()) {
- qmlInfo(q) << obj->metaObject()->className()
- << name << "is not writable, and cannot be set.";
+ qmlInfo(q) << "Cannot assign to read-only property" << property;
return QmlMetaProperty();
- } else {
- return prop;
}
+ return prop;
}
QmlSetProperties::ActionList QmlSetProperties::actions()
@@ -324,15 +308,12 @@ QmlSetProperties::ActionList QmlSetProperties::actions()
for (int ii = 0; ii < d->properties.count(); ++ii) {
QByteArray property = d->properties.at(ii).first;
- QmlMetaProperty prop = d->property(property);
- if (prop.isValid()) {
- Action a;
- a.restore = restoreEntryValues();
- a.property = prop;
- a.fromValue = a.property.read();
- a.toValue = d->properties.at(ii).second;
+ Action a(d->object, QString::fromLatin1(property),
+ d->properties.at(ii).second);
+ if (a.property.isValid()) {
+ a.restore = restoreEntryValues();
list << a;
}
}
@@ -347,16 +328,35 @@ QmlSetProperties::ActionList QmlSetProperties::actions()
a.restore = restoreEntryValues();
a.property = prop;
a.fromValue = a.property.read();
- a.toValue = d->expressions.at(ii).second->value();
+ a.specifiedObject = d->object;
+ a.specifiedProperty = QString::fromLatin1(property);
+
+ if (d->isExplicit) {
+ a.toValue = d->expressions.at(ii).second->value();
+ } else {
+ a.toBinding = new QmlBindableValue(d->expressions.at(ii).second->expression(), object(), qmlContext(this));
+ a.toBinding->setTarget(prop);
+ }
list << a;
}
-
}
return list;
}
+bool QmlSetProperties::isExplicit() const
+{
+ Q_D(const QmlSetProperties);
+ return d->isExplicit;
+}
+
+void QmlSetProperties::setIsExplicit(bool e)
+{
+ Q_D(QmlSetProperties);
+ d->isExplicit = e;
+}
+
QML_DEFINE_CUSTOM_TYPE(QmlSetProperties,SetProperties,QmlSetPropertiesParser)
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlsetproperties.h b/src/declarative/util/qmlsetproperties.h
index da5fcf2..3632816 100644
--- a/src/declarative/util/qmlsetproperties.h
+++ b/src/declarative/util/qmlsetproperties.h
@@ -44,7 +44,6 @@
#include <QtDeclarative/qmlstateoperations.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -59,6 +58,7 @@ class Q_DECLARATIVE_EXPORT QmlSetProperties : public QmlStateOperation
Q_PROPERTY(QObject *target READ object WRITE setObject)
Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues)
+ Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit);
public:
QmlSetProperties();
~QmlSetProperties();
@@ -69,12 +69,16 @@ public:
bool restoreEntryValues() const;
void setRestoreEntryValues(bool);
+ bool isExplicit() const;
+ void setIsExplicit(bool);
+
virtual ActionList actions();
};
-QML_DECLARE_TYPE(QmlSetProperties)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlSetProperties)
+
QT_END_HEADER
#endif // QMLSETPROPERTIES_H
diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp
index abe8301..e3cff38 100644
--- a/src/declarative/util/qmlstate.cpp
+++ b/src/declarative/util/qmlstate.cpp
@@ -53,10 +53,23 @@ QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
-Action::Action() : restore(true), bv(0), event(0), actionDone(false)
+Action::Action()
+: restore(true), actionDone(false), fromBinding(0), toBinding(0), event(0),
+ specifiedObject(0)
{
}
+Action::Action(QObject *target, const QString &propertyName,
+ const QVariant &value)
+: restore(true), actionDone(false), toValue(value), fromBinding(0),
+ toBinding(0), event(0), specifiedObject(target),
+ specifiedProperty(propertyName)
+{
+ property = QmlMetaProperty::createProperty(target, propertyName);
+ if (property.isValid())
+ fromValue = property.read();
+}
+
ActionEvent::~ActionEvent()
{
}
@@ -108,6 +121,8 @@ QML_DEFINE_TYPE(QmlState,State)
QmlState::QmlState(QObject *parent)
: QObject(*(new QmlStatePrivate), parent)
{
+ Q_D(QmlState);
+ d->transitionManager.setState(this);
}
QmlState::~QmlState()
@@ -234,33 +249,9 @@ QmlState &QmlState::operator<<(QmlStateOperation *op)
return *this;
}
-#if 0
-static void dump(const QmlStateOperation::ActionList &list)
-{
- if (!QString(getenv("STATE_DEBUG")).isEmpty())
- return;
-
- for (int ii = 0; ii < list.count(); ++ii) {
- const Action &action = list.at(ii);
- qWarning() << action.property.object << action.property.name << action.toValue;
- }
-}
-#endif
-
-void QmlStatePrivate::applyBindings()
-{
- foreach(const Action &action, bindingsList) {
- if (action.bv && !action.toBinding.isEmpty()) {
- action.bv->setExpression(action.toBinding);
- }
- }
-}
-
void QmlStatePrivate::complete()
{
Q_Q(QmlState);
- //apply bindings (now that all transitions are complete)
- applyBindings();
for (int ii = 0; ii < reverting.count(); ++ii) {
for (int jj = 0; jj < revertList.count(); ++jj) {
@@ -272,22 +263,19 @@ void QmlStatePrivate::complete()
}
reverting.clear();
- for (int ii = 0; ii < completeList.count(); ++ii) {
- const QmlMetaProperty &prop = completeList.at(ii).property;
- prop.write(completeList.at(ii).value);
- }
-
- completeList.clear();
- transition = 0;
emit q->completed();
}
-QmlStateOperation::ActionList QmlStatePrivate::generateActionList(QmlStateGroup *group) const
+// Generate a list of actions for this state. This includes coelescing state
+// actions that this state "extends"
+QmlStateOperation::ActionList
+QmlStatePrivate::generateActionList(QmlStateGroup *group) const
{
QmlStateOperation::ActionList applyList;
if (inState)
return applyList;
+ // Prevent "extends" recursion
inState = true;
if (!extends.isEmpty()) {
@@ -319,9 +307,15 @@ void QmlState::setStateGroup(QmlStateGroup *group)
void QmlState::cancel()
{
Q_D(QmlState);
- if (d->transition) {
- d->transition->stop(); //XXX this could potentially trigger a complete in rare circumstances
- d->transition = 0;
+ d->transitionManager.cancel();
+}
+
+void Action::deleteFromBinding()
+{
+ if (fromBinding) {
+ property.setBinding(0);
+ delete fromBinding;
+ fromBinding = 0;
}
}
@@ -334,29 +328,56 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever
revert->cancel();
d->revertList.clear();
d->reverting.clear();
- d->bindingsList.clear();
- if (revert)
- d->revertList = static_cast<QmlStatePrivate*>(revert->d_ptr)->revertList;
- QmlStateOperation::RevertActionList additionalReverts;
+ if (revert) {
+ QmlStatePrivate *revertPrivate =
+ static_cast<QmlStatePrivate*>(revert->d_ptr);
+ d->revertList = revertPrivate->revertList;
+ revertPrivate->revertList.clear();
+ }
+ // List of actions caused by this state
QmlStateOperation::ActionList applyList = d->generateActionList(group);
+ // List of actions that need to be reverted to roll back (just) this state
+ QmlStatePrivate::SimpleActionList additionalReverts;
+ // First add the reverse of all the applyList actions
for (int ii = 0; ii < applyList.count(); ++ii) {
- const Action &action = applyList.at(ii);
- if (action.event || !action.restore)
+ Action &action = applyList[ii];
+
+ if (action.event)
continue;
+ action.fromBinding = action.property.binding();
+
bool found = false;
- for (int jj = 0; !found && jj < d->revertList.count(); ++jj) {
- if (d->revertList.at(jj).property == action.property)
+ int jj;
+ for (jj = 0; jj < d->revertList.count(); ++jj) {
+ if (d->revertList.at(jj).property == action.property) {
found = true;
+ break;
+ }
}
+
if (!found) {
- RevertAction r(action);
- additionalReverts << r;
+ if (!action.restore) {
+ action.deleteFromBinding();
+ } else {
+ // Only need to revert the applyList action if the previous
+ // state doesn't have a higher priority revert already
+ SimpleAction r(action);
+ additionalReverts << r;
+ }
+ } else {
+
+ if (!found || d->revertList.at(jj).binding != action.fromBinding) {
+ action.deleteFromBinding();
+ }
}
}
+
+ // Any reverts from a previous state that aren't carried forth
+ // into this state need to be translated into apply actions
for (int ii = 0; ii < d->revertList.count(); ++ii) {
bool found = false;
for (int jj = 0; !found && jj < applyList.count(); ++jj) {
@@ -366,104 +387,35 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever
}
if (!found) {
QVariant cur = d->revertList.at(ii).property.read();
+ delete d->revertList.at(ii).property.setBinding(0);
+
Action a;
a.property = d->revertList.at(ii).property;
a.fromValue = cur;
a.toValue = d->revertList.at(ii).value;
a.toBinding = d->revertList.at(ii).binding;
- if (!a.toBinding.isEmpty()) {
- a.fromBinding = d->revertList.at(ii).bv->expression();
- a.bv = d->revertList.at(ii).bv;
- }
+ a.specifiedObject = d->revertList.at(ii).specifiedObject; //###
+ a.specifiedProperty = d->revertList.at(ii).specifiedProperty;
applyList << a;
+ // Store these special reverts in the reverting list
d->reverting << d->revertList.at(ii).property;
}
}
+ // All the local reverts now become part of the ongoing revertList
d->revertList << additionalReverts;
- //apply all changes, and work out any ending positions for bindings
- //then rewind all changes and proceed as normal
- //### 4 foreach loops!
- ////////////////////////////////////////////////////////////////////
- foreach(const Action &action, applyList) {
- if (stateChangeDebug())
- qWarning() << " Action:" << action.property.object() << action.property.name() << action.toValue;
-
- if (action.bv && !action.toBinding.isEmpty()) {
- d->bindingsList << action;
- action.bv->clearExpression();
- }
- }
-
- if (!d->bindingsList.isEmpty()) {
+ // Output for debugging
+ if (stateChangeDebug()) {
foreach(const Action &action, applyList) {
- if (action.bv && !action.toBinding.isEmpty()) {
- action.bv->setExpression(action.toBinding);
- } else if (!action.event) {
- action.property.write(action.toValue);
- }
- }
-
- for (int ii = 0; ii < applyList.size(); ++ii) {
- Action *action = &applyList[ii];
- if (action->event)
- continue;
-
- const QmlMetaProperty &prop = action->property;
- if (action->bv && !action->toBinding.isEmpty()) {
- action->toValue = prop.read();
- }
- }
-
- foreach(const Action &action, applyList) {
- if (action.event)
- continue;
-
- if (action.bv && !action.toBinding.isEmpty())
- action.bv->clearExpression();
- action.property.write(action.fromValue);
- }
- }
- ////////////////////////////////////////////////////////////////////
-
- QmlStateOperation::ActionList modList = applyList;
- QList<QmlMetaProperty> touched;
- d->completeList.clear();
- if (trans) {
- d->transition = trans;
- trans->prepare(modList, touched, this);
- for (int ii = 0; ii < modList.count(); ++ii) {
- const Action &action = modList.at(ii);
-
- if (action.event) {
- if (action.actionDone) {
- modList.removeAt(ii);
- --ii;
- }
- } else {
- if (action.toValue != action.fromValue) {
- d->completeList << RevertAction(action, false);
- }
-
- if (touched.contains(action.property)) {
- modList.removeAt(ii);
- --ii;
- }
- }
+ qWarning() << " Action:" << action.property.object()
+ << action.property.name() << action.toValue;
}
}
- foreach(const Action &action, modList) {
- if (action.event)
- action.event->execute();
- else
- action.property.write(action.toValue);
- }
- if (!trans)
- d->applyBindings(); //### merge into above foreach?
+ d->transitionManager.transition(applyList, trans);
}
-QML_DEFINE_TYPE(QmlStateOperation,StateOperation)
+QML_DEFINE_NOCREATE_TYPE(QmlStateOperation)
QmlStateOperation::ActionList QmlStateOperation::actions()
{
return ActionList();
diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h
index 0b8d82a..7532430 100644
--- a/src/declarative/util/qmlstate.h
+++ b/src/declarative/util/qmlstate.h
@@ -59,16 +59,23 @@ class Action
{
public:
Action();
+ Action(QObject *, const QString &, const QVariant &);
+
+ bool restore:1;
+ bool actionDone:1;
QmlMetaProperty property;
- bool restore;
QVariant fromValue;
QVariant toValue;
- QString fromBinding;
- QString toBinding;
- QmlBindableValue *bv;
+
+ QmlBindableValue *fromBinding;
+ QmlBindableValue *toBinding;
ActionEvent *event;
- bool actionDone;
+
+ QObject *specifiedObject;
+ QString specifiedProperty;
+
+ void deleteFromBinding();
};
class ActionEvent
@@ -79,28 +86,6 @@ public:
virtual void execute();
};
-class RevertAction
-{
-public:
- RevertAction(const Action &a, bool from = true) : bv(0)
- {
- property = a.property;
- if (from) {
- value = a.fromValue;
- binding = a.fromBinding;
- } else {
- value = a.toValue;
- binding = a.toBinding;
- }
- bv = a.bv;
- }
-
- QmlMetaProperty property;
- QVariant value;
- QString binding;
- QmlBindableValue *bv;
-};
-
class QmlStateGroup;
class Q_DECLARATIVE_EXPORT QmlStateOperation : public QObject
{
@@ -109,14 +94,12 @@ public:
QmlStateOperation(QObject *parent = 0)
: QObject(parent) {}
typedef QList<Action> ActionList;
- typedef QList<RevertAction> RevertActionList;
virtual ActionList actions();
protected:
QmlStateOperation(QObjectPrivate &dd, QObject *parent = 0);
};
-QML_DECLARE_TYPE(QmlStateOperation)
typedef QmlStateOperation::ActionList QmlStateActions;
@@ -166,10 +149,12 @@ private:
Q_DISABLE_COPY(QmlState)
friend class QmlTransitionPrivate;
};
-QML_DECLARE_TYPE(QmlState)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlStateOperation)
+QML_DECLARE_TYPE(QmlState)
+
QT_END_HEADER
#endif // QMLSTATE_H
diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h
index da8fdcd..414ec08 100644
--- a/src/declarative/util/qmlstate_p.h
+++ b/src/declarative/util/qmlstate_p.h
@@ -42,34 +42,72 @@
#ifndef QMLSTATE_P_H
#define QMLSTATE_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtDeclarative/qmlstate.h>
#include <private/qobject_p.h>
#include <private/qmlanimation_p.h>
+#include <private/qmltransitionmanager_p.h>
QT_BEGIN_NAMESPACE
+class SimpleAction
+{
+public:
+ enum State { StartState, EndState };
+ SimpleAction(const Action &a, State state = StartState)
+ {
+ property = a.property;
+ specifiedObject = a.specifiedObject;
+ specifiedProperty = a.specifiedProperty;
+ if (state == StartState) {
+ value = a.fromValue;
+ binding = property.binding();
+ } else {
+ value = a.toValue;
+ binding = a.toBinding;
+ }
+ }
+
+ QmlMetaProperty property;
+ QVariant value;
+ QmlBindableValue *binding;
+ QObject *specifiedObject;
+ QString specifiedProperty;
+};
+
class QmlStatePrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QmlState)
public:
QmlStatePrivate()
- : when(0), transition(0), inState(false), group(0) {}
+ : when(0), inState(false), group(0) {}
+
+ typedef QList<SimpleAction> SimpleActionList;
QString name;
QmlBindableValue *when;
QmlConcreteList<QmlStateOperation *> operations;
- QmlTransition *transition;
- QmlStateOperation::RevertActionList revertList;
+
+ QmlTransitionManager transitionManager;
+
+ SimpleActionList revertList;
QList<QmlMetaProperty> reverting;
- QmlStateOperation::RevertActionList completeList;
- QmlStateOperation::ActionList bindingsList;
QString extends;
mutable bool inState;
QmlStateGroup *group;
QmlStateOperation::ActionList generateActionList(QmlStateGroup *) const;
- void applyBindings();
void complete();
};
diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp
index 57ccd37..2b1cf7d 100644
--- a/src/declarative/util/qmlstategroup.cpp
+++ b/src/declarative/util/qmlstategroup.cpp
@@ -45,8 +45,8 @@
#include "qmltransition.h"
#include <QtCore/qdebug.h>
-
QT_BEGIN_NAMESPACE
+
DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
QML_DEFINE_TYPE(QmlStateGroup,StateGroup)
diff --git a/src/declarative/util/qmlstategroup.h b/src/declarative/util/qmlstategroup.h
index 237b60e..a817bd0 100644
--- a/src/declarative/util/qmlstategroup.h
+++ b/src/declarative/util/qmlstategroup.h
@@ -85,10 +85,11 @@ private:
friend class QmlState;
void updateAutoState();
};
-QML_DECLARE_TYPE(QmlStateGroup)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlStateGroup)
+
QT_END_HEADER
#endif // QMLSTATEGROUP_H
diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp
index 02b54f8..5bb2cb6 100644
--- a/src/declarative/util/qmlstateoperations.cpp
+++ b/src/declarative/util/qmlstateoperations.cpp
@@ -204,229 +204,4 @@ QmlRunScript::ActionList QmlRunScript::actions()
return rv;
}
-/*!
- \qmlclass SetProperty QmlSetProperty
- \brief The SetProperty element describes a new property value or binding for a state.
-
- The code below changes the position of the Rect depending upon
- the current state:
-
- \code
- Rect {
- id: myrect
- width: 50
- height: 50
- color: "red"
- }
-
- states: [
- State {
- name: "Position1"
- SetProperty {
- target: myrect
- property: "x"
- value: 150
- }
- SetProperty {
- target: myrect
- property: "y"
- value: 50
- }
- },
- State {
- name: "Position2"
- SetProperty {
- target: myrect
- property: "y"
- value: 200
- }
- }
- ]
- \endcode
-
- \sa SetProperties
-*/
-
-/*!
- \internal
- \class QmlSetProperty
- \brief The QmlSetProperty class describes a new property value or binding for a state.
-
- \ingroup group_states
-
- \sa QmlSetProperties
-*/
-
-class QmlSetPropertyPrivate : public QObjectPrivate
-{
-public:
- QmlSetPropertyPrivate() : obj(0) {}
-
- QObject *obj;
- QString prop;
- QVariant value;
- QString binding;
-};
-
-QML_DEFINE_TYPE(QmlSetProperty,SetProperty)
-
-QmlSetProperty::QmlSetProperty(QObject *parent)
- : QmlStateOperation(*(new QmlSetPropertyPrivate), parent)
-{
-}
-
-QmlSetProperty::~QmlSetProperty()
-{
-}
-
-/*!
- \qmlproperty Object SetProperty::target
- This property holds the object the property to change belongs to
-*/
-
-/*!
- \property QmlSetProperty::target
- \brief the object the property to change belongs to
-*/
-QObject *QmlSetProperty::object()
-{
- Q_D(QmlSetProperty);
- return d->obj;
-}
-
-void QmlSetProperty::setObject(QObject *o)
-{
- Q_D(QmlSetProperty);
- d->obj = o;
-}
-
-/*!
- \qmlproperty string SetProperty::property
- This property holds the name of the property to change
-*/
-
-/*!
- \property QmlSetProperty::property
- \brief the name of the property to change
-*/
-QString QmlSetProperty::property() const
-{
- Q_D(const QmlSetProperty);
- return d->prop;
-}
-
-void QmlSetProperty::setProperty(const QString &p)
-{
- Q_D(QmlSetProperty);
- d->prop = p;
-}
-
-/*!
- \qmlproperty variant SetProperty::value
- This property holds the value to assign to the property
-
- You should set either a \c value or a \c binding, but not both.
-*/
-
-/*!
- \property QmlSetProperty::value
- \brief the value to assign to the property
-
- You should set either a value or a binding, not both.
-*/
-QVariant QmlSetProperty::value() const
-{
- Q_D(const QmlSetProperty);
- return d->value;
-}
-
-void QmlSetProperty::setValue(const QVariant &v)
-{
- Q_D(QmlSetProperty);
- d->value = v;
-}
-
-/*!
- \qmlproperty string SetProperty::binding
- This property holds the binding to assign to the property
-
- You should set either a \c value or a \c binding, but not both.
-*/
-
-/*!
- \property QmlSetProperty::binding
- \brief the binding to assign to the property
-
- You should set either a value or a binding, not both.
-*/
-QString QmlSetProperty::binding() const
-{
- Q_D(const QmlSetProperty);
- return d->binding;
-}
-
-void QmlSetProperty::setBinding(const QString &binding)
-{
- Q_D(QmlSetProperty);
- d->binding = binding;
-}
-
-QmlSetProperty::ActionList QmlSetProperty::actions()
-{
- Q_D(QmlSetProperty);
- if (!d->obj)
- return ActionList();
-
- QObject *obj = d->obj;
- QString propName = d->prop;
-
- if (d->prop.contains(QLatin1Char('.'))) { //handle dot properties
- QStringList str = d->prop.split(QLatin1Char('.'));
- for (int ii = 0; ii < str.count()-1; ++ii) {
- const QString &s = str.at(ii);
- QmlMetaProperty prop(obj, s);
- if (!prop.isValid()) {
- qmlInfo(this) << obj->metaObject()->className()
- << "has no property named" << s;
- return ActionList();
- }
- QVariant v = prop.read();
- obj = QmlMetaType::toQObject(v);
- if (!obj) {
- qmlInfo(this) << "Unable to coerce value property"
- << s << "into a QObject";
- return ActionList();
- }
- }
- propName = str.last();
- }
-
- QmlMetaProperty prop(obj, propName);
- if (!prop.isValid()) {
- qmlInfo(this) << obj->metaObject()->className()
- << "has no property named" << propName;
- return ActionList();
- }else if (!prop.isWritable()){
- qmlInfo(this) << obj->metaObject()->className() << propName
- << "is not a writable property and cannot be set.";
- return ActionList();
- }
- QVariant cur = prop.read();
-
- Action a;
- a.property = prop;
- a.fromValue = cur;
- a.toValue = d->value;
- if (!d->binding.isEmpty()) {
- QmlBindableValue *bv = prop.binding();
- if (bv) {
- a.fromBinding = bv->expression();
- a.bv = bv;
- }
- }
- a.toBinding = d->binding;
-
- return ActionList() << a;
-}
-
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlstateoperations.h b/src/declarative/util/qmlstateoperations.h
index c7a6d42..221373b 100644
--- a/src/declarative/util/qmlstateoperations.h
+++ b/src/declarative/util/qmlstateoperations.h
@@ -70,7 +70,6 @@ public:
virtual ActionList actions();
};
-QML_DECLARE_TYPE(QmlParentChange)
class QmlRunScriptPrivate;
class Q_DECLARATIVE_EXPORT QmlRunScript : public QmlStateOperation, public ActionEvent
@@ -95,38 +94,12 @@ public:
virtual void execute();
};
-QML_DECLARE_TYPE(QmlRunScript)
-
-class QmlSetPropertyPrivate;
-class Q_DECLARATIVE_EXPORT QmlSetProperty : public QmlStateOperation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlSetProperty)
-
- Q_PROPERTY(QObject *target READ object WRITE setObject)
- Q_PROPERTY(QString property READ property WRITE setProperty)
- Q_PROPERTY(QVariant value READ value WRITE setValue)
- Q_PROPERTY(QString binding READ binding WRITE setBinding)
-
-public:
- QmlSetProperty(QObject *parent=0);
- ~QmlSetProperty();
-
- QObject *object();
- void setObject(QObject *);
- QString property() const;
- void setProperty(const QString &);
- QVariant value() const;
- void setValue(const QVariant &);
- QString binding() const;
- void setBinding(const QString&);
-
- virtual ActionList actions();
-};
-QML_DECLARE_TYPE(QmlSetProperty)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlParentChange)
+QML_DECLARE_TYPE(QmlRunScript)
+
QT_END_HEADER
#endif // QMLSTATEOPERATIONS_H
diff --git a/src/declarative/util/qmltimeline.cpp b/src/declarative/util/qmltimeline.cpp
new file mode 100644
index 0000000..5ba310d
--- /dev/null
+++ b/src/declarative/util/qmltimeline.cpp
@@ -0,0 +1,940 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmltimeline_p.h"
+#include <QDebug>
+#include <QMutex>
+#include <QThread>
+#include <QWaitCondition>
+#include <QEvent>
+#include <QCoreApplication>
+#include <QEasingCurve>
+#include <QTime>
+
+QT_BEGIN_NAMESPACE
+
+struct Update {
+ Update(QmlTimeLineValue *_g, qreal _v)
+ : g(_g), v(_v) {}
+ Update(const QmlTimeLineEvent &_e)
+ : g(0), v(0), e(_e) {}
+
+ QmlTimeLineValue *g;
+ qreal v;
+ QmlTimeLineEvent e;
+};
+
+struct QmlTimeLinePrivate
+{
+ QmlTimeLinePrivate(QmlTimeLine *);
+
+ struct Op {
+ enum Type {
+ Pause,
+ Set,
+ Move,
+ MoveBy,
+ Accel,
+ AccelDistance,
+ Execute
+ };
+ Op() {}
+ Op(Type t, int l, qreal v, qreal v2, int o,
+ const QmlTimeLineEvent &ev = QmlTimeLineEvent(), const QEasingCurve &es = QEasingCurve())
+ : type(t), length(l), value(v), value2(v2), order(o), event(ev),
+ easing(es) {}
+ Op(const Op &o)
+ : type(o.type), length(o.length), value(o.value), value2(o.value2),
+ order(o.order), event(o.event), easing(o.easing) {}
+ Op &operator=(const Op &o) {
+ type = o.type; length = o.length; value = o.value;
+ value2 = o.value2; order = o.order; event = o.event;
+ easing = o.easing;
+ return *this;
+ }
+
+ Type type;
+ int length;
+ qreal value;
+ qreal value2;
+
+ int order;
+ QmlTimeLineEvent event;
+ QEasingCurve easing;
+ };
+ struct TimeLine
+ {
+ TimeLine() : length(0), consumedOpLength(0), base(0.) {}
+ QList<Op> ops;
+ int length;
+ int consumedOpLength;
+ qreal base;
+ };
+
+ int length;
+ int syncPoint;
+ typedef QHash<QmlTimeLineObject *, TimeLine> Ops;
+ Ops ops;
+ QmlTimeLine *q;
+
+ void add(QmlTimeLineObject &, const Op &);
+ qreal value(const Op &op, int time, qreal base, bool *) const;
+
+ int advance(int);
+
+ bool clockRunning;
+ int prevTime;
+
+ int order;
+
+ QmlTimeLine::SyncMode syncMode;
+ int syncAdj;
+ QList<QPair<int, Update> > *updateQueue;
+};
+
+QmlTimeLinePrivate::QmlTimeLinePrivate(QmlTimeLine *parent)
+: length(0), syncPoint(0), q(parent), clockRunning(false), prevTime(0), order(0), syncMode(QmlTimeLine::LocalSync), syncAdj(0), updateQueue(0)
+{
+}
+
+void QmlTimeLinePrivate::add(QmlTimeLineObject &g, const Op &o)
+{
+ if (g._t && g._t != q) {
+ qWarning() << "QmlTimeLine: Cannot modify a QmlTimeLineValue owned by"
+ << "another timeline.";
+ return;
+ }
+ g._t = q;
+
+ Ops::Iterator iter = ops.find(&g);
+ if (iter == ops.end()) {
+ iter = ops.insert(&g, TimeLine());
+ if (syncPoint > 0)
+ q->pause(g, syncPoint);
+ }
+ if (!iter->ops.isEmpty() &&
+ o.type == Op::Pause &&
+ iter->ops.last().type == Op::Pause) {
+ iter->ops.last().length += o.length;
+ iter->length += o.length;
+ } else {
+ iter->ops.append(o);
+ iter->length += o.length;
+ }
+
+ if (iter->length > length)
+ length = iter->length;
+
+ if (!clockRunning) {
+ q->stop();
+ prevTime = 0;
+ clockRunning = true;
+
+ if (syncMode == QmlTimeLine::LocalSync) {
+ syncAdj = -1;
+ } else {
+ syncAdj = 0;
+ }
+ q->start();
+/* q->tick(0);
+ if (syncMode == QmlTimeLine::LocalSync) {
+ syncAdj = -1;
+ } else {
+ syncAdj = 0;
+ }
+ */
+ }
+}
+
+qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *changed) const
+{
+ Q_ASSERT(time >= 0);
+ Q_ASSERT(time <= op.length);
+ *changed = true;
+
+ switch(op.type) {
+ case Op::Pause:
+ *changed = false;
+ return base;
+ case Op::Set:
+ return op.value;
+ case Op::Move:
+ if (time == 0) {
+ return base;
+ } else if (time == (op.length)) {
+ return op.value;
+ } else {
+ qreal delta = op.value - base;
+ qreal pTime = (qreal)(time) / (qreal)op.length;
+ if (op.easing.type() == QEasingCurve::Linear)
+ return base + delta * pTime;
+ else
+ return base + delta * op.easing.valueForProgress(pTime);
+ }
+ case Op::MoveBy:
+ if (time == 0) {
+ return base;
+ } else if (time == (op.length)) {
+ return base + op.value;
+ } else {
+ qreal delta = op.value;
+ qreal pTime = (qreal)(time) / (qreal)op.length;
+ if (op.easing.type() == QEasingCurve::Linear)
+ return base + delta * pTime;
+ else
+ return base + delta * op.easing.valueForProgress(pTime);
+ }
+ case Op::Accel:
+ if (time == 0) {
+ return base;
+ } else {
+ qreal t = (qreal)(time) / 1000.0f;
+ qreal delta = op.value * t + 0.5f * op.value2 * t * t;
+ return base + delta;
+ }
+ case Op::AccelDistance:
+ if (time == 0) {
+ return base;
+ } else if (time == (op.length)) {
+ return base + op.value2;
+ } else {
+ qreal t = (qreal)(time) / 1000.0f;
+ qreal accel = -1.0f * 1000.0f * op.value / (qreal)op.length;
+ qreal delta = op.value * t + 0.5f * accel * t * t;
+ return base + delta;
+
+ }
+ case Op::Execute:
+ op.event.execute();
+ *changed = false;
+ return -1;
+ }
+
+ return base;
+}
+
+/*!
+ \internal
+ \class QmlTimeLine
+ \ingroup group_animation
+ \brief The QmlTimeLine class provides a timeline for controlling animations.
+
+ QmlTimeLine is similar to QTimeLine except:
+ \list
+ \i It updates QmlTimeLineValue instances directly, rather than maintaining a single
+ current value.
+
+ For example, the following animates a simple value over 200 milliseconds:
+ \code
+ QmlTimeLineValue v(<starting value>);
+ QmlTimeLine tl;
+ tl.move(v, 100., 200);
+ tl.start()
+ \endcode
+
+ If your program needs to know when values are changed, it can either
+ connect to the QmlTimeLine's updated() signal, or inherit from QmlTimeLineValue
+ and reimplement the QmlTimeLineValue::setValue() method.
+
+ \i Supports multiple QmlTimeLineValue, arbitrary start and end values and allows
+ animations to be strung together for more complex effects.
+
+ For example, the following animation moves the x and y coordinates of
+ an object from wherever they are to the position (100, 100) in 50
+ milliseconds and then further animates them to (100, 200) in 50
+ milliseconds:
+
+ \code
+ QmlTimeLineValue x(<starting value>);
+ QmlTimeLineValue y(<starting value>);
+
+ QmlTimeLine tl;
+ tl.start();
+
+ tl.move(x, 100., 50);
+ tl.move(y, 100., 50);
+ tl.move(y, 200., 50);
+ \endcode
+
+ \i All QmlTimeLine instances share a single, synchronized clock.
+
+ Actions scheduled within the same event loop tick are scheduled
+ synchronously against each other, regardless of the wall time between the
+ scheduling. Synchronized scheduling applies both to within the same
+ QmlTimeLine and across separate QmlTimeLine's within the same process.
+
+ \endlist
+
+ Currently easing functions are not supported.
+*/
+
+
+/*!
+ Construct a new QmlTimeLine with the specified \a parent.
+*/
+QmlTimeLine::QmlTimeLine(QObject *parent)
+: QAbstractAnimation(parent)
+{
+ d = new QmlTimeLinePrivate(this);
+}
+
+/*!
+ Destroys the time line. Any inprogress animations are canceled, but not
+ completed.
+*/
+QmlTimeLine::~QmlTimeLine()
+{
+ for (QmlTimeLinePrivate::Ops::Iterator iter = d->ops.begin();
+ iter != d->ops.end();
+ ++iter)
+ iter.key()->_t = 0;
+
+ delete d; d = 0;
+}
+
+/*!
+ \enum QmlTimeLine::SyncMode
+ */
+
+/*!
+ Return the timeline's synchronization mode.
+ */
+QmlTimeLine::SyncMode QmlTimeLine::syncMode() const
+{
+ return d->syncMode;
+}
+
+/*!
+ Set the timeline's synchronization mode to \a syncMode.
+ */
+void QmlTimeLine::setSyncMode(SyncMode syncMode)
+{
+ d->syncMode = syncMode;
+}
+
+/*!
+ Pause \a obj for \a time milliseconds.
+*/
+void QmlTimeLine::pause(QmlTimeLineObject &obj, int time)
+{
+ if (time <= 0) return;
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Pause, time, 0., 0., d->order++);
+ d->add(obj, op);
+}
+
+/*!
+ Execute the \a event.
+ */
+void QmlTimeLine::execute(const QmlTimeLineEvent &event)
+{
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, event);
+ d->add(*event.eventObject(), op);
+}
+
+/*!
+ Set the \a value of \a timeLineValue.
+*/
+void QmlTimeLine::set(QmlTimeLineValue &timeLineValue, qreal value)
+{
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Set, 0, value, 0., d->order++);
+ d->add(timeLineValue, op);
+}
+
+/*!
+ Decelerate \a timeLineValue from the starting \a velocity to zero at the
+ given \a acceleration rate. Although the \a acceleration is technically
+ a deceleration, it should always be positive. The QmlTimeLine will ensure
+ that the deceleration is in the opposite direction to the initial velocity.
+*/
+int QmlTimeLine::accel(QmlTimeLineValue &timeLineValue, qreal velocity, qreal acceleration)
+{
+ if ((velocity > 0.0f) == (acceleration > 0.0f))
+ acceleration = acceleration * -1.0f;
+
+ int time = static_cast<int>(-1000 * velocity / acceleration);
+
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++);
+ d->add(timeLineValue, op);
+
+ return time;
+}
+
+/*!
+ \overload
+
+ Decelerate \a timeLineValue from the starting \a velocity to zero at the
+ given \a acceleration rate over a maximum distance of maxDistance.
+
+ If necessary, QmlTimeLine will reduce the acceleration to ensure that the
+ entire operation does not require a move of more than \a maxDistance.
+ \a maxDistance should always be positive.
+*/
+int QmlTimeLine::accel(QmlTimeLineValue &timeLineValue, qreal velocity, qreal acceleration, qreal maxDistance)
+{
+ Q_ASSERT(acceleration >= 0.0f && maxDistance >= 0.0f);
+
+ qreal maxAccel = (velocity * velocity) / (2.0f * maxDistance);
+ if (maxAccel > acceleration)
+ acceleration = maxAccel;
+
+ if ((velocity > 0.0f) == (acceleration > 0.0f))
+ acceleration = acceleration * -1.0f;
+
+ int time = static_cast<int>(-1000 * velocity / acceleration);
+
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++);
+ d->add(timeLineValue, op);
+
+ return time;
+}
+
+/*!
+ Decelerate \a timeLineValue from the starting \a velocity to zero over the given
+ \a distance. This is like accel(), but the QmlTimeLine calculates the exact
+ deceleration to use.
+
+ \a distance should be positive.
+*/
+int QmlTimeLine::accelDistance(QmlTimeLineValue &timeLineValue, qreal velocity, qreal distance)
+{
+ if (distance == 0.0f || velocity == 0.0f)
+ return -1;
+ Q_ASSERT((distance >= 0.0f) == (velocity >= 0.0f));
+
+ int time = static_cast<int>(1000 * (2.0f * distance) / velocity);
+
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::AccelDistance, time, velocity, distance, d->order++);
+ d->add(timeLineValue, op);
+
+ return time;
+}
+
+/*!
+ Linearly change the \a timeLineValue from its current value to the given
+ \a destination value over \a time milliseconds.
+*/
+void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, int time)
+{
+ if (time <= 0) return;
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++);
+ d->add(timeLineValue, op);
+}
+
+/*!
+ Change the \a timeLineValue from its current value to the given \a destination
+ value over \a time milliseconds using the \a easing curve.
+ */
+void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, const QEasingCurve &easing, int time)
+{
+ if (time <= 0) return;
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QmlTimeLineEvent(), easing);
+ d->add(timeLineValue, op);
+}
+
+/*!
+ Linearly change the \a timeLineValue from its current value by the \a change amount
+ over \a time milliseconds.
+*/
+void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, int time)
+{
+ if (time <= 0) return;
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++);
+ d->add(timeLineValue, op);
+}
+
+/*!
+ Change the \a timeLineValue from its current value by the \a change amount over
+ \a time milliseconds using the \a easing curve.
+ */
+void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, const QEasingCurve &easing, int time)
+{
+ if (time <= 0) return;
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QmlTimeLineEvent(), easing);
+ d->add(timeLineValue, op);
+}
+
+/*!
+ Cancel (but don't complete) all scheduled actions for \a timeLineValue.
+*/
+void QmlTimeLine::reset(QmlTimeLineValue &timeLineValue)
+{
+ if (!timeLineValue._t)
+ return;
+ if (timeLineValue._t != this) {
+ qWarning() << "QmlTimeLine: Cannot reset a QmlTimeLineValue owned by another timeline.";
+ return;
+ }
+ remove(&timeLineValue);
+ timeLineValue._t = 0;
+}
+
+int QmlTimeLine::duration() const
+{
+ return -1;
+}
+
+/*!
+ Synchronize the end point of \a timeLineValue to the endpoint of \a syncTo
+ within this timeline.
+
+ Following operations on \a timeLineValue in this timeline will be scheduled after
+ all the currently scheduled actions on \a syncTo are complete. In
+ psuedo-code this is equivalent to:
+ \code
+ QmlTimeLine::pause(timeLineValue, min(0, length_of(syncTo) - length_of(timeLineValue)))
+ \endcode
+*/
+void QmlTimeLine::sync(QmlTimeLineValue &timeLineValue, QmlTimeLineValue &syncTo)
+{
+ QmlTimeLinePrivate::Ops::Iterator iter = d->ops.find(&syncTo);
+ if (iter == d->ops.end())
+ return;
+ int length = iter->length;
+
+ iter = d->ops.find(&timeLineValue);
+ if (iter == d->ops.end()) {
+ pause(timeLineValue, length);
+ } else {
+ int glength = iter->length;
+ pause(timeLineValue, length - glength);
+ }
+}
+
+/*!
+ Synchronize the end point of \a timeLineValue to the endpoint of the longest
+ action cursrently scheduled in the timeline.
+
+ In psuedo-code, this is equivalent to:
+ \code
+ QmlTimeLine::pause(timeLineValue, length_of(timeline) - length_of(timeLineValue))
+ \endcode
+*/
+void QmlTimeLine::sync(QmlTimeLineValue &timeLineValue)
+{
+ QmlTimeLinePrivate::Ops::Iterator iter = d->ops.find(&timeLineValue);
+ if (iter == d->ops.end()) {
+ pause(timeLineValue, d->length);
+ } else {
+ pause(timeLineValue, d->length - iter->length);
+ }
+}
+
+/*
+ Synchronize all currently and future scheduled values in this timeline to
+ the longest action currently scheduled.
+
+ For example:
+ \code
+ value1->setValue(0.);
+ value2->setValue(0.);
+ value3->setValue(0.);
+ QmlTimeLine tl;
+ ...
+ tl.move(value1, 10, 200);
+ tl.move(value2, 10, 100);
+ tl.sync();
+ tl.move(value2, 20, 100);
+ tl.move(value3, 20, 100);
+ \endcode
+
+ will result in:
+
+ \table
+ \header \o \o 0ms \o 50ms \o 100ms \o 150ms \o 200ms \o 250ms \o 300ms
+ \row \o value1 \o 0 \o 2.5 \o 5.0 \o 7.5 \o 10 \o 10 \o 10
+ \row \o value2 \o 0 \o 5.0 \o 10.0 \o 10.0 \o 10.0 \o 15.0 \o 20.0
+ \row \o value2 \o 0 \o 0 \o 0 \o 0 \o 0 \o 10.0 \o 20.0
+ \endtable
+*/
+
+/*void QmlTimeLine::sync()
+{
+ for (QmlTimeLinePrivate::Ops::Iterator iter = d->ops.begin();
+ iter != d->ops.end();
+ ++iter)
+ pause(*iter.key(), d->length - iter->length);
+ d->syncPoint = d->length;
+}*/
+
+/*!
+ \internal
+
+ Temporary hack.
+ */
+void QmlTimeLine::setSyncPoint(int sp)
+{
+ d->syncPoint = sp;
+}
+
+/*!
+ \internal
+
+ Temporary hack.
+ */
+int QmlTimeLine::syncPoint() const
+{
+ return d->syncPoint;
+}
+
+/*!
+ Returns true if the timeline is active. An active timeline is one where
+ QmlTimeLineValue actions are still pending.
+*/
+bool QmlTimeLine::isActive() const
+{
+ return !d->ops.isEmpty();
+}
+
+/*!
+ Completes the timeline. All queued actions are played to completion, and then discarded. For example,
+ \code
+ QmlTimeLineValue v(0.);
+ QmlTimeLine tl;
+ tl.move(v, 100., 1000.);
+ // 500 ms passes
+ // v.value() == 50.
+ tl.complete();
+ // v.value() == 100.
+ \endcode
+*/
+void QmlTimeLine::complete()
+{
+ d->advance(d->length);
+}
+
+/*!
+ Resets the timeline. All queued actions are discarded and QmlTimeLineValue's retain their current value. For example,
+ \code
+ QmlTimeLineValue v(0.);
+ QmlTimeLine tl;
+ tl.move(v, 100., 1000.);
+ // 500 ms passes
+ // v.value() == 50.
+ tl.clear();
+ // v.value() == 50.
+ \endcode
+*/
+void QmlTimeLine::clear()
+{
+ for (QmlTimeLinePrivate::Ops::ConstIterator iter = d->ops.begin(); iter != d->ops.end(); ++iter)
+ iter.key()->_t = 0;
+ d->ops.clear();
+ d->length = 0;
+ d->syncPoint = 0;
+ //XXX need stop here?
+}
+
+int QmlTimeLine::time() const
+{
+ return d->prevTime;
+}
+
+/*!
+ \fn void QmlTimeLine::updated()
+
+ Emitted each time the timeline modifies QmlTimeLineValues. Even if multiple
+ QmlTimeLineValues are changed, this signal is only emitted once for each clock tick.
+*/
+
+void QmlTimeLine::updateCurrentTime(int v)
+{
+ if (d->syncAdj == -1)
+ d->syncAdj = v;
+ v -= d->syncAdj;
+
+ int timeChanged = v - d->prevTime;
+#if 0
+ if (!timeChanged)
+ return;
+#endif
+ d->prevTime = v;
+ d->advance(timeChanged);
+ emit updated();
+
+ // Do we need to stop the clock?
+ if (d->ops.isEmpty()) {
+ stop();
+ d->prevTime = 0;
+ d->clockRunning = false;
+ emit completed();
+ } /*else if (pauseTime > 0) {
+ GfxClock::cancelClock();
+ d->prevTime = 0;
+ GfxClock::pauseFor(pauseTime);
+ d->syncAdj = 0;
+ d->clockRunning = false;
+ }*/ else if (/*!GfxClock::isActive()*/ state() != Running) {
+ stop();
+ d->prevTime = 0;
+ d->clockRunning = true;
+ d->syncAdj = 0;
+ start();
+ }
+}
+
+bool operator<(const QPair<int, Update> &lhs,
+ const QPair<int, Update> &rhs)
+{
+ return lhs.first < rhs.first;
+}
+
+int QmlTimeLinePrivate::advance(int t)
+{
+ int pauseTime = -1;
+
+ // XXX - surely there is a more efficient way?
+ do {
+ pauseTime = -1;
+ // Minimal advance time
+ int advanceTime = t;
+ for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ++iter) {
+ TimeLine &tl = *iter;
+ Op &op = tl.ops.first();
+ int length = op.length - tl.consumedOpLength;
+
+ if (length < advanceTime) {
+ advanceTime = length;
+ if (advanceTime == 0)
+ break;
+ }
+ }
+ t -= advanceTime;
+
+ // Process until then. A zero length advance time will only process
+ // sets.
+ QList<QPair<int, Update> > updates;
+
+ for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ) {
+ QmlTimeLineValue *v = static_cast<QmlTimeLineValue *>(iter.key());
+ TimeLine &tl = *iter;
+ Q_ASSERT(!tl.ops.isEmpty());
+
+ do {
+ Op &op = tl.ops.first();
+ if (advanceTime == 0 && op.length != 0)
+ continue;
+
+ if (tl.consumedOpLength == 0 &&
+ op.type != Op::Pause &&
+ op.type != Op::Execute)
+ tl.base = v->value();
+
+ if ((tl.consumedOpLength + advanceTime) == op.length) {
+ if (op.type == Op::Execute) {
+ updates << qMakePair(op.order, Update(op.event));
+ } else {
+ bool changed = false;
+ qreal val = value(op, op.length, tl.base, &changed);
+ if (changed)
+ updates << qMakePair(op.order, Update(v, val));
+ }
+ tl.length -= qMin(advanceTime, tl.length);
+ tl.consumedOpLength = 0;
+ tl.ops.removeFirst();
+ } else {
+ tl.consumedOpLength += advanceTime;
+ bool changed = false;
+ qreal val = value(op, tl.consumedOpLength, tl.base, &changed);
+ if (changed)
+ updates << qMakePair(op.order, Update(v, val));
+ tl.length -= qMin(advanceTime, tl.length);
+ break;
+ }
+
+ } while(!tl.ops.isEmpty() && advanceTime == 0 && tl.ops.first().length == 0);
+
+
+ if (tl.ops.isEmpty()) {
+ iter = ops.erase(iter);
+ v->_t = 0;
+ } else {
+ if (tl.ops.first().type == Op::Pause && pauseTime != 0) {
+ int opPauseTime = tl.ops.first().length - tl.consumedOpLength;
+ if (pauseTime == -1 || opPauseTime < pauseTime)
+ pauseTime = opPauseTime;
+ } else {
+ pauseTime = 0;
+ }
+ ++iter;
+ }
+ }
+
+ length -= qMin(length, advanceTime);
+ syncPoint -= advanceTime;
+
+ qSort(updates.begin(), updates.end());
+ updateQueue = &updates;
+ for (int ii = 0; ii < updates.count(); ++ii) {
+ const Update &v = updates.at(ii).second;
+ if (v.g)
+ v.g->setValue(v.v);
+ else
+ v.e.execute();
+ }
+ updateQueue = 0;
+ } while(t);
+
+ return pauseTime;
+}
+
+void QmlTimeLine::remove(QmlTimeLineObject *v)
+{
+ QmlTimeLinePrivate::Ops::Iterator iter = d->ops.find(v);
+ Q_ASSERT(iter != d->ops.end());
+
+ int len = iter->length;
+ d->ops.erase(iter);
+ if (len == d->length) {
+ // We need to recalculate the length
+ d->length = 0;
+ for (QmlTimeLinePrivate::Ops::Iterator iter = d->ops.begin();
+ iter != d->ops.end();
+ ++iter) {
+
+ if (iter->length > d->length)
+ d->length = iter->length;
+
+ }
+ }
+ if (d->ops.isEmpty()) {
+ stop();
+ d->clockRunning = false;
+ } else if (/*!GfxClock::isActive()*/ state() != Running) {
+ stop();
+ d->prevTime = 0;
+ d->clockRunning = true;
+
+ if (d->syncMode == QmlTimeLine::LocalSync) {
+ d->syncAdj = -1;
+ } else {
+ d->syncAdj = 0;
+ }
+ start();
+ }
+
+ if (d->updateQueue) {
+ for (int ii = 0; ii < d->updateQueue->count(); ++ii) {
+ if (d->updateQueue->at(ii).second.g == v ||
+ d->updateQueue->at(ii).second.e.eventObject() == v) {
+ d->updateQueue->removeAt(ii);
+ --ii;
+ }
+ }
+ }
+
+
+}
+
+/*!
+ \internal
+ \class QmlTimeLineValue
+ \ingroup group_animation
+ \brief The QmlTimeLineValue class provides a value that can be modified by QmlTimeLine.
+*/
+
+/*!
+ \fn QmlTimeLineValue::QmlTimeLineValue(qreal value = 0)
+
+ Construct a new QmlTimeLineValue with an initial \a value.
+*/
+
+/*!
+ \fn qreal QmlTimeLineValue::value() const
+
+ Return the current value.
+*/
+
+/*!
+ \fn void QmlTimeLineValue::setValue(qreal value)
+
+ Set the current \a value.
+*/
+
+/*!
+ \fn QmlTimeLine *QmlTimeLineValue::timeLine() const
+
+ If a QmlTimeLine is operating on this value, return a pointer to it,
+ otherwise return null.
+*/
+
+
+QmlTimeLineObject::QmlTimeLineObject()
+: _t(0)
+{
+}
+
+QmlTimeLineObject::~QmlTimeLineObject()
+{
+ if (_t) {
+ _t->remove(this);
+ _t = 0;
+ }
+}
+
+QmlTimeLineEvent::QmlTimeLineEvent()
+: d0(0), d1(0), d2(0)
+{
+}
+
+QmlTimeLineEvent::QmlTimeLineEvent(const QmlTimeLineEvent &o)
+: d0(o.d0), d1(o.d1), d2(o.d2)
+{
+}
+
+QmlTimeLineEvent &QmlTimeLineEvent::operator=(const QmlTimeLineEvent &o)
+{
+ d0 = o.d0;
+ d1 = o.d1;
+ d2 = o.d2;
+ return *this;
+}
+
+void QmlTimeLineEvent::execute() const
+{
+ d0(d1);
+}
+
+QmlTimeLineObject *QmlTimeLineEvent::eventObject() const
+{
+ return d2;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qmltimeline_p.h b/src/declarative/util/qmltimeline_p.h
new file mode 100644
index 0000000..abed80a
--- /dev/null
+++ b/src/declarative/util/qmltimeline_p.h
@@ -0,0 +1,224 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLTIMELINE_H
+#define QMLTIMELINE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/QObject>
+#include <QtCore/QAbstractAnimation>
+#include <QtDeclarative/qfxglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class QEasingCurve;
+class QmlTimeLineValue;
+class QmlTimeLineEvent;
+struct QmlTimeLinePrivate;
+class QmlTimeLineObject;
+class Q_DECLARATIVE_EXPORT QmlTimeLine : public QAbstractAnimation
+{
+Q_OBJECT
+public:
+ QmlTimeLine(QObject *parent = 0);
+ ~QmlTimeLine();
+
+ enum SyncMode { LocalSync, GlobalSync };
+ SyncMode syncMode() const;
+ void setSyncMode(SyncMode);
+
+ void pause(QmlTimeLineObject &, int);
+ void execute(const QmlTimeLineEvent &);
+ void set(QmlTimeLineValue &, qreal);
+
+ int accel(QmlTimeLineValue &, qreal velocity, qreal accel);
+ int accel(QmlTimeLineValue &, qreal velocity, qreal accel, qreal maxDistance);
+ int accelDistance(QmlTimeLineValue &, qreal velocity, qreal distance);
+
+ void move(QmlTimeLineValue &, qreal destination, int time = 500);
+ void move(QmlTimeLineValue &, qreal destination, const QEasingCurve &, int time = 500);
+ void moveBy(QmlTimeLineValue &, qreal change, int time = 500);
+ void moveBy(QmlTimeLineValue &, qreal change, const QEasingCurve &, int time = 500);
+
+ void sync();
+ void setSyncPoint(int);
+ int syncPoint() const;
+
+ void sync(QmlTimeLineValue &);
+ void sync(QmlTimeLineValue &, QmlTimeLineValue &);
+
+ void reset(QmlTimeLineValue &);
+
+ void complete();
+ void clear();
+ bool isActive() const;
+
+ int time() const;
+
+ virtual int duration() const;
+Q_SIGNALS:
+ void updated();
+ void completed();
+
+protected:
+ virtual void updateCurrentTime(int);
+
+private:
+ void remove(QmlTimeLineObject *);
+ friend class QmlTimeLineObject;
+ friend struct QmlTimeLinePrivate;
+ QmlTimeLinePrivate *d;
+};
+
+class Q_DECLARATIVE_EXPORT QmlTimeLineObject
+{
+public:
+ QmlTimeLineObject();
+ virtual ~QmlTimeLineObject();
+
+protected:
+ friend class QmlTimeLine;
+ friend struct QmlTimeLinePrivate;
+ QmlTimeLine *_t;
+};
+
+class Q_DECLARATIVE_EXPORT QmlTimeLineValue : public QmlTimeLineObject
+{
+public:
+ QmlTimeLineValue(qreal v = 0.) : _v(v) {}
+
+ virtual qreal value() const { return _v; }
+ virtual void setValue(qreal v) { _v = v; }
+
+ QmlTimeLine *timeLine() const { return _t; }
+
+ operator qreal() const { return _v; }
+ QmlTimeLineValue &operator=(qreal v) { setValue(v); return *this; }
+private:
+ friend class QmlTimeLine;
+ friend struct QmlTimeLinePrivate;
+ qreal _v;
+};
+
+class Q_DECLARATIVE_EXPORT QmlTimeLineEvent
+{
+public:
+ QmlTimeLineEvent();
+ QmlTimeLineEvent(const QmlTimeLineEvent &o);
+
+ template<class T, void (T::*method)()>
+ QmlTimeLineEvent(QmlTimeLineObject *b, T *c)
+ {
+ d0 = &callFunc<T, method>;
+ d1 = (void *)c;
+ d2 = b;
+ }
+
+ template<class T, void (T::*method)()>
+ static QmlTimeLineEvent timeLineEvent(QmlTimeLineObject *b, T *c)
+ {
+ QmlTimeLineEvent rv;
+ rv.d0 = &callFunc<T, method>;
+ rv.d1 = (void *)c;
+ rv.d2 = b;
+ return rv;
+ }
+
+ QmlTimeLineEvent &operator=(const QmlTimeLineEvent &o);
+ void execute() const;
+ QmlTimeLineObject *eventObject() const;
+
+private:
+ typedef void (*CallFunc)(void *c);
+
+ template <class T, void (T::*method)()>
+ static void callFunc(void *c)
+ {
+ T *cls = (T *)c;
+ (cls->*method)();
+ }
+ CallFunc d0;
+ void *d1;
+ QmlTimeLineObject *d2;
+};
+
+template<class T>
+class QmlTimeLineValueProxy : public QmlTimeLineValue
+{
+public:
+ QmlTimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.)
+ : QmlTimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0)
+ {
+ Q_ASSERT(_class);
+ }
+
+ QmlTimeLineValueProxy(T *cls, void (T::*func)(int), qreal v = 0.)
+ : QmlTimeLineValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func)
+ {
+ Q_ASSERT(_class);
+ }
+
+ virtual void setValue(qreal v)
+ {
+ QmlTimeLineValue::setValue(v);
+ if (_setFunctionReal) (_class->*_setFunctionReal)(v);
+ else if (_setFunctionInt) (_class->*_setFunctionInt)((int)v);
+ }
+
+private:
+ T *_class;
+ void (T::*_setFunctionReal)(qreal);
+ void (T::*_setFunctionInt)(int);
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp
index 5931075..d793c7d 100644
--- a/src/declarative/util/qmltransition.cpp
+++ b/src/declarative/util/qmltransition.cpp
@@ -46,6 +46,7 @@
#include "qmlstateoperations.h"
#include "qmlanimation.h"
#include "qmlanimation_p.h"
+#include "qmltransitionmanager_p.h"
#include <QParallelAnimationGroup>
QT_BEGIN_NAMESPACE
@@ -92,7 +93,7 @@ public:
bool reversed;
bool reversible;
ParallelAnimationWrapper *group;
- QmlState *endState;
+ QmlTransitionManager *endState;
void init()
{
@@ -103,7 +104,7 @@ public:
void complete()
{
- endState->d_func()->complete();
+ endState->complete();
}
class AnimationList : public QmlConcreteList<QmlAbstractAnimation *>
@@ -161,7 +162,7 @@ void QmlTransition::setReversed(bool r)
void QmlTransition::prepare(QmlStateOperation::ActionList &actions,
QList<QmlMetaProperty> &after,
- QmlState *endState)
+ QmlTransitionManager *endState)
{
Q_D(QmlTransition);
@@ -176,6 +177,7 @@ void QmlTransition::prepare(QmlStateOperation::ActionList &actions,
}
d->endState = endState;
+ d->group->setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward);
d->group->start();
}
diff --git a/src/declarative/util/qmltransition.h b/src/declarative/util/qmltransition.h
index 4462b4c..8ccb0ec 100644
--- a/src/declarative/util/qmltransition.h
+++ b/src/declarative/util/qmltransition.h
@@ -55,6 +55,7 @@ QT_MODULE(Declarative)
class QmlAbstractAnimation;
class QmlTransitionPrivate;
+class QmlTransitionManager;
class Q_DECLARATIVE_EXPORT QmlTransition : public QObject
{
Q_OBJECT
@@ -83,15 +84,16 @@ public:
void prepare(QmlStateOperation::ActionList &actions,
QList<QmlMetaProperty> &after,
- QmlState *endState);
+ QmlTransitionManager *end);
void setReversed(bool r);
void stop();
};
-QML_DECLARE_TYPE(QmlTransition)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlTransition)
+
QT_END_HEADER
#endif // QMLTRANSITION_H
diff --git a/src/declarative/util/qmltransitionmanager.cpp b/src/declarative/util/qmltransitionmanager.cpp
new file mode 100644
index 0000000..5e86b73
--- /dev/null
+++ b/src/declarative/util/qmltransitionmanager.cpp
@@ -0,0 +1,225 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtDeclarative/qmlbindablevalue.h>
+#include <private/qmltransitionmanager_p.h>
+#include <private/qmlstate_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QmlTransitionManagerPrivate
+{
+public:
+ QmlTransitionManagerPrivate()
+ : state(0), transition(0) {}
+
+ void applyBindings();
+ typedef QList<SimpleAction> SimpleActionList;
+ QmlState *state;
+ QmlTransition *transition;
+ QmlStateOperation::ActionList bindingsList;
+ SimpleActionList completeList;
+};
+
+QmlTransitionManager::QmlTransitionManager()
+: d(new QmlTransitionManagerPrivate)
+{
+}
+
+void QmlTransitionManager::setState(QmlState *s)
+{
+ d->state = s;
+}
+
+QmlTransitionManager::~QmlTransitionManager()
+{
+ delete d; d = 0;
+}
+
+void QmlTransitionManager::complete()
+{
+ d->applyBindings();
+
+ for (int ii = 0; ii < d->completeList.count(); ++ii) {
+ const QmlMetaProperty &prop = d->completeList.at(ii).property;
+ prop.write(d->completeList.at(ii).value);
+ }
+
+ d->completeList.clear();
+
+ if (d->state)
+ static_cast<QmlStatePrivate*>(QObjectPrivate::get(d->state))->complete();
+}
+
+void QmlTransitionManagerPrivate::applyBindings()
+{
+ foreach(const Action &action, bindingsList) {
+ if (action.toBinding) {
+ action.property.setBinding(action.toBinding);
+ action.toBinding->forceUpdate();
+ }
+ }
+
+ bindingsList.clear();
+}
+
+void QmlTransitionManager::transition(const QList<Action> &list,
+ QmlTransition *transition)
+{
+ cancel();
+
+ QmlStateOperation::ActionList applyList = list;
+ // Determine which actions are binding changes.
+ foreach(const Action &action, applyList) {
+ if (action.toBinding) {
+ d->bindingsList << action;
+ if (action.fromBinding)
+ action.property.setBinding(0); // Disable current binding
+ } else if (action.fromBinding) {
+ action.property.setBinding(0); // Disable current binding
+ }
+ }
+
+ // Animated transitions need both the start and the end value for
+ // each property change. In the presence of bindings, the end values
+ // are non-trivial to calculate. As a "best effort" attempt, we first
+ // apply all the property and binding changes, then read all the actual
+ // final values, then roll back the changes and proceed as normal.
+ //
+ // This doesn't catch everything, and it might be a little fragile in
+ // some cases - but whatcha going to do?
+
+ if (!d->bindingsList.isEmpty()) {
+
+ // Apply all the property and binding changes
+ foreach(const Action &action, applyList) {
+ if (action.toBinding) {
+ action.property.setBinding(action.toBinding);
+ action.toBinding->forceUpdate();
+ } else if (!action.event) {
+ action.property.write(action.toValue);
+ }
+ }
+
+ // Read all the end values for binding changes
+ for (int ii = 0; ii < applyList.size(); ++ii) {
+ Action *action = &applyList[ii];
+ if (action->event)
+ continue;
+
+ const QmlMetaProperty &prop = action->property;
+ if (action->toBinding)
+ action->toValue = prop.read();
+ }
+
+ // Revert back to the original values
+ foreach(const Action &action, applyList) {
+ if (action.event)
+ continue;
+
+ if (action.toBinding)
+ action.property.setBinding(0);
+
+ action.property.write(action.fromValue);
+ }
+ }
+
+ if (transition) {
+ QList<QmlMetaProperty> touched;
+ d->transition = transition;
+ d->transition->prepare(applyList, touched, this);
+
+ // Modify the action list to remove actions handled in the transition
+ for (int ii = 0; ii < applyList.count(); ++ii) {
+ const Action &action = applyList.at(ii);
+
+ if (action.event) {
+
+ if (action.actionDone) {
+ applyList.removeAt(ii);
+ --ii;
+ }
+
+ } else {
+
+ if (touched.contains(action.property)) {
+ if (action.toValue != action.fromValue)
+ d->completeList <<
+ SimpleAction(action, SimpleAction::EndState);
+
+ applyList.removeAt(ii);
+ --ii;
+ }
+
+ }
+ }
+ }
+
+ // Any actions remaining have not been handled by the transition and should
+ // be applied immediately. We skip applying transitions, as they are all
+ // applied at the end in applyBindings() to avoid any nastiness mid
+ // transition
+ foreach(const Action &action, applyList) {
+ if (action.event) {
+ action.event->execute();
+ } else {
+ action.property.write(action.toValue);
+ }
+ }
+ if (!transition)
+ d->applyBindings(); //### merge into above foreach?
+
+}
+
+void QmlTransitionManager::cancel()
+{
+ if (d->transition) {
+ // ### this could potentially trigger a complete in rare circumstances
+ d->transition->stop();
+ d->transition = 0;
+ }
+
+ d->bindingsList.clear();
+ d->completeList.clear();
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qbindablemap.h b/src/declarative/util/qmltransitionmanager_p.h
index c76928d..74a3950 100644
--- a/src/declarative/util/qbindablemap.h
+++ b/src/declarative/util/qmltransitionmanager_p.h
@@ -39,49 +39,47 @@
**
****************************************************************************/
-#ifndef QBINDABLEMAP_H
-#define QBINDABLEMAP_H
+#ifndef QMLTRANSITIONMANAGER_P_H
+#define QMLTRANSITIONMANAGER_P_H
-#include <QtDeclarative/qfxglobal.h>
-#include <QtCore/QObject>
-#include <QtCore/QHash>
-#include <QtCore/QStringList>
-#include <QtCore/QVariant>
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
-
-QT_BEGIN_HEADER
+#include <QtDeclarative/qmlstateoperations.h>
QT_BEGIN_NAMESPACE
-QT_MODULE(Declarative)
-
-class QBindableMapMetaObject;
-class Q_DECLARATIVE_EXPORT QBindableMap : public QObject
+class QmlStatePrivate;
+class QmlTransitionManagerPrivate;
+class QmlTransitionManager
{
- Q_OBJECT
public:
- QBindableMap(QObject *parent = 0);
- virtual ~QBindableMap();
-
- QVariant value(const QString &key) const;
- void setValue(const QString &key, QVariant value);
- void clearValue(const QString &key);
+ QmlTransitionManager();
+ ~QmlTransitionManager();
- Q_INVOKABLE QStringList keys() const;
+ void transition(const QList<Action> &, QmlTransition *transition);
-Q_SIGNALS:
- void changed(const QString &key);
+ void cancel();
private:
- Q_DISABLE_COPY(QBindableMap)
- void emitChanged(const QString &key);
- QBindableMapMetaObject *m_mo;
- QStringList m_keys;
- friend class QBindableMapMetaObject;
-};
+ Q_DISABLE_COPY(QmlTransitionManager);
+ QmlTransitionManagerPrivate *d;
+
+ void complete();
+ void setState(QmlState *);
+ friend class QmlState;
+ friend class QmlTransitionPrivate;
+};
QT_END_NAMESPACE
-QT_END_HEADER
-#endif
+#endif // QMLTRANSITIONMANAGER_P_H
diff --git a/src/declarative/util/qperformancelog.cpp b/src/declarative/util/qperformancelog.cpp
index 8065f9d..8e11997 100644
--- a/src/declarative/util/qperformancelog.cpp
+++ b/src/declarative/util/qperformancelog.cpp
@@ -39,10 +39,11 @@
**
****************************************************************************/
-#include "qperformancelog.h"
+#include "qperformancelog_p.h"
#include <QHash>
#include <QDebug>
+QT_BEGIN_NAMESPACE
#ifdef Q_ENABLE_PERFORMANCE_LOG
@@ -175,3 +176,5 @@ void QPerformanceLog::clear()
}
#endif // Q_ENABLE_PERFORMANCE_LOG
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qperformancelog.h b/src/declarative/util/qperformancelog_p.h
index 3203685..6655a8d 100644
--- a/src/declarative/util/qperformancelog.h
+++ b/src/declarative/util/qperformancelog_p.h
@@ -43,6 +43,9 @@
#define QPERFORMANCELOG_H
#include <QtCore/qdatetime.h>
+
+QT_BEGIN_NAMESPACE
+
namespace QPerformanceLog
{
Q_DECLARATIVE_EXPORT void displayData();
@@ -133,4 +136,6 @@ namespace QPerformanceLog
#endif // Q_ENABLE_PERFORMANCE_LOG
+QT_END_NAMESPACE
+
#endif // QPERFORMANCELOG_H
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index 030a44e..aae10af 100644
--- a/src/declarative/util/util.pri
+++ b/src/declarative/util/util.pri
@@ -6,44 +6,42 @@ SOURCES += \
util/qmlpackage.cpp \
util/qmlscript.cpp \
util/qmlanimation.cpp \
- util/qmlbehaviour.cpp \
util/qmlfont.cpp \
util/qmlfollow.cpp \
util/qmlstate.cpp\
+ util/qmltransitionmanager.cpp \
util/qmlstateoperations.cpp \
util/qmlsetproperties.cpp \
util/qmlstategroup.cpp \
util/qmltransition.cpp \
- util/qbindablemap.cpp \
- util/qmldatetimeformatter.cpp \
util/qmllistmodel.cpp\
util/qmllistaccessor.cpp \
util/qmlopenmetaobject.cpp \
+ util/qmltimeline.cpp \
util/qmlbind.cpp
HEADERS += \
util/qfxview.h \
- util/qfxperf.h \
+ util/qfxperf_p.h \
util/qfxglobal.h \
- util/qperformancelog.h \
+ util/qperformancelog_p.h \
util/qmlconnection.h \
util/qmlpackage.h \
util/qmlscript.h \
util/qmlanimation.h \
util/qmlanimation_p.h \
- util/qmlbehaviour.h \
util/qmlfont.h \
util/qmlfollow.h \
util/qmlstate.h\
util/qmlstateoperations.h \
util/qmlsetproperties.h \
util/qmlstate_p.h\
+ util/qmltransitionmanager_p.h \
util/qmlstategroup.h \
util/qmltransition.h \
- util/qbindablemap.h \
- util/qmldatetimeformatter.h \
util/qmllistmodel.h\
util/qmllistaccessor.h \
util/qmlopenmetaobject.h \
util/qmlnullablevalue_p.h \
+ util/qmltimeline_p.h \
util/qmlbind.h