93void QQuickTransitionManager::transition(
const QList<QQuickStateAction> &list,
94 QQuickTransition *transition,
95 QObject *defaultTarget)
97 RETURN_IF_DELETED(cancel());
100 QQuickStateOperation::ActionList applyList = list;
103 for (
const QQuickStateAction &action : std::as_const(applyList)) {
104 if (action.toBinding)
105 d->bindingsList << action;
106 if (action.fromBinding) {
107 auto property = action.property;
108 QQmlAnyBinding::removeBindingFrom(property);
110 if (action.event && action.event->changesBindings()) {
111 d->bindingsList << action;
112 action.event->clearBindings();
124 if (transition && !d->bindingsList.isEmpty()) {
127 for (
const QQuickStateAction &action : std::as_const(applyList)) {
128 if (
auto binding = action.toBinding; binding) {
129 binding.installOn(action.property);
130 }
else if (!action.event) {
131 QQmlPropertyPrivate::write(action.property, action.toValue, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);
132 }
else if (action.event->isReversable()) {
133 if (action.reverseEvent)
134 action.event->reverse();
136 action.event->execute();
141 for (
auto it = applyList.begin(), eit = applyList.end(); it != eit; ++it) {
143 it->event->saveTargetValues();
146 const QQmlProperty &prop = it->property;
147 if (it->toBinding || !it->toValue.isValid())
148 it->toValue = prop.read();
152 for (
const QQuickStateAction &action : std::as_const(applyList)) {
154 if (action.event->isReversable()) {
155 action.event->clearBindings();
156 action.event->rewind();
157 action.event->clearBindings();
162 if (action.toBinding) {
163 auto property = action.property;
164 QQmlAnyBinding::removeBindingFrom(property);
167 QQmlPropertyPrivate::write(action.property, action.fromValue, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);
172 QList<QQmlProperty> touched;
173 QQuickTransitionInstance *oldInstance = d->transitionInstance;
174 d->transitionInstance = transition->prepare(applyList, touched,
this, defaultTarget);
175 d->transitionInstance->start();
176 if (oldInstance && oldInstance != d->transitionInstance)
180 auto isHandledInTransition = [
this, touched](
const QQuickStateAction &action) {
182 return action.actionDone;
184 if (touched.contains(action.property)) {
185 if (action.toValue != action.fromValue)
186 d->completeList << QQuickSimpleAction(action, QQuickSimpleAction::EndState);
193 applyList.removeIf(isHandledInTransition);
200 for (
const QQuickStateAction &action : std::as_const(applyList)) {
201 if (action.event && !action.event->changesBindings()) {
202 if (action.event->isReversable() && action.reverseEvent)
203 action.event->reverse();
205 action.event->execute();
206 }
else if (!action.event && !action.toBinding) {
207 action.property.write(action.toValue);
210 if (lcStates().isDebugEnabled()) {
211 for (
const QQuickStateAction &action : std::as_const(applyList)) {
213 qCDebug(lcStates) <<
"no transition for event:" << action.event->type();
215 qCDebug(lcStates) <<
"no transition for:" << action.property.object()
216 << action.property.name() <<
"from:" << action.fromValue
217 <<
"to:" << action.toValue;