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/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
@@ -29,35 +29,9 @@
|
||||
|
||||
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)
|
||||
{
|
||||
return debug.nospace() << "ChangeAuxiliaryCommand(auxiliaryChanges: " << command.m_auxiliaryChangeVector << ")";
|
||||
return debug.nospace() << "ChangeAuxiliaryCommand(auxiliaryChanges: " << command.auxiliaryChanges << ")";
|
||||
}
|
||||
|
||||
} // 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/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
|
||||
@@ -34,24 +36,24 @@ namespace QmlDesigner {
|
||||
|
||||
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);
|
||||
|
||||
public:
|
||||
ChangeAuxiliaryCommand();
|
||||
explicit ChangeAuxiliaryCommand(const QVector<PropertyValueContainer> &auxiliaryChangeVector);
|
||||
|
||||
QVector<PropertyValueContainer> auxiliaryChanges() const;
|
||||
|
||||
private:
|
||||
QVector<PropertyValueContainer> m_auxiliaryChangeVector;
|
||||
QVector<PropertyValueContainer> auxiliaryChanges;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChangeAuxiliaryCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, ChangeAuxiliaryCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeAuxiliaryCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ChangeAuxiliaryCommand)
|
||||
|
@@ -633,7 +633,7 @@ void NodeInstanceServer::changePropertyValues(const ChangeValuesCommand &command
|
||||
|
||||
void NodeInstanceServer::changeAuxiliaryValues(const ChangeAuxiliaryCommand &command)
|
||||
{
|
||||
foreach (const PropertyValueContainer &container, command.auxiliaryChanges()) {
|
||||
for (const PropertyValueContainer &container : command.auxiliaryChanges) {
|
||||
setInstanceAuxiliaryData(container);
|
||||
}
|
||||
|
||||
|
@@ -116,7 +116,7 @@ void Qt5TestNodeInstanceServer::changePropertyBindings(const ChangeBindingsComma
|
||||
|
||||
void Qt5TestNodeInstanceServer::changeAuxiliaryValues(const ChangeAuxiliaryCommand &command)
|
||||
{
|
||||
foreach (const PropertyValueContainer &container, command.auxiliaryChanges()) {
|
||||
for (const PropertyValueContainer &container : command.auxiliaryChanges) {
|
||||
setInstanceAuxiliaryData(container);
|
||||
}
|
||||
|
||||
|
@@ -535,9 +535,8 @@ void NodeInstanceView::auxiliaryDataChanged(const ModelNode &node,
|
||||
if (hasInstanceForModelNode(node)) {
|
||||
NodeInstance instance = instanceForModelNode(node);
|
||||
if (value.isValid() || name == "invisible") {
|
||||
PropertyValueContainer container(instance.instanceId(), name, value, TypeName());
|
||||
ChangeAuxiliaryCommand changeAuxiliaryCommand({container});
|
||||
m_nodeInstanceServer->changeAuxiliaryValues(changeAuxiliaryCommand);
|
||||
PropertyValueContainer container { instance.instanceId(), name, value, TypeName() };
|
||||
m_nodeInstanceServer->changeAuxiliaryValues({ { container } });
|
||||
} else {
|
||||
if (node.hasVariantProperty(name)) {
|
||||
PropertyValueContainer container(instance.instanceId(), name, node.variantProperty(name).value(), TypeName());
|
||||
|
Reference in New Issue
Block a user