summaryrefslogtreecommitdiffstats
path: root/src/declarative/util
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-03-25 02:09:59 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-03-25 02:12:54 (GMT)
commita20828a110ad35a7a98a6234ca0013203d9f8b61 (patch)
tree9bb92d7cca2339465b79a6070584d2dca6e81c15 /src/declarative/util
parent4d078ed668541a4051f91b5c120b8cb0534129bd (diff)
downloadQt-a20828a110ad35a7a98a6234ca0013203d9f8b61.zip
Qt-a20828a110ad35a7a98a6234ca0013203d9f8b61.tar.gz
Qt-a20828a110ad35a7a98a6234ca0013203d9f8b61.tar.bz2
Qt.Infinite -> Animation.Infinite
Too misleading to have on the Qt object, as it only means infinite for animation loops.
Diffstat (limited to 'src/declarative/util')
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp11
-rw-r--r--src/declarative/util/qdeclarativeanimation_p.h3
-rw-r--r--src/declarative/util/qdeclarativespringfollow.cpp2
-rw-r--r--src/declarative/util/qdeclarativeutilmodule.cpp35
4 files changed, 45 insertions, 6 deletions
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 81ab3d3..bad142c 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -309,7 +309,7 @@ void QDeclarativeAbstractAnimation::setAlwaysRunToEnd(bool f)
By default, \c loops is 1: the animation will play through once and then stop.
- If set to Qt.Infinite, the animation will continuously repeat until it is explicitly
+ If set to Animation.Infinite, the animation will continuously repeat until it is explicitly
stopped - either by setting the \c running property to false, or by calling
the \c stop() method.
@@ -319,7 +319,7 @@ void QDeclarativeAbstractAnimation::setAlwaysRunToEnd(bool f)
Rectangle {
width: 100; height: 100; color: "green"
RotationAnimation on rotation {
- loops: Qt.Infinite
+ loops: Animation.Infinite
from: 0
to: 360
}
@@ -335,6 +335,9 @@ int QDeclarativeAbstractAnimation::loops() const
void QDeclarativeAbstractAnimation::setLoops(int loops)
{
Q_D(QDeclarativeAbstractAnimation);
+ if (loops < 0)
+ loops = -1;
+
if (loops == d->loopCount)
return;
@@ -1598,7 +1601,7 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int
\qml
Rectangle {
SequentialAnimation on x {
- loops: Qt.Infinite
+ loops: Animation.Infinite
PropertyAnimation { to: 50 }
PropertyAnimation { to: 0 }
}
@@ -2007,7 +2010,7 @@ void QDeclarativePropertyAnimation::setProperties(const QString &prop)
id: theRect
width: 100; height: 100
color: Qt.rgba(0,0,1)
- NumberAnimation on x { to: 500; loops: Qt.Infinite } //animate theRect's x property
+ NumberAnimation on x { to: 500; loops: Animation.Infinite } //animate theRect's x property
Behavior on y { NumberAnimation {} } //animate theRect's y property
}
\endqml
diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h
index 2e5b87c..816520e 100644
--- a/src/declarative/util/qdeclarativeanimation_p.h
+++ b/src/declarative/util/qdeclarativeanimation_p.h
@@ -70,6 +70,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeAbstractAnimation : public QObject, public Q
Q_INTERFACES(QDeclarativeParserStatus)
Q_INTERFACES(QDeclarativePropertyValueSource)
+ Q_ENUMS(Loops)
Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
Q_PROPERTY(bool alwaysRunToEnd READ alwaysRunToEnd WRITE setAlwaysRunToEnd NOTIFY alwaysRunToEndChanged)
@@ -80,6 +81,8 @@ public:
QDeclarativeAbstractAnimation(QObject *parent=0);
virtual ~QDeclarativeAbstractAnimation();
+ enum Loops { Infinite = -2 };
+
bool isRunning() const;
void setRunning(bool);
bool isPaused() const;
diff --git a/src/declarative/util/qdeclarativespringfollow.cpp b/src/declarative/util/qdeclarativespringfollow.cpp
index ca88b24..76d7c98 100644
--- a/src/declarative/util/qdeclarativespringfollow.cpp
+++ b/src/declarative/util/qdeclarativespringfollow.cpp
@@ -224,7 +224,7 @@ void QDeclarativeSpringFollowPrivate::stop()
color: "#00ff00"
y: 200 // initial value
SequentialAnimation on y {
- loops: Qt.Infinite
+ loops: Animation.Infinite
NumberAnimation {
to: 200
easing.type: "OutBounce"
diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp
index 46c9b73..d79c6ba 100644
--- a/src/declarative/util/qdeclarativeutilmodule.cpp
+++ b/src/declarative/util/qdeclarativeutilmodule.cpp
@@ -71,6 +71,38 @@
#include "qdeclarativexmllistmodel_p.h"
#endif
+template<typename T>
+int qmlRegisterTypeEnums(const char *qmlName)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativePrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+ 0, 0,
+
+ "Qt", 4, 6, qmlName, &T::staticMetaObject,
+
+ QDeclarativePrivate::attachedPropertiesFunc<T>(),
+ QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
+
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+
+ 0, 0,
+
+ 0
+ };
+
+ return QDeclarativePrivate::registerType(type);
+}
+
void QDeclarativeUtilModule::defineModule()
{
qmlRegisterType<QDeclarativeAnchorAnimation>("Qt",4,6,"AnchorAnimation");
@@ -107,9 +139,10 @@ void QDeclarativeUtilModule::defineModule()
#endif
qmlRegisterType<QDeclarativeAnchors>();
- qmlRegisterType<QDeclarativeAbstractAnimation>();
qmlRegisterType<QDeclarativeStateOperation>();
+ qmlRegisterTypeEnums<QDeclarativeAbstractAnimation>("Animation");
+
qmlRegisterCustomType<QDeclarativeListModel>("Qt", 4,6, "ListModel", "QDeclarativeListModel",
new QDeclarativeListModelParser);
qmlRegisterCustomType<QDeclarativePropertyChanges>("Qt", 4, 6, "PropertyChanges", "QDeclarativePropertyChanges",