diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2010-03-26 07:38:43 (GMT) |
---|---|---|
committer | Kai Koehne <kai.koehne@nokia.com> | 2010-03-26 08:58:22 (GMT) |
commit | a034773ce0e9d3fe3e7768da248d8c2e99cf132d (patch) | |
tree | bacb7922b40915198aef30a5c950f366c7ee6b54 /src/declarative | |
parent | 01cea4f1f53f8153dd62771d7346f79ee608b890 (diff) | |
download | Qt-a034773ce0e9d3fe3e7768da248d8c2e99cf132d.zip Qt-a034773ce0e9d3fe3e7768da248d8c2e99cf132d.tar.gz Qt-a034773ce0e9d3fe3e7768da248d8c2e99cf132d.tar.bz2 |
Adds a way to clear the state list property in QDeclarativeStateGroup
Needed by QmlDesigner, which needs to be able to remove states
at runtime.
Done my Marco Bubke
Reviewed-by: Michael Brasser
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/util/qdeclarativestategroup.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp index bc4582c..258a9e9 100644 --- a/src/declarative/util/qdeclarativestategroup.cpp +++ b/src/declarative/util/qdeclarativestategroup.cpp @@ -69,6 +69,7 @@ public: static void append_state(QDeclarativeListProperty<QDeclarativeState> *list, QDeclarativeState *state); static int count_state(QDeclarativeListProperty<QDeclarativeState> *list); static QDeclarativeState *at_state(QDeclarativeListProperty<QDeclarativeState> *list, int index); + static void clear_states(QDeclarativeListProperty<QDeclarativeState> *list); QList<QDeclarativeState *> states; QList<QDeclarativeTransition *> transitions; @@ -150,7 +151,8 @@ QDeclarativeListProperty<QDeclarativeState> QDeclarativeStateGroup::statesProper Q_D(QDeclarativeStateGroup); return QDeclarativeListProperty<QDeclarativeState>(this, &d->states, &QDeclarativeStateGroupPrivate::append_state, &QDeclarativeStateGroupPrivate::count_state, - &QDeclarativeStateGroupPrivate::at_state); + &QDeclarativeStateGroupPrivate::at_state, + &QDeclarativeStateGroupPrivate::clear_states); } void QDeclarativeStateGroupPrivate::append_state(QDeclarativeListProperty<QDeclarativeState> *list, QDeclarativeState *state) @@ -175,6 +177,16 @@ QDeclarativeState *QDeclarativeStateGroupPrivate::at_state(QDeclarativeListPrope return _this->d_func()->states.at(index); } +void QDeclarativeStateGroupPrivate::clear_states(QDeclarativeListProperty<QDeclarativeState> *list) +{ + QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object); + _this->d_func()->setCurrentStateInternal(QString(), true); + for (int i = 0; i < _this->d_func()->states.count(); ++i) { + _this->d_func()->states.at(i)->setStateGroup(0); + } + _this->d_func()->states.clear(); +} + /*! \qmlproperty list<Transition> StateGroup::transitions This property holds a list of transitions defined by the state group. |