forked from qt-creator/qt-creator
QmlPuppet: Refactor ChangeIdsCommand
Change-Id: I75de863121b66a5050226dd5c8914229cb1af608 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -29,35 +29,9 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
ChangeIdsCommand::ChangeIdsCommand() = default;
|
||||
|
||||
ChangeIdsCommand::ChangeIdsCommand(const QVector<IdContainer> &idVector)
|
||||
: m_idVector(idVector)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<IdContainer> ChangeIdsCommand::ids() const
|
||||
{
|
||||
return m_idVector;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChangeIdsCommand &command)
|
||||
{
|
||||
out << command.ids();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ChangeIdsCommand &command)
|
||||
{
|
||||
in >> command.m_idVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeIdsCommand &command)
|
||||
{
|
||||
return debug.nospace() << "ChangeIdsCommand(ids: " << command.m_idVector << ")";
|
||||
return debug.nospace() << "ChangeIdsCommand(ids: " << command.ids << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -27,7 +27,7 @@
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
|
||||
#include <QDataStream>
|
||||
|
||||
#include "idcontainer.h"
|
||||
|
||||
@@ -35,24 +35,23 @@ namespace QmlDesigner {
|
||||
|
||||
class ChangeIdsCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, ChangeIdsCommand &command);
|
||||
public:
|
||||
friend QDataStream &operator>>(QDataStream &in, ChangeIdsCommand &command)
|
||||
{
|
||||
in >> command.ids;
|
||||
return in;
|
||||
}
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const ChangeIdsCommand &command)
|
||||
{
|
||||
out << command.ids;
|
||||
return out;
|
||||
}
|
||||
friend QDebug operator <<(QDebug debug, const ChangeIdsCommand &command);
|
||||
|
||||
public:
|
||||
ChangeIdsCommand();
|
||||
explicit ChangeIdsCommand(const QVector<IdContainer> &idVector);
|
||||
|
||||
QVector<IdContainer> ids() const;
|
||||
|
||||
private:
|
||||
QVector<IdContainer> m_idVector;
|
||||
QVector<IdContainer> ids;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChangeIdsCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, ChangeIdsCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeIdsCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ChangeIdsCommand)
|
||||
|
@@ -656,7 +656,7 @@ void NodeInstanceServer::changePropertyBindings(const ChangeBindingsCommand &com
|
||||
|
||||
void NodeInstanceServer::changeIds(const ChangeIdsCommand &command)
|
||||
{
|
||||
foreach (const IdContainer &container, command.ids()) {
|
||||
for (const IdContainer &container : command.ids) {
|
||||
if (hasInstanceForId(container.instanceId()))
|
||||
instanceForId(container.instanceId()).setId(container.id());
|
||||
}
|
||||
|
@@ -1261,8 +1261,7 @@ void Qt5InformationNodeInstanceServer::changeIds(const ChangeIdsCommand &command
|
||||
updateActiveSceneToEditView3D();
|
||||
} else {
|
||||
qint32 sceneInstanceId = sceneInstance.instanceId();
|
||||
const QVector<IdContainer> ids = command.ids();
|
||||
for (const auto &id : ids) {
|
||||
for (const auto &id : command.ids) {
|
||||
if (sceneInstanceId == id.instanceId()) {
|
||||
QMetaObject::invokeMethod(m_editView3DRootItem, "handleActiveSceneIdChange",
|
||||
Qt::QueuedConnection,
|
||||
|
@@ -125,7 +125,7 @@ void Qt5TestNodeInstanceServer::changeAuxiliaryValues(const ChangeAuxiliaryComma
|
||||
|
||||
void Qt5TestNodeInstanceServer::changeIds(const ChangeIdsCommand &command)
|
||||
{
|
||||
foreach (const IdContainer &container, command.ids()) {
|
||||
for (const IdContainer &container : command.ids) {
|
||||
if (hasInstanceForId(container.instanceId()))
|
||||
instanceForId(container.instanceId()).setId(container.id());
|
||||
}
|
||||
|
@@ -1146,7 +1146,7 @@ ChangeBindingsCommand NodeInstanceView::createChangeBindingCommand(const QList<B
|
||||
ChangeIdsCommand NodeInstanceView::createChangeIdsCommand(const QList<NodeInstance> &instanceList) const
|
||||
{
|
||||
QVector<IdContainer> containerList;
|
||||
foreach (const NodeInstance &instance, instanceList) {
|
||||
for (const NodeInstance &instance : instanceList) {
|
||||
QString id = instance.modelNode().id();
|
||||
if (!id.isEmpty()) {
|
||||
IdContainer container(instance.instanceId(), id);
|
||||
@@ -1154,7 +1154,7 @@ ChangeIdsCommand NodeInstanceView::createChangeIdsCommand(const QList<NodeInstan
|
||||
}
|
||||
}
|
||||
|
||||
return ChangeIdsCommand(containerList);
|
||||
return {containerList};
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user