summaryrefslogtreecommitdiffstats
path: root/src/declarative/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/util')
-rw-r--r--src/declarative/util/qmlsetproperties.cpp13
-rw-r--r--src/declarative/util/qmlstate.cpp146
-rw-r--r--src/declarative/util/qmlstate.h1
-rw-r--r--src/declarative/util/qmlstate_p.h10
-rw-r--r--src/declarative/util/qmlstateoperations.cpp219
-rw-r--r--src/declarative/util/qmlstateoperations.h28
-rw-r--r--src/declarative/util/qmltransition.cpp7
-rw-r--r--src/declarative/util/qmltransition.h3
-rw-r--r--src/declarative/util/qmltransitionmanager.cpp225
-rw-r--r--src/declarative/util/qmltransitionmanager_p.h85
-rw-r--r--src/declarative/util/util.pri2
11 files changed, 346 insertions, 393 deletions
diff --git a/src/declarative/util/qmlsetproperties.cpp b/src/declarative/util/qmlsetproperties.cpp
index 7a68ba2..6464e33 100644
--- a/src/declarative/util/qmlsetproperties.cpp
+++ b/src/declarative/util/qmlsetproperties.cpp
@@ -308,17 +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;
- a.specifiedObject = d->object;
- a.specifiedProperty = QString::fromLatin1(property);
+ Action a(d->object, QString::fromLatin1(property),
+ d->properties.at(ii).second);
+ if (a.property.isValid()) {
+ a.restore = restoreEntryValues();
list << a;
}
}
diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp
index 8b096f0..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), actionDone(false), fromBinding(0), toBinding(0), event(0), specifiedObject(0)
+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,23 +249,10 @@ QmlState &QmlState::operator<<(QmlStateOperation *op)
return *this;
}
-void QmlStatePrivate::applyBindings()
-{
- foreach(const Action &action, bindingsList) {
- if (action.toBinding) {
- action.property.setBinding(action.toBinding);
- action.toBinding->forceUpdate();
- }
- }
-}
-
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) {
if (revertList.at(jj).property == reverting.at(ii)) {
@@ -261,13 +263,6 @@ 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();
}
@@ -312,10 +307,7 @@ 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()
@@ -336,7 +328,6 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever
revert->cancel();
d->revertList.clear();
d->reverting.clear();
- d->bindingsList.clear();
if (revert) {
QmlStatePrivate *revertPrivate =
@@ -421,108 +412,7 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever
}
}
- // 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);
- }
- }
-
-
- d->completeList.clear();
-
- if (trans) {
- QList<QmlMetaProperty> touched;
- d->transition = trans;
- trans->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 (!trans)
- d->applyBindings(); //### merge into above foreach?
+ d->transitionManager.transition(applyList, trans);
}
QML_DEFINE_NOCREATE_TYPE(QmlStateOperation)
diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h
index 987c7ad..7532430 100644
--- a/src/declarative/util/qmlstate.h
+++ b/src/declarative/util/qmlstate.h
@@ -59,6 +59,7 @@ class Action
{
public:
Action();
+ Action(QObject *, const QString &, const QVariant &);
bool restore:1;
bool actionDone:1;
diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h
index 1b784f3..414ec08 100644
--- a/src/declarative/util/qmlstate_p.h
+++ b/src/declarative/util/qmlstate_p.h
@@ -56,6 +56,7 @@
#include <QtDeclarative/qmlstate.h>
#include <private/qobject_p.h>
#include <private/qmlanimation_p.h>
+#include <private/qmltransitionmanager_p.h>
QT_BEGIN_NAMESPACE
@@ -90,24 +91,23 @@ class QmlStatePrivate : public QObjectPrivate
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;
+
+ QmlTransitionManager transitionManager;
+
SimpleActionList revertList;
QList<QmlMetaProperty> reverting;
- SimpleActionList 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/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp
index b7398a3..5bb2cb6 100644
--- a/src/declarative/util/qmlstateoperations.cpp
+++ b/src/declarative/util/qmlstateoperations.cpp
@@ -204,223 +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())
- a.toBinding = new QmlBindableValue(d->binding, object(), qmlContext(this));
-
- return ActionList() << a;
-}
-
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlstateoperations.h b/src/declarative/util/qmlstateoperations.h
index 6e5de48..221373b 100644
--- a/src/declarative/util/qmlstateoperations.h
+++ b/src/declarative/util/qmlstateoperations.h
@@ -95,38 +95,10 @@ public:
virtual void execute();
};
-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();
-};
-
QT_END_NAMESPACE
QML_DECLARE_TYPE(QmlParentChange)
QML_DECLARE_TYPE(QmlRunScript)
-QML_DECLARE_TYPE(QmlSetProperty)
QT_END_HEADER
diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp
index 43a4605..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);
diff --git a/src/declarative/util/qmltransition.h b/src/declarative/util/qmltransition.h
index d6cd513..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,7 +84,7 @@ public:
void prepare(QmlStateOperation::ActionList &actions,
QList<QmlMetaProperty> &after,
- QmlState *endState);
+ QmlTransitionManager *end);
void setReversed(bool r);
void stop();
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/qmltransitionmanager_p.h b/src/declarative/util/qmltransitionmanager_p.h
new file mode 100644
index 0000000..74a3950
--- /dev/null
+++ b/src/declarative/util/qmltransitionmanager_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** 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 QMLTRANSITIONMANAGER_P_H
+#define QMLTRANSITIONMANAGER_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/qmlstateoperations.h>
+
+QT_BEGIN_NAMESPACE
+
+class QmlStatePrivate;
+class QmlTransitionManagerPrivate;
+class QmlTransitionManager
+{
+public:
+ QmlTransitionManager();
+ ~QmlTransitionManager();
+
+ void transition(const QList<Action> &, QmlTransition *transition);
+
+ void cancel();
+
+private:
+ Q_DISABLE_COPY(QmlTransitionManager);
+ QmlTransitionManagerPrivate *d;
+
+ void complete();
+ void setState(QmlState *);
+
+ friend class QmlState;
+ friend class QmlTransitionPrivate;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMLTRANSITIONMANAGER_P_H
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index 157c2d9..aae10af 100644
--- a/src/declarative/util/util.pri
+++ b/src/declarative/util/util.pri
@@ -9,6 +9,7 @@ SOURCES += \
util/qmlfont.cpp \
util/qmlfollow.cpp \
util/qmlstate.cpp\
+ util/qmltransitionmanager.cpp \
util/qmlstateoperations.cpp \
util/qmlsetproperties.cpp \
util/qmlstategroup.cpp \
@@ -35,6 +36,7 @@ HEADERS += \
util/qmlstateoperations.h \
util/qmlsetproperties.h \
util/qmlstate_p.h\
+ util/qmltransitionmanager_p.h \
util/qmlstategroup.h \
util/qmltransition.h \
util/qmllistmodel.h\