summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-07-28 03:25:11 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-07-28 03:25:11 (GMT)
commit9816567056c93f193c8d86d8e3cc8e22695b6642 (patch)
treed97dfd05e8e6a63b5bc09211f0395c6f1e714829 /src/declarative
parentfa475c4c783c8b711134247d4c1a7ae5c909dcf2 (diff)
downloadQt-9816567056c93f193c8d86d8e3cc8e22695b6642.zip
Qt-9816567056c93f193c8d86d8e3cc8e22695b6642.tar.gz
Qt-9816567056c93f193c8d86d8e3cc8e22695b6642.tar.bz2
Fix ParentChange in states.
Make sure we can override when necessary.
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/util/qmlstate.cpp28
-rw-r--r--src/declarative/util/qmlstate.h1
-rw-r--r--src/declarative/util/qmlstateoperations.cpp10
-rw-r--r--src/declarative/util/qmlstateoperations.h1
4 files changed, 35 insertions, 5 deletions
diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp
index c41c31a..af60a6f 100644
--- a/src/declarative/util/qmlstate.cpp
+++ b/src/declarative/util/qmlstate.cpp
@@ -110,6 +110,11 @@ void ActionEvent::clearReverseBindings()
{
}
+bool ActionEvent::override(ActionEvent *other)
+{
+ return false;
+}
+
/*!
\internal
*/
@@ -378,13 +383,15 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever
if (action.event) {
if (!action.event->isReversable())
continue;
- /*for (jj = 0; jj < d->revertList.count(); ++jj) {
+ for (jj = 0; jj < d->revertList.count(); ++jj) {
ActionEvent *event = d->revertList.at(jj).event;
if (event && event->typeName() == action.event->typeName()) {
- found = true;
- break;
+ if (action.event->override(event)) {
+ found = true;
+ break;
+ }
}
- }*/ //### not a close enough match
+ }
} else {
action.fromBinding = action.property.binding();
@@ -417,7 +424,18 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever
// into this state need to be translated into apply actions
for (int ii = 0; ii < d->revertList.count(); ++ii) {
bool found = false;
- if (!d->revertList.at(ii).event) { //### corresponding test for events?
+ if (d->revertList.at(ii).event) {
+ ActionEvent *event = d->revertList.at(ii).event;
+ if (!event->isReversable())
+ continue;
+ for (int jj = 0; !found && jj < applyList.count(); ++jj) {
+ const Action &action = applyList.at(jj);
+ if (action.event && action.event->typeName() == event->typeName()) {
+ if (action.event->override(event))
+ found = true;
+ }
+ }
+ } else {
for (int jj = 0; !found && jj < applyList.count(); ++jj) {
const Action &action = applyList.at(jj);
if (action.property == d->revertList.at(ii).property)
diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h
index 7b3021b..7c62768 100644
--- a/src/declarative/util/qmlstate.h
+++ b/src/declarative/util/qmlstate.h
@@ -96,6 +96,7 @@ public:
virtual bool changesBindings();
virtual void clearForwardBindings();
virtual void clearReverseBindings();
+ virtual bool override(ActionEvent*other);
};
class QmlStateGroup;
diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp
index e2cbae4..3d03c34 100644
--- a/src/declarative/util/qmlstateoperations.cpp
+++ b/src/declarative/util/qmlstateoperations.cpp
@@ -202,6 +202,16 @@ QString QmlParentChange::typeName() const
return QLatin1String("ParentChange");
}
+bool QmlParentChange::override(ActionEvent*other)
+{
+ Q_D(QmlParentChange);
+ if (other->typeName() != QLatin1String("ParentChange"))
+ return false;
+ if (QmlParentChange *otherPC = static_cast<QmlParentChange*>(other))
+ return (d->target == otherPC->object());
+ return false;
+}
+
class QmlRunScriptPrivate : public QObjectPrivate
{
public:
diff --git a/src/declarative/util/qmlstateoperations.h b/src/declarative/util/qmlstateoperations.h
index f595e16..4bd17a0 100644
--- a/src/declarative/util/qmlstateoperations.h
+++ b/src/declarative/util/qmlstateoperations.h
@@ -76,6 +76,7 @@ public:
virtual bool isReversable();
virtual void reverse();
virtual QString typeName() const;
+ virtual bool override(ActionEvent*other);
};
class QmlRunScriptPrivate;