src/declarative/util/qdeclarativestategroup.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    89 /*!
    89 /*!
    90    \qmlclass StateGroup QDeclarativeStateGroup
    90    \qmlclass StateGroup QDeclarativeStateGroup
    91    \since 4.7
    91    \since 4.7
    92    \brief The StateGroup element provides state support for non-Item elements.
    92    \brief The StateGroup element provides state support for non-Item elements.
    93 
    93 
    94    Item (and all dervied elements) provides built in support for states and transitions
    94    Item (and all derived elements) provides built in support for states and transitions
    95    via its state, states and transitions properties. StateGroup provides an easy way to
    95    via its \l{Item::state}{state}, \l{Item::states}{states} and \l{Item::transitions}{transitions} properties. StateGroup provides an easy way to
    96    use this support in other (non-Item-derived) elements.
    96    use this support in other (non-Item-derived) elements.
    97 
    97 
    98    \qml
    98    \qml
    99    MyCustomObject {
    99    MyCustomObject {
   100        StateGroup {
   100        StateGroup {
   261     Q_D(QDeclarativeStateGroup);
   261     Q_D(QDeclarativeStateGroup);
   262     d->componentComplete = true;
   262     d->componentComplete = true;
   263 
   263 
   264     for (int ii = 0; ii < d->states.count(); ++ii) {
   264     for (int ii = 0; ii < d->states.count(); ++ii) {
   265         QDeclarativeState *state = d->states.at(ii);
   265         QDeclarativeState *state = d->states.at(ii);
   266         if (state->name().isEmpty())
   266         if (!state->isNamed())
   267             state->setName(QLatin1String("anonymousState") % QString::number(++d->unnamedCount));
   267             state->setName(QLatin1String("anonymousState") % QString::number(++d->unnamedCount));
   268     }
   268     }
   269 
   269 
   270     if (d->updateAutoState()) {
   270     if (d->updateAutoState()) {
   271         return;
   271         return;
   293 
   293 
   294     bool revert = false;
   294     bool revert = false;
   295     for (int ii = 0; ii < states.count(); ++ii) {
   295     for (int ii = 0; ii < states.count(); ++ii) {
   296         QDeclarativeState *state = states.at(ii);
   296         QDeclarativeState *state = states.at(ii);
   297         if (state->isWhenKnown()) {
   297         if (state->isWhenKnown()) {
   298             if (!state->name().isEmpty()) {
   298             if (state->isNamed()) {
   299                 if (state->when() && state->when()->evaluate().toBool()) {
   299                 if (state->when() && state->when()->evaluate().toBool()) {
   300                     if (stateChangeDebug()) 
   300                     if (stateChangeDebug()) 
   301                         qWarning() << "Setting auto state due to:" 
   301                         qWarning() << "Setting auto state due to:" 
   302                                    << state->when()->expression();
   302                                    << state->when()->expression();
   303                     if (currentState != state->name()) {
   303                     if (currentState != state->name()) {