forked from qt-creator/qt-creator
QmlPuppet: Refactor ChangeFileUrlCommand
Change-Id: I900f530109b6cdbb22d8138094443b48834d16cb Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -25,41 +25,14 @@
|
|||||||
|
|
||||||
#include "changefileurlcommand.h"
|
#include "changefileurlcommand.h"
|
||||||
|
|
||||||
#include <QDataStream>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
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)
|
QDebug operator <<(QDebug debug, const ChangeFileUrlCommand &command)
|
||||||
{
|
{
|
||||||
return debug.nospace() << "ChangeFileUrlCommand("
|
return debug.nospace() << "ChangeFileUrlCommand("
|
||||||
<< "fileUrl: " << command.fileUrl() << ")";
|
<< "fileUrl: " << command.fileUrl << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -26,29 +26,31 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <qmetatype.h>
|
#include <qmetatype.h>
|
||||||
|
#include <QDataStream>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class ChangeFileUrlCommand
|
class ChangeFileUrlCommand
|
||||||
{
|
{
|
||||||
friend QDataStream &operator>>(QDataStream &in, ChangeFileUrlCommand &command);
|
|
||||||
public:
|
public:
|
||||||
ChangeFileUrlCommand();
|
friend QDataStream &operator>>(QDataStream &in, ChangeFileUrlCommand &command)
|
||||||
explicit ChangeFileUrlCommand(const QUrl &fileUrl);
|
{
|
||||||
|
in >> command.fileUrl;
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
QUrl fileUrl() const;
|
friend QDataStream &operator<<(QDataStream &out, const ChangeFileUrlCommand &command)
|
||||||
|
{
|
||||||
|
out << command.fileUrl;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
friend QDebug operator <<(QDebug debug, const ChangeFileUrlCommand &command);
|
||||||
QUrl m_fileUrl;
|
|
||||||
|
QUrl fileUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
QDataStream &operator<<(QDataStream &out, const ChangeFileUrlCommand &command);
|
|
||||||
QDataStream &operator>>(QDataStream &in, ChangeFileUrlCommand &command);
|
|
||||||
|
|
||||||
QDebug operator <<(QDebug debug, const ChangeFileUrlCommand &command);
|
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QmlDesigner::ChangeFileUrlCommand)
|
Q_DECLARE_METATYPE(QmlDesigner::ChangeFileUrlCommand)
|
||||||
|
@@ -608,7 +608,7 @@ QList<ServerNodeInstance> NodeInstanceServer::setupInstances(const CreateSceneCo
|
|||||||
|
|
||||||
void NodeInstanceServer::changeFileUrl(const ChangeFileUrlCommand &command)
|
void NodeInstanceServer::changeFileUrl(const ChangeFileUrlCommand &command)
|
||||||
{
|
{
|
||||||
m_fileUrl = command.fileUrl();
|
m_fileUrl = command.fileUrl;
|
||||||
|
|
||||||
if (engine())
|
if (engine())
|
||||||
engine()->setBaseUrl(m_fileUrl);
|
engine()->setBaseUrl(m_fileUrl);
|
||||||
|
@@ -80,7 +80,7 @@ void Qt5TestNodeInstanceServer::createInstances(const CreateInstancesCommand &co
|
|||||||
|
|
||||||
void Qt5TestNodeInstanceServer::changeFileUrl(const ChangeFileUrlCommand &command)
|
void Qt5TestNodeInstanceServer::changeFileUrl(const ChangeFileUrlCommand &command)
|
||||||
{
|
{
|
||||||
setupFileUrl(command.fileUrl());
|
setupFileUrl(command.fileUrl);
|
||||||
|
|
||||||
refreshBindings();
|
refreshBindings();
|
||||||
collectItemChangesAndSendChangeCommands();
|
collectItemChangesAndSendChangeCommands();
|
||||||
|
@@ -1103,7 +1103,7 @@ ReparentInstancesCommand NodeInstanceView::createReparentInstancesCommand(const
|
|||||||
|
|
||||||
ChangeFileUrlCommand NodeInstanceView::createChangeFileUrlCommand(const QUrl &fileUrl) const
|
ChangeFileUrlCommand NodeInstanceView::createChangeFileUrlCommand(const QUrl &fileUrl) const
|
||||||
{
|
{
|
||||||
return ChangeFileUrlCommand(fileUrl);
|
return {fileUrl};
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeValuesCommand NodeInstanceView::createChangeValueCommand(const QList<VariantProperty>& propertyList) const
|
ChangeValuesCommand NodeInstanceView::createChangeValueCommand(const QList<VariantProperty>& propertyList) const
|
||||||
|
Reference in New Issue
Block a user