src/declarative/util/qdeclarativestategroup.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
    86     bool updateAutoState();
    86     bool updateAutoState();
    87 };
    87 };
    88 
    88 
    89 /*!
    89 /*!
    90    \qmlclass StateGroup QDeclarativeStateGroup
    90    \qmlclass StateGroup QDeclarativeStateGroup
       
    91     \ingroup qml-state-elements
    91    \since 4.7
    92    \since 4.7
    92    \brief The StateGroup element provides state support for non-Item elements.
    93    \brief The StateGroup element provides state support for non-Item elements.
    93 
    94 
    94    Item (and all derived elements) provides built in support for states and transitions
    95    Item (and all derived elements) provides built in support for states and transitions
    95    via its \l{Item::state}{state}, \l{Item::states}{states} and \l{Item::transitions}{transitions} properties. StateGroup provides an easy way to
    96    via its \l{Item::state}{state}, \l{Item::states}{states} and \l{Item::transitions}{transitions} properties. StateGroup provides an easy way to
   110 
   111 
   111        onSomethingHappened: myStateGroup.state = "state1";
   112        onSomethingHappened: myStateGroup.state = "state1";
   112    }
   113    }
   113    \endqml
   114    \endqml
   114 
   115 
   115    \sa {qmlstate}{States} {state-transitions}{Transitions}, {QtDeclarative}
   116    \sa {qmlstate}{States} {Transitions}, {QtDeclarative}
   116 */
   117 */
   117 
   118 
   118 QDeclarativeStateGroup::QDeclarativeStateGroup(QObject *parent)
   119 QDeclarativeStateGroup::QDeclarativeStateGroup(QObject *parent)
   119     : QObject(*(new QDeclarativeStateGroupPrivate), parent)
   120     : QObject(*(new QDeclarativeStateGroupPrivate), parent)
   120 {
   121 {
   202       ...
   203       ...
   203     ]
   204     ]
   204   }
   205   }
   205   \endqml
   206   \endqml
   206 
   207 
   207   \sa {state-transitions}{Transitions}
   208   \sa {Transitions}
   208 */
   209 */
   209 QDeclarativeListProperty<QDeclarativeTransition> QDeclarativeStateGroup::transitionsProperty()
   210 QDeclarativeListProperty<QDeclarativeTransition> QDeclarativeStateGroup::transitionsProperty()
   210 {
   211 {
   211     Q_D(QDeclarativeStateGroup);
   212     Q_D(QDeclarativeStateGroup);
   212     return QDeclarativeListProperty<QDeclarativeTransition>(this, d->transitions);
   213     return QDeclarativeListProperty<QDeclarativeTransition>(this, d->transitions);
   269 
   270 
   270     if (d->updateAutoState()) {
   271     if (d->updateAutoState()) {
   271         return;
   272         return;
   272     } else if (!d->currentState.isEmpty()) {
   273     } else if (!d->currentState.isEmpty()) {
   273         QString cs = d->currentState;
   274         QString cs = d->currentState;
   274         d->currentState = QString();
   275         d->currentState.clear();
   275         d->setCurrentStateInternal(cs, true);
   276         d->setCurrentStateInternal(cs, true);
   276     }
   277     }
   277 }
   278 }
   278 
   279 
   279 /*!
   280 /*!
   311                 }
   312                 }
   312             }
   313             }
   313         }
   314         }
   314     }
   315     }
   315     if (revert) {
   316     if (revert) {
   316         bool rv = currentState != QString();
   317         bool rv = !currentState.isEmpty();
   317         q->setState(QString());
   318         q->setState(QString());
   318         return rv;
   319         return rv;
   319     } else {
   320     } else {
   320         return false;
   321         return false;
   321     }
   322     }