QmlPuppet: Refactor ChangeFileUrlCommand

Change-Id: I900f530109b6cdbb22d8138094443b48834d16cb
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Michael Winkelmann
2020-08-19 15:00:25 +02:00
parent 95aa7f42de
commit d39a6f656f
5 changed files with 18 additions and 43 deletions

View File

@@ -25,41 +25,14 @@
#include "changefileurlcommand.h"
#include <QDataStream>
#include <QDebug>
namespace QmlDesigner {
ChangeFileUrlCommand::ChangeFileUrlCommand() = default;
ChangeFileUrlCommand::ChangeFileUrlCommand(const QUrl &fileUrl)
: m_fileUrl(fileUrl)
{
}
QUrl ChangeFileUrlCommand::fileUrl() const
{
return m_fileUrl;
}
QDataStream &operator<<(QDataStream &out, const ChangeFileUrlCommand &command)
{
out << command.fileUrl();
return out;
}
QDataStream &operator>>(QDataStream &in, ChangeFileUrlCommand &command)
{
in >> command.m_fileUrl;
return in;
}
QDebug operator <<(QDebug debug, const ChangeFileUrlCommand &command)
{
return debug.nospace() << "ChangeFileUrlCommand("
<< "fileUrl: " << command.fileUrl() << ")";
<< "fileUrl: " << command.fileUrl << ")";
}
} // namespace QmlDesigner

View File

@@ -26,29 +26,31 @@
#pragma once
#include <qmetatype.h>
#include <QDataStream>
#include <QUrl>
namespace QmlDesigner {
class ChangeFileUrlCommand
{
friend QDataStream &operator>>(QDataStream &in, ChangeFileUrlCommand &command);
public:
ChangeFileUrlCommand();
explicit ChangeFileUrlCommand(const QUrl &fileUrl);
friend QDataStream &operator>>(QDataStream &in, ChangeFileUrlCommand &command)
{
in >> command.fileUrl;
return in;
}
QUrl fileUrl() const;
friend QDataStream &operator<<(QDataStream &out, const ChangeFileUrlCommand &command)
{
out << command.fileUrl;
return out;
}
private:
QUrl m_fileUrl;
friend QDebug operator <<(QDebug debug, const ChangeFileUrlCommand &command);
QUrl fileUrl;
};
QDataStream &operator<<(QDataStream &out, const ChangeFileUrlCommand &command);
QDataStream &operator>>(QDataStream &in, ChangeFileUrlCommand &command);
QDebug operator <<(QDebug debug, const ChangeFileUrlCommand &command);
} // namespace QmlDesigner
Q_DECLARE_METATYPE(QmlDesigner::ChangeFileUrlCommand)

View File

@@ -608,7 +608,7 @@ QList<ServerNodeInstance> NodeInstanceServer::setupInstances(const CreateSceneCo
void NodeInstanceServer::changeFileUrl(const ChangeFileUrlCommand &command)
{
m_fileUrl = command.fileUrl();
m_fileUrl = command.fileUrl;
if (engine())
engine()->setBaseUrl(m_fileUrl);

View File

@@ -80,7 +80,7 @@ void Qt5TestNodeInstanceServer::createInstances(const CreateInstancesCommand &co
void Qt5TestNodeInstanceServer::changeFileUrl(const ChangeFileUrlCommand &command)
{
setupFileUrl(command.fileUrl());
setupFileUrl(command.fileUrl);
refreshBindings();
collectItemChangesAndSendChangeCommands();

View File

@@ -1103,7 +1103,7 @@ ReparentInstancesCommand NodeInstanceView::createReparentInstancesCommand(const
ChangeFileUrlCommand NodeInstanceView::createChangeFileUrlCommand(const QUrl &fileUrl) const
{
return ChangeFileUrlCommand(fileUrl);
return {fileUrl};
}
ChangeValuesCommand NodeInstanceView::createChangeValueCommand(const QList<VariantProperty>& propertyList) const