2012-11-06 15:35:19 +01:00
|
|
|
/****************************************************************************
|
2012-09-19 15:57:22 +02:00
|
|
|
**
|
2016-01-15 14:59:14 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2012-09-19 15:57:22 +02:00
|
|
|
**
|
2012-11-06 15:35:19 +01:00
|
|
|
** This file is part of Qt Creator.
|
2012-09-19 15:57:22 +02:00
|
|
|
**
|
2012-11-06 15:35:19 +01:00
|
|
|
** 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
|
2016-01-15 14:59:14 +01:00
|
|
|
** 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.
|
2012-09-19 15:57:22 +02:00
|
|
|
**
|
2015-09-18 11:34:48 +02:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
2016-01-15 14:59:14 +01:00
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
** 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-3.0.html.
|
2012-09-19 15:57:22 +02:00
|
|
|
**
|
2012-11-06 15:35:19 +01:00
|
|
|
****************************************************************************/
|
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
|