aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquicktransitionmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/util/qquicktransitionmanager.cpp')
-rw-r--r--src/quick/util/qquicktransitionmanager.cpp90
1 files changed, 29 insertions, 61 deletions
diff --git a/src/quick/util/qquicktransitionmanager.cpp b/src/quick/util/qquicktransitionmanager.cpp
index 97c1fcd045..700e06a8ba 100644
--- a/src/quick/util/qquicktransitionmanager.cpp
+++ b/src/quick/util/qquicktransitionmanager.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qquicktransitionmanager_p_p.h"
@@ -51,7 +15,7 @@
QT_BEGIN_NAMESPACE
-DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
+Q_DECLARE_LOGGING_CATEGORY(lcStates)
class QQuickTransitionManagerPrivate
{
@@ -95,7 +59,7 @@ void QQuickTransitionManager::complete()
// Explicitly take a copy in case the write action triggers a script that modifies the list.
QQuickTransitionManagerPrivate::SimpleActionList completeListCopy = d->completeList;
- for (const QQuickSimpleAction &action : qAsConst(completeListCopy))
+ for (const QQuickSimpleAction &action : std::as_const(completeListCopy))
action.property().write(action.value());
d->completeList.clear();
@@ -108,7 +72,7 @@ void QQuickTransitionManager::complete()
void QQuickTransitionManagerPrivate::applyBindings()
{
- for (const QQuickStateAction &action : qAsConst(bindingsList)) {
+ for (const QQuickStateAction &action : std::as_const(bindingsList)) {
if (auto binding = action.toBinding; binding) {
binding.installOn(action.property, QQmlAnyBinding::RespectInterceptors);
} else if (action.event) {
@@ -137,11 +101,13 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
QQuickStateOperation::ActionList applyList = list;
// Determine which actions are binding changes and disable any current bindings
- for (const QQuickStateAction &action : qAsConst(applyList)) {
+ for (const QQuickStateAction &action : std::as_const(applyList)) {
if (action.toBinding)
d->bindingsList << action;
- if (action.fromBinding)
- QQmlPropertyPrivate::removeBinding(action.property); // Disable current binding
+ if (action.fromBinding) {
+ auto property = action.property;
+ QQmlAnyBinding::removeBindingFrom(property); // Disable current binding
+ }
if (action.event && action.event->changesBindings()) { //### assume isReversable()?
d->bindingsList << action;
action.event->clearBindings();
@@ -159,7 +125,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
if (transition && !d->bindingsList.isEmpty()) {
// Apply all the property and binding changes
- for (const QQuickStateAction &action : qAsConst(applyList)) {
+ for (const QQuickStateAction &action : std::as_const(applyList)) {
if (auto binding = action.toBinding; binding) {
binding.installOn(action.property);
} else if (!action.event) {
@@ -184,7 +150,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
}
// Revert back to the original values
- for (const QQuickStateAction &action : qAsConst(applyList)) {
+ for (const QQuickStateAction &action : std::as_const(applyList)) {
if (action.event) {
if (action.event->isReversable()) {
action.event->clearBindings();
@@ -194,8 +160,10 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
continue;
}
- if (action.toBinding)
- QQmlPropertyPrivate::removeBinding(action.property); // Make sure this is disabled during the transition
+ if (action.toBinding) {
+ auto property = action.property;
+ QQmlAnyBinding::removeBindingFrom(property); // Make sure this is disabled during the transition
+ }
QQmlPropertyPrivate::write(action.property, action.fromValue, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);
}
@@ -222,15 +190,15 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
}
return false;
};
- auto newEnd = std::remove_if(applyList.begin(), applyList.end(), isHandledInTransition);
- applyList.erase(newEnd, applyList.end());
+
+ applyList.removeIf(isHandledInTransition);
}
// Any actions remaining have not been handled by the transition and should
// be applied immediately. We skip applying bindings, as they are all
// applied at the end in applyBindings() to avoid any nastiness mid
// transition
- for (const QQuickStateAction &action : qAsConst(applyList)) {
+ for (const QQuickStateAction &action : std::as_const(applyList)) {
if (action.event && !action.event->changesBindings()) {
if (action.event->isReversable() && action.reverseEvent)
action.event->reverse();
@@ -240,18 +208,17 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
action.property.write(action.toValue);
}
}
-#ifndef QT_NO_DEBUG_STREAM
- if (stateChangeDebug()) {
- for (const QQuickStateAction &action : qAsConst(applyList)) {
+ if (lcStates().isDebugEnabled()) {
+ for (const QQuickStateAction &action : std::as_const(applyList)) {
if (action.event)
- qWarning() << " No transition for event:" << action.event->type();
+ qCDebug(lcStates) << "no transition for event:" << action.event->type();
else
- qWarning() << " No transition for:" << action.property.object()
- << action.property.name() << "From:" << action.fromValue
- << "To:" << action.toValue;
+ qCDebug(lcStates) << "no transition for:" << action.property.object()
+ << action.property.name() << "from:" << action.fromValue
+ << "to:" << action.toValue;
}
}
-#endif
+
if (!transition)
complete();
}
@@ -261,9 +228,10 @@ void QQuickTransitionManager::cancel()
if (d->transitionInstance && d->transitionInstance->isRunning())
RETURN_IF_DELETED(d->transitionInstance->stop());
- for (const QQuickStateAction &action : qAsConst(d->bindingsList)) {
+ for (const QQuickStateAction &action : std::as_const(d->bindingsList)) {
if (action.toBinding && action.deletableToBinding) {
- QQmlPropertyPrivate::removeBinding(action.property);
+ auto property = action.property;
+ QQmlAnyBinding::removeBindingFrom(property);
} else if (action.event) {
//### what do we do here?
}