forked from qt-creator/qt-creator
QmlPuppet: Refactor ChangeAuxiliaryCommand
Change-Id: I32eb04db96322883aa908e22724756f5e25ded09 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
** Copyright (C) 2020 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of Qt Creator.
|
** This file is part of Qt Creator.
|
||||||
@@ -29,35 +29,9 @@
|
|||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
ChangeAuxiliaryCommand::ChangeAuxiliaryCommand() = default;
|
|
||||||
|
|
||||||
ChangeAuxiliaryCommand::ChangeAuxiliaryCommand(const QVector<PropertyValueContainer> &auxiliaryChangeVector)
|
|
||||||
: m_auxiliaryChangeVector (auxiliaryChangeVector)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<PropertyValueContainer> ChangeAuxiliaryCommand::auxiliaryChanges() const
|
|
||||||
{
|
|
||||||
return m_auxiliaryChangeVector;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &operator<<(QDataStream &out, const ChangeAuxiliaryCommand &command)
|
|
||||||
{
|
|
||||||
out << command.auxiliaryChanges();
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &operator>>(QDataStream &in, ChangeAuxiliaryCommand &command)
|
|
||||||
{
|
|
||||||
in >> command.m_auxiliaryChangeVector;
|
|
||||||
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDebug operator <<(QDebug debug, const ChangeAuxiliaryCommand &command)
|
QDebug operator <<(QDebug debug, const ChangeAuxiliaryCommand &command)
|
||||||
{
|
{
|
||||||
return debug.nospace() << "ChangeAuxiliaryCommand(auxiliaryChanges: " << command.m_auxiliaryChangeVector << ")";
|
return debug.nospace() << "ChangeAuxiliaryCommand(auxiliaryChanges: " << command.auxiliaryChanges << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
** Copyright (C) 2020 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of Qt Creator.
|
** This file is part of Qt Creator.
|
||||||
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <QDebug>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
@@ -34,24 +36,24 @@ namespace QmlDesigner {
|
|||||||
|
|
||||||
class ChangeAuxiliaryCommand
|
class ChangeAuxiliaryCommand
|
||||||
{
|
{
|
||||||
friend QDataStream &operator>>(QDataStream &in, ChangeAuxiliaryCommand &command);
|
public:
|
||||||
|
friend QDataStream &operator>>(QDataStream &in, ChangeAuxiliaryCommand &command)
|
||||||
|
{
|
||||||
|
in >> command.auxiliaryChanges;
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
friend QDataStream &operator<<(QDataStream &out, const ChangeAuxiliaryCommand &command)
|
||||||
|
{
|
||||||
|
out << command.auxiliaryChanges;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
friend QDebug operator <<(QDebug debug, const ChangeAuxiliaryCommand &command);
|
friend QDebug operator <<(QDebug debug, const ChangeAuxiliaryCommand &command);
|
||||||
|
|
||||||
public:
|
QVector<PropertyValueContainer> auxiliaryChanges;
|
||||||
ChangeAuxiliaryCommand();
|
|
||||||
explicit ChangeAuxiliaryCommand(const QVector<PropertyValueContainer> &auxiliaryChangeVector);
|
|
||||||
|
|
||||||
QVector<PropertyValueContainer> auxiliaryChanges() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QVector<PropertyValueContainer> m_auxiliaryChangeVector;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QDataStream &operator<<(QDataStream &out, const ChangeAuxiliaryCommand &command);
|
|
||||||
QDataStream &operator>>(QDataStream &in, ChangeAuxiliaryCommand &command);
|
|
||||||
|
|
||||||
QDebug operator <<(QDebug debug, const ChangeAuxiliaryCommand &command);
|
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QmlDesigner::ChangeAuxiliaryCommand)
|
Q_DECLARE_METATYPE(QmlDesigner::ChangeAuxiliaryCommand)
|
||||||
|
@@ -633,7 +633,7 @@ void NodeInstanceServer::changePropertyValues(const ChangeValuesCommand &command
|
|||||||
|
|
||||||
void NodeInstanceServer::changeAuxiliaryValues(const ChangeAuxiliaryCommand &command)
|
void NodeInstanceServer::changeAuxiliaryValues(const ChangeAuxiliaryCommand &command)
|
||||||
{
|
{
|
||||||
foreach (const PropertyValueContainer &container, command.auxiliaryChanges()) {
|
for (const PropertyValueContainer &container : command.auxiliaryChanges) {
|
||||||
setInstanceAuxiliaryData(container);
|
setInstanceAuxiliaryData(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -116,7 +116,7 @@ void Qt5TestNodeInstanceServer::changePropertyBindings(const ChangeBindingsComma
|
|||||||
|
|
||||||
void Qt5TestNodeInstanceServer::changeAuxiliaryValues(const ChangeAuxiliaryCommand &command)
|
void Qt5TestNodeInstanceServer::changeAuxiliaryValues(const ChangeAuxiliaryCommand &command)
|
||||||
{
|
{
|
||||||
foreach (const PropertyValueContainer &container, command.auxiliaryChanges()) {
|
for (const PropertyValueContainer &container : command.auxiliaryChanges) {
|
||||||
setInstanceAuxiliaryData(container);
|
setInstanceAuxiliaryData(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -535,9 +535,8 @@ void NodeInstanceView::auxiliaryDataChanged(const ModelNode &node,
|
|||||||
if (hasInstanceForModelNode(node)) {
|
if (hasInstanceForModelNode(node)) {
|
||||||
NodeInstance instance = instanceForModelNode(node);
|
NodeInstance instance = instanceForModelNode(node);
|
||||||
if (value.isValid() || name == "invisible") {
|
if (value.isValid() || name == "invisible") {
|
||||||
PropertyValueContainer container(instance.instanceId(), name, value, TypeName());
|
PropertyValueContainer container { instance.instanceId(), name, value, TypeName() };
|
||||||
ChangeAuxiliaryCommand changeAuxiliaryCommand({container});
|
m_nodeInstanceServer->changeAuxiliaryValues({ { container } });
|
||||||
m_nodeInstanceServer->changeAuxiliaryValues(changeAuxiliaryCommand);
|
|
||||||
} else {
|
} else {
|
||||||
if (node.hasVariantProperty(name)) {
|
if (node.hasVariantProperty(name)) {
|
||||||
PropertyValueContainer container(instance.instanceId(), name, node.variantProperty(name).value(), TypeName());
|
PropertyValueContainer container(instance.instanceId(), name, node.variantProperty(name).value(), TypeName());
|
||||||
|
Reference in New Issue
Block a user