From 4871ff0563cf8a9691db8b084dce012aeb5abf47 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 19 May 2009 18:46:43 +1000 Subject: Add a SetProperties::restoreEntryValues property to store the state restoring property entry values --- src/declarative/util/qmlsetproperties.cpp | 18 +++++++++++++++++- src/declarative/util/qmlsetproperties.h | 4 ++++ src/declarative/util/qmlstate.cpp | 4 ++-- src/declarative/util/qmlstate.h | 1 + 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/declarative/util/qmlsetproperties.cpp b/src/declarative/util/qmlsetproperties.cpp index 34d3b00..c986864 100644 --- a/src/declarative/util/qmlsetproperties.cpp +++ b/src/declarative/util/qmlsetproperties.cpp @@ -113,13 +113,15 @@ class QmlSetPropertiesPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QmlSetProperties) public: - QmlSetPropertiesPrivate() : object(0), decoded(true) {} + QmlSetPropertiesPrivate() : object(0), decoded(true), restore(true) {} QObject *object; QByteArray data; bool decoded; void decode(); + bool restore; + QList > properties; QList > expressions; @@ -264,6 +266,18 @@ void QmlSetProperties::setObject(QObject *o) d->object = o; } +bool QmlSetProperties::restoreEntryValues() const +{ + Q_D(const QmlSetProperties); + return d->restore; +} + +void QmlSetProperties::setRestoreEntryValues(bool v) +{ + Q_D(QmlSetProperties); + d->restore = v; +} + QmlMetaProperty QmlSetPropertiesPrivate::property(const QByteArray &property) { @@ -314,6 +328,7 @@ QmlSetProperties::ActionList QmlSetProperties::actions() if (prop.isValid()) { Action a; + a.restore = restoreEntryValues(); a.property = prop; a.fromValue = a.property.read(); a.toValue = d->properties.at(ii).second; @@ -329,6 +344,7 @@ QmlSetProperties::ActionList QmlSetProperties::actions() if (prop.isValid()) { Action a; + a.restore = restoreEntryValues(); a.property = prop; a.fromValue = a.property.read(); a.toValue = d->expressions.at(ii).second->value(); diff --git a/src/declarative/util/qmlsetproperties.h b/src/declarative/util/qmlsetproperties.h index bd036c1..6d313b7 100644 --- a/src/declarative/util/qmlsetproperties.h +++ b/src/declarative/util/qmlsetproperties.h @@ -58,6 +58,7 @@ class Q_DECLARATIVE_EXPORT QmlSetProperties : public QmlStateOperation Q_DECLARE_PRIVATE(QmlSetProperties); Q_PROPERTY(QObject *target READ object WRITE setObject); + Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues); public: QmlSetProperties(); ~QmlSetProperties(); @@ -65,6 +66,9 @@ public: QObject *object() const; void setObject(QObject *); + bool restoreEntryValues() const; + void setRestoreEntryValues(bool); + virtual ActionList actions(); }; QML_DECLARE_TYPE(QmlSetProperties); diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp index 194cc1b..6261003 100644 --- a/src/declarative/util/qmlstate.cpp +++ b/src/declarative/util/qmlstate.cpp @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); -Action::Action() : bv(0), event(0), actionDone(false) +Action::Action() : restore(true), bv(0), event(0), actionDone(false) { } @@ -344,7 +344,7 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever for (int ii = 0; ii < applyList.count(); ++ii) { const Action &action = applyList.at(ii); - if (action.event) + if (action.event || !action.restore) continue; bool found = false; diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h index 68c43fa..dd9d6ab 100644 --- a/src/declarative/util/qmlstate.h +++ b/src/declarative/util/qmlstate.h @@ -61,6 +61,7 @@ public: Action(); QmlMetaProperty property; + bool restore; QVariant fromValue; QVariant toValue; QString fromBinding; -- cgit v0.12