summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-05-05 01:49:20 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-05-05 01:53:37 (GMT)
commit4982b883c31874206aaa05268852fbcee81a8a39 (patch)
tree05baa3fc23ee1d69ce056135f5d20fa7f6b0d1be /src
parent3b3ec6bc4114db82462eef812a47db420d4505c2 (diff)
downloadQt-4982b883c31874206aaa05268852fbcee81a8a39.zip
Qt-4982b883c31874206aaa05268852fbcee81a8a39.tar.gz
Qt-4982b883c31874206aaa05268852fbcee81a8a39.tar.bz2
Enable states to be activated via their 'when' clause even if unnamed.
Autogenerate a name for unnamed states: "anonymousState1", etc. Task-number: QTBUG-10352 Reviewed-by: Aaron Kennedy
Diffstat (limited to 'src')
-rw-r--r--src/declarative/util/qdeclarativestategroup.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp
index 5b51495..9b042d7 100644
--- a/src/declarative/util/qdeclarativestategroup.cpp
+++ b/src/declarative/util/qdeclarativestategroup.cpp
@@ -47,6 +47,7 @@
#include <qdeclarativebinding_p.h>
#include <qdeclarativeglobal_p.h>
+#include <QtCore/qstringbuilder.h>
#include <QtCore/qdebug.h>
#include <private/qobject_p.h>
@@ -62,7 +63,7 @@ class QDeclarativeStateGroupPrivate : public QObjectPrivate
public:
QDeclarativeStateGroupPrivate()
: nullState(0), componentComplete(true),
- ignoreTrans(false), applyingState(false) {}
+ ignoreTrans(false), applyingState(false), unnamedCount(0) {}
QString currentState;
QDeclarativeState *nullState;
@@ -78,6 +79,7 @@ public:
bool componentComplete;
bool ignoreTrans;
bool applyingState;
+ int unnamedCount;
QDeclarativeTransition *findTransition(const QString &from, const QString &to);
void setCurrentStateInternal(const QString &state, bool = false);
@@ -259,6 +261,12 @@ void QDeclarativeStateGroup::componentComplete()
Q_D(QDeclarativeStateGroup);
d->componentComplete = true;
+ for (int ii = 0; ii < d->states.count(); ++ii) {
+ QDeclarativeState *state = d->states.at(ii);
+ if (state->name().isEmpty())
+ state->setName(QLatin1String("anonymousState") % QString::number(++d->unnamedCount));
+ }
+
if (d->updateAutoState()) {
return;
} else if (!d->currentState.isEmpty()) {