forked from qt-creator/qt-creator
QmlPuppet: Refactor ChangeBindingsCommand
Change-Id: Id3020a73f59a1adfd25066a37d083d923e77956b Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -29,35 +29,9 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
ChangeBindingsCommand::ChangeBindingsCommand() = default;
|
||||
|
||||
ChangeBindingsCommand::ChangeBindingsCommand(const QVector<PropertyBindingContainer> &bindingChangeVector)
|
||||
: m_bindingChangeVector (bindingChangeVector)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<PropertyBindingContainer> ChangeBindingsCommand::bindingChanges() const
|
||||
{
|
||||
return m_bindingChangeVector;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChangeBindingsCommand &command)
|
||||
{
|
||||
out << command.bindingChanges();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ChangeBindingsCommand &command)
|
||||
{
|
||||
in >> command.m_bindingChangeVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeBindingsCommand &command)
|
||||
{
|
||||
return debug.nospace() << "PropertyValueContainer(bindingChanges: " << command.m_bindingChangeVector << ")";
|
||||
return debug.nospace() << "PropertyValueContainer(bindingChanges: " << command.bindingChanges << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -34,24 +34,22 @@ namespace QmlDesigner {
|
||||
|
||||
class ChangeBindingsCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, ChangeBindingsCommand &command);
|
||||
public:
|
||||
friend QDataStream &operator>>(QDataStream &in, ChangeBindingsCommand &command) {
|
||||
in >> command.bindingChanges;
|
||||
return in;
|
||||
}
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const ChangeBindingsCommand &command) {
|
||||
out << command.bindingChanges;
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDebug operator <<(QDebug debug, const ChangeBindingsCommand &command);
|
||||
|
||||
public:
|
||||
ChangeBindingsCommand();
|
||||
explicit ChangeBindingsCommand(const QVector<PropertyBindingContainer> &bindingChangeVector);
|
||||
|
||||
QVector<PropertyBindingContainer> bindingChanges() const;
|
||||
|
||||
private:
|
||||
QVector<PropertyBindingContainer> m_bindingChangeVector;
|
||||
QVector<PropertyBindingContainer> bindingChanges;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChangeBindingsCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, ChangeBindingsCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeBindingsCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ChangeBindingsCommand)
|
||||
|
@@ -643,7 +643,7 @@ void NodeInstanceServer::changeAuxiliaryValues(const ChangeAuxiliaryCommand &com
|
||||
void NodeInstanceServer::changePropertyBindings(const ChangeBindingsCommand &command)
|
||||
{
|
||||
bool hasDynamicProperties = false;
|
||||
foreach (const PropertyBindingContainer &container, command.bindingChanges()) {
|
||||
for (const PropertyBindingContainer &container : command.bindingChanges) {
|
||||
hasDynamicProperties |= container.isDynamic();
|
||||
setInstancePropertyBinding(container);
|
||||
}
|
||||
|
@@ -103,7 +103,7 @@ void Qt5TestNodeInstanceServer::changePropertyValues(const ChangeValuesCommand &
|
||||
void Qt5TestNodeInstanceServer::changePropertyBindings(const ChangeBindingsCommand &command)
|
||||
{
|
||||
bool hasDynamicProperties = false;
|
||||
foreach (const PropertyBindingContainer &container, command.bindingChanges()) {
|
||||
for (const PropertyBindingContainer &container : command.bindingChanges) {
|
||||
hasDynamicProperties |= container.isDynamic();
|
||||
setInstancePropertyBinding(container);
|
||||
}
|
||||
|
@@ -543,9 +543,8 @@ void NodeInstanceView::auxiliaryDataChanged(const ModelNode &node,
|
||||
ChangeValuesCommand changeValueCommand({container});
|
||||
m_nodeInstanceServer->changePropertyValues(changeValueCommand);
|
||||
} else if (node.hasBindingProperty(name)) {
|
||||
PropertyBindingContainer container(instance.instanceId(), name, node.bindingProperty(name).expression(), TypeName());
|
||||
ChangeBindingsCommand changeValueCommand({container});
|
||||
m_nodeInstanceServer->changePropertyBindings(changeValueCommand);
|
||||
PropertyBindingContainer container{instance.instanceId(), name, node.bindingProperty(name).expression(), TypeName()};
|
||||
m_nodeInstanceServer->changePropertyBindings({{container}});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1131,7 +1130,7 @@ ChangeBindingsCommand NodeInstanceView::createChangeBindingCommand(const QList<B
|
||||
{
|
||||
QVector<PropertyBindingContainer> containerList;
|
||||
|
||||
foreach (const BindingProperty &property, propertyList) {
|
||||
for (const BindingProperty &property : propertyList) {
|
||||
ModelNode node = property.parentModelNode();
|
||||
if (node.isValid() && hasInstanceForModelNode(node)) {
|
||||
NodeInstance instance = instanceForModelNode(node);
|
||||
@@ -1141,7 +1140,7 @@ ChangeBindingsCommand NodeInstanceView::createChangeBindingCommand(const QList<B
|
||||
|
||||
}
|
||||
|
||||
return ChangeBindingsCommand(containerList);
|
||||
return {containerList};
|
||||
}
|
||||
|
||||
ChangeIdsCommand NodeInstanceView::createChangeIdsCommand(const QList<NodeInstance> &instanceList) const
|
||||
|
Reference in New Issue
Block a user