2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2012-09-19 15:57:22 +02:00
|
|
|
|
|
|
|
|
#include "qmlpropertychangesnodeinstance.h"
|
|
|
|
|
#include "qmlstatenodeinstance.h"
|
2015-05-20 18:30:37 +02:00
|
|
|
|
|
|
|
|
#include <qmlprivategate.h>
|
|
|
|
|
|
2012-09-19 15:57:22 +02:00
|
|
|
#include <QQmlEngine>
|
|
|
|
|
#include <QQmlContext>
|
|
|
|
|
#include <QQmlExpression>
|
|
|
|
|
|
|
|
|
|
namespace QmlDesigner {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2015-05-20 18:30:37 +02:00
|
|
|
QmlPropertyChangesNodeInstance::QmlPropertyChangesNodeInstance(QObject *propertyChangesObject) :
|
2012-09-19 15:57:22 +02:00
|
|
|
ObjectNodeInstance(propertyChangesObject)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlPropertyChangesNodeInstance::Pointer QmlPropertyChangesNodeInstance::create(QObject *object)
|
|
|
|
|
{
|
2015-05-20 18:30:37 +02:00
|
|
|
Pointer instance(new QmlPropertyChangesNodeInstance(object));
|
2012-09-19 15:57:22 +02:00
|
|
|
|
|
|
|
|
instance->populateResetHashes();
|
|
|
|
|
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-05 12:19:19 +01:00
|
|
|
void QmlPropertyChangesNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value)
|
2012-09-19 15:57:22 +02:00
|
|
|
{
|
2015-05-20 18:30:37 +02:00
|
|
|
if (QmlPrivateGate::PropertyChanges::isNormalProperty(name)) { // 'restoreEntryValues', 'explicit'
|
2012-09-19 15:57:22 +02:00
|
|
|
ObjectNodeInstance::setPropertyVariant(name, value);
|
|
|
|
|
} else {
|
2015-05-20 18:30:37 +02:00
|
|
|
QmlPrivateGate::PropertyChanges::changeValue(object(), name, value);
|
|
|
|
|
QObject *targetObject = QmlPrivateGate::PropertyChanges::targetObject(object());
|
|
|
|
|
if (targetObject
|
|
|
|
|
&& nodeInstanceServer()->activeStateInstance().
|
|
|
|
|
isWrappingThisObject(QmlPrivateGate::PropertyChanges::stateObject(object()))) {
|
2014-07-02 14:33:15 +02:00
|
|
|
if (nodeInstanceServer()->hasInstanceForObject(targetObject)) {
|
|
|
|
|
ServerNodeInstance targetInstance = nodeInstanceServer()->instanceForObject(targetObject);
|
|
|
|
|
targetInstance.setPropertyVariant(name, value);
|
|
|
|
|
}
|
2012-09-19 15:57:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-05 12:19:19 +01:00
|
|
|
void QmlPropertyChangesNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression)
|
2012-09-19 15:57:22 +02:00
|
|
|
{
|
2015-05-20 18:30:37 +02:00
|
|
|
if (QmlPrivateGate::PropertyChanges::isNormalProperty(name)) { // 'restoreEntryValues', 'explicit'
|
2012-09-19 15:57:22 +02:00
|
|
|
ObjectNodeInstance::setPropertyBinding(name, expression);
|
|
|
|
|
} else {
|
2015-05-20 18:30:37 +02:00
|
|
|
QmlPrivateGate::PropertyChanges::changeExpression(object(), name, expression);
|
2012-09-19 15:57:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-05 12:19:19 +01:00
|
|
|
QVariant QmlPropertyChangesNodeInstance::property(const PropertyName &name) const
|
2012-09-19 15:57:22 +02:00
|
|
|
{
|
2015-05-20 18:30:37 +02:00
|
|
|
return QmlPrivateGate::PropertyChanges::getProperty(object(), name);
|
2012-09-19 15:57:22 +02:00
|
|
|
}
|
|
|
|
|
|
2013-03-05 12:19:19 +01:00
|
|
|
void QmlPropertyChangesNodeInstance::resetProperty(const PropertyName &name)
|
2012-09-19 15:57:22 +02:00
|
|
|
{
|
2015-05-20 18:30:37 +02:00
|
|
|
QmlPrivateGate::PropertyChanges::removeProperty(object(), name);
|
2012-09-19 15:57:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-04-15 15:52:36 +02:00
|
|
|
void QmlPropertyChangesNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty)
|
2012-09-19 15:57:22 +02:00
|
|
|
{
|
2015-05-20 18:30:37 +02:00
|
|
|
QmlPrivateGate::PropertyChanges::detachFromState(object());
|
2012-09-19 15:57:22 +02:00
|
|
|
|
2013-04-15 15:52:36 +02:00
|
|
|
ObjectNodeInstance::reparent(oldParentInstance, oldParentProperty, newParentInstance, newParentProperty);
|
2012-09-19 15:57:22 +02:00
|
|
|
|
2015-05-20 18:30:37 +02:00
|
|
|
QmlPrivateGate::PropertyChanges::attachToState(object());
|
2012-09-19 15:57:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlDesigner
|