summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2011-08-19 10:14:59 +1000
committerQt by Nokia <qt-info@nokia.com>2011-08-19 03:53:11 +0200
commit9ed7790fd828f1dfa51a05326620e538076297b1 (patch)
treeacd3825c454471b005255197d5af560a6ccdc2e0
parentc47025eab4276b4e1b0181b92e53ab4f7e3ae6aa (diff)
Internal state class refactoring.
Change-Id: I6e5fe3fa4459f99a50e3aa79c3a87106600f083a Reviewed-on: http://codereview.qt.nokia.com/3231 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Charles Yin <charles.yin@nokia.com>
-rw-r--r--src/declarative/util/qdeclarativestate.cpp12
-rw-r--r--src/declarative/util/qdeclarativestate_p.h2
-rw-r--r--src/declarative/util/qdeclarativestate_p_p.h2
-rw-r--r--src/declarative/util/qdeclarativestategroup.cpp18
-rw-r--r--src/declarative/util/qdeclarativestategroup_p.h4
-rw-r--r--src/declarative/util/qdeclarativetransition.cpp10
-rw-r--r--src/declarative/util/qdeclarativetransitionmanager.cpp2
7 files changed, 31 insertions, 19 deletions
diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp
index 63cb95d7b1..4779208c5f 100644
--- a/src/declarative/util/qdeclarativestate.cpp
+++ b/src/declarative/util/qdeclarativestate.cpp
@@ -315,13 +315,15 @@ void QDeclarativeStatePrivate::complete()
}
reverting.clear();
+ if (group)
+ group->stateAboutToComplete();
emit q->completed();
}
// Generate a list of actions for this state. This includes coelescing state
// actions that this state "extends"
QDeclarativeStateOperation::ActionList
-QDeclarativeStatePrivate::generateActionList(QDeclarativeStateGroup *group) const
+QDeclarativeStatePrivate::generateActionList() const
{
QDeclarativeStateOperation::ActionList applyList;
if (inState)
@@ -331,11 +333,11 @@ QDeclarativeStatePrivate::generateActionList(QDeclarativeStateGroup *group) cons
inState = true;
if (!extends.isEmpty()) {
- QList<QDeclarativeState *> states = group->states();
+ QList<QDeclarativeState *> states = group ? group->states() : QList<QDeclarativeState *>();
for (int ii = 0; ii < states.count(); ++ii)
if (states.at(ii)->name() == extends) {
qmlExecuteDeferred(states.at(ii));
- applyList = static_cast<QDeclarativeStatePrivate*>(states.at(ii)->d_func())->generateActionList(group);
+ applyList = static_cast<QDeclarativeStatePrivate*>(states.at(ii)->d_func())->generateActionList();
}
}
@@ -559,7 +561,7 @@ bool QDeclarativeState::isStateActive() const
return stateGroup() && stateGroup()->state() == name();
}
-void QDeclarativeState::apply(QDeclarativeStateGroup *group, QDeclarativeTransition *trans, QDeclarativeState *revert)
+void QDeclarativeState::apply(QDeclarativeTransition *trans, QDeclarativeState *revert)
{
Q_D(QDeclarativeState);
@@ -579,7 +581,7 @@ void QDeclarativeState::apply(QDeclarativeStateGroup *group, QDeclarativeTransit
}
// List of actions caused by this state
- QDeclarativeStateOperation::ActionList applyList = d->generateActionList(group);
+ QDeclarativeStateOperation::ActionList applyList = d->generateActionList();
// List of actions that need to be reverted to roll back (just) this state
QDeclarativeStatePrivate::SimpleActionList additionalReverts;
diff --git a/src/declarative/util/qdeclarativestate_p.h b/src/declarative/util/qdeclarativestate_p.h
index d24304ccf5..a7aafe32fe 100644
--- a/src/declarative/util/qdeclarativestate_p.h
+++ b/src/declarative/util/qdeclarativestate_p.h
@@ -174,7 +174,7 @@ public:
QDeclarativeState &operator<<(QDeclarativeStateOperation *);
- void apply(QDeclarativeStateGroup *, QDeclarativeTransition *, QDeclarativeState *revert);
+ void apply(QDeclarativeTransition *, QDeclarativeState *revert);
void cancel();
QDeclarativeStateGroup *stateGroup() const;
diff --git a/src/declarative/util/qdeclarativestate_p_p.h b/src/declarative/util/qdeclarativestate_p_p.h
index 195b935cdb..2479413511 100644
--- a/src/declarative/util/qdeclarativestate_p_p.h
+++ b/src/declarative/util/qdeclarativestate_p_p.h
@@ -246,7 +246,7 @@ public:
mutable bool inState;
QDeclarativeStateGroup *group;
- QDeclarativeStateOperation::ActionList generateActionList(QDeclarativeStateGroup *) const;
+ QDeclarativeStateOperation::ActionList generateActionList() const;
void complete();
};
diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp
index df16c16fa2..4f9593011b 100644
--- a/src/declarative/util/qdeclarativestategroup.cpp
+++ b/src/declarative/util/qdeclarativestategroup.cpp
@@ -474,15 +474,17 @@ void QDeclarativeStateGroupPrivate::setCurrentStateInternal(const QString &state
}
if (oldState == 0 || newState == 0) {
- if (!nullState) { nullState = new QDeclarativeState; QDeclarative_setParent_noEvent(nullState, q); }
+ if (!nullState) {
+ nullState = new QDeclarativeState;
+ QDeclarative_setParent_noEvent(nullState, q);
+ nullState->setStateGroup(q);
+ }
if (!oldState) oldState = nullState;
if (!newState) newState = nullState;
}
- newState->apply(q, transition, oldState);
- applyingState = false;
- if (!transition)
- static_cast<QDeclarativeStatePrivate*>(QObjectPrivate::get(newState))->complete();
+ newState->apply(transition, oldState);
+ applyingState = false; //### consider removing this (don't allow state changes in transition)
}
QDeclarativeState *QDeclarativeStateGroup::findState(const QString &name) const
@@ -503,6 +505,12 @@ void QDeclarativeStateGroup::removeState(QDeclarativeState *state)
d->states.removeOne(state);
}
+void QDeclarativeStateGroup::stateAboutToComplete()
+{
+ Q_D(QDeclarativeStateGroup);
+ d->applyingState = false;
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativestategroup_p.h b/src/declarative/util/qdeclarativestategroup_p.h
index 65d9536236..e539f3fb16 100644
--- a/src/declarative/util/qdeclarativestategroup_p.h
+++ b/src/declarative/util/qdeclarativestategroup_p.h
@@ -74,6 +74,7 @@ public:
QDeclarativeListProperty<QDeclarativeTransition> transitionsProperty();
QDeclarativeState *findState(const QString &name) const;
+ void removeState(QDeclarativeState *state);
virtual void classBegin();
virtual void componentComplete();
@@ -82,8 +83,9 @@ Q_SIGNALS:
private:
friend class QDeclarativeState;
+ friend class QDeclarativeStatePrivate;
bool updateAutoState();
- void removeState(QDeclarativeState *state);
+ void stateAboutToComplete();
};
QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp
index 5351f8a5c9..df22a57c1d 100644
--- a/src/declarative/util/qdeclarativetransition.cpp
+++ b/src/declarative/util/qdeclarativetransition.cpp
@@ -113,7 +113,7 @@ class QDeclarativeTransitionPrivate : public QObjectPrivate
public:
QDeclarativeTransitionPrivate()
: fromState(QLatin1String("*")), toState(QLatin1String("*")),
- reversed(false), reversible(false), enabled(true), endState(0)
+ reversed(false), reversible(false), enabled(true), manager(0)
{
group.trans = this;
}
@@ -124,11 +124,11 @@ public:
bool reversible;
bool enabled;
ParallelAnimationWrapper group;
- QDeclarativeTransitionManager *endState;
+ QDeclarativeTransitionManager *manager;
void complete()
{
- endState->complete();
+ manager->complete();
}
static void append_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, QDeclarativeAbstractAnimation *a);
static int animation_count(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list);
@@ -203,7 +203,7 @@ void QDeclarativeTransition::setReversed(bool r)
void QDeclarativeTransition::prepare(QDeclarativeStateOperation::ActionList &actions,
QList<QDeclarativeProperty> &after,
- QDeclarativeTransitionManager *endState)
+ QDeclarativeTransitionManager *manager)
{
Q_D(QDeclarativeTransition);
@@ -219,7 +219,7 @@ void QDeclarativeTransition::prepare(QDeclarativeStateOperation::ActionList &act
}
}
- d->endState = endState;
+ d->manager = manager;
d->group.setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward);
d->group.start();
}
diff --git a/src/declarative/util/qdeclarativetransitionmanager.cpp b/src/declarative/util/qdeclarativetransitionmanager.cpp
index 6e96ac914c..0b549b7cf7 100644
--- a/src/declarative/util/qdeclarativetransitionmanager.cpp
+++ b/src/declarative/util/qdeclarativetransitionmanager.cpp
@@ -246,7 +246,7 @@ void QDeclarativeTransitionManager::transition(const QList<QDeclarativeAction> &
}
#endif
if (!transition)
- d->applyBindings();
+ complete();
}
void QDeclarativeTransitionManager::cancel()