forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/qds/dev'
Change-Id: I74bf2bfb1eacb60675640c47eb41ce51dd6eb99f
This commit is contained in:
23584
src/libs/3rdparty/json/json.hpp
vendored
23584
src/libs/3rdparty/json/json.hpp
vendored
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,7 @@ add_subdirectory(glsl)
|
||||
add_subdirectory(languageserverprotocol)
|
||||
add_subdirectory(sqlite)
|
||||
add_subdirectory(tracing)
|
||||
add_subdirectory(qmlpuppetcommunication)
|
||||
|
||||
add_subdirectory(qtcreatorcdbext)
|
||||
|
||||
|
||||
1
src/libs/qmlpuppetcommunication/CMakeLists.txt
Normal file
1
src/libs/qmlpuppetcommunication/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
include(QmlPuppetCommunication.cmake)
|
||||
87
src/libs/qmlpuppetcommunication/QmlPuppetCommunication.cmake
Normal file
87
src/libs/qmlpuppetcommunication/QmlPuppetCommunication.cmake
Normal file
@@ -0,0 +1,87 @@
|
||||
add_qtc_library(QmlPuppetCommunication STATIC
|
||||
PROPERTIES AUTOUIC OFF
|
||||
DEPENDS Qt5::Core Qt5::CorePrivate Qt5::Gui
|
||||
)
|
||||
|
||||
extend_qtc_library(QmlPuppetCommunication
|
||||
CONDITION TARGET Nanotrace
|
||||
PUBLIC_DEPENDS Nanotrace
|
||||
)
|
||||
|
||||
extend_qtc_library(QmlPuppetCommunication
|
||||
PUBLIC_INCLUDES ${CMAKE_CURRENT_LIST_DIR}/types
|
||||
SOURCES_PREFIX ${CMAKE_CURRENT_LIST_DIR}/types
|
||||
SOURCES
|
||||
enumeration.h
|
||||
)
|
||||
|
||||
extend_qtc_library(QmlPuppetCommunication
|
||||
PUBLIC_INCLUDES ${CMAKE_CURRENT_LIST_DIR}/interfaces
|
||||
SOURCES_PREFIX ${CMAKE_CURRENT_LIST_DIR}/interfaces
|
||||
SOURCES
|
||||
commondefines.h
|
||||
nodeinstanceclientinterface.h
|
||||
nodeinstanceserverinterface.cpp nodeinstanceserverinterface.h
|
||||
nodeinstanceglobal.h
|
||||
)
|
||||
|
||||
extend_qtc_library(QmlPuppetCommunication
|
||||
PUBLIC_INCLUDES ${CMAKE_CURRENT_LIST_DIR}/container
|
||||
SOURCES_PREFIX ${CMAKE_CURRENT_LIST_DIR}/container
|
||||
SOURCES
|
||||
addimportcontainer.cpp addimportcontainer.h
|
||||
idcontainer.cpp idcontainer.h
|
||||
imagecontainer.cpp imagecontainer.h
|
||||
informationcontainer.cpp informationcontainer.h
|
||||
instancecontainer.cpp instancecontainer.h
|
||||
mockuptypecontainer.cpp mockuptypecontainer.h
|
||||
propertyabstractcontainer.cpp propertyabstractcontainer.h
|
||||
propertybindingcontainer.cpp propertybindingcontainer.h
|
||||
propertyvaluecontainer.cpp propertyvaluecontainer.h
|
||||
reparentcontainer.cpp reparentcontainer.h
|
||||
sharedmemory.h
|
||||
$<IF:$<BOOL:${UNIX}>,sharedmemory_unix.cpp,sharedmemory_qt.cpp>
|
||||
)
|
||||
|
||||
extend_qtc_library(QmlPuppetCommunication
|
||||
PUBLIC_INCLUDES ${CMAKE_CURRENT_LIST_DIR}/commands
|
||||
SOURCES_PREFIX ${CMAKE_CURRENT_LIST_DIR}/commands
|
||||
SOURCES
|
||||
captureddatacommand.h
|
||||
changeauxiliarycommand.cpp changeauxiliarycommand.h
|
||||
changebindingscommand.cpp changebindingscommand.h
|
||||
changefileurlcommand.cpp changefileurlcommand.h
|
||||
changeidscommand.cpp changeidscommand.h
|
||||
changelanguagecommand.cpp changelanguagecommand.h
|
||||
changenodesourcecommand.cpp changenodesourcecommand.h
|
||||
changepreviewimagesizecommand.cpp changepreviewimagesizecommand.h
|
||||
changeselectioncommand.cpp changeselectioncommand.h
|
||||
changestatecommand.cpp changestatecommand.h
|
||||
changevaluescommand.cpp changevaluescommand.h
|
||||
childrenchangedcommand.cpp childrenchangedcommand.h
|
||||
clearscenecommand.cpp clearscenecommand.h
|
||||
completecomponentcommand.cpp completecomponentcommand.h
|
||||
componentcompletedcommand.cpp componentcompletedcommand.h
|
||||
createinstancescommand.cpp createinstancescommand.h
|
||||
createscenecommand.cpp createscenecommand.h
|
||||
debugoutputcommand.cpp debugoutputcommand.h
|
||||
endpuppetcommand.cpp endpuppetcommand.h
|
||||
informationchangedcommand.cpp informationchangedcommand.h
|
||||
inputeventcommand.cpp inputeventcommand.h
|
||||
nanotracecommand.cpp nanotracecommand.h
|
||||
pixmapchangedcommand.cpp pixmapchangedcommand.h
|
||||
puppetalivecommand.cpp puppetalivecommand.h
|
||||
puppettocreatorcommand.cpp puppettocreatorcommand.h
|
||||
removeinstancescommand.cpp removeinstancescommand.h
|
||||
removepropertiescommand.cpp removepropertiescommand.h
|
||||
removesharedmemorycommand.cpp removesharedmemorycommand.h
|
||||
reparentinstancescommand.cpp reparentinstancescommand.h
|
||||
requestmodelnodepreviewimagecommand.cpp requestmodelnodepreviewimagecommand.h
|
||||
scenecreatedcommand.h
|
||||
statepreviewimagechangedcommand.cpp statepreviewimagechangedcommand.h
|
||||
synchronizecommand.h
|
||||
tokencommand.cpp tokencommand.h
|
||||
update3dviewstatecommand.cpp update3dviewstatecommand.h
|
||||
valueschangedcommand.cpp valueschangedcommand.h
|
||||
view3dactioncommand.cpp view3dactioncommand.h
|
||||
)
|
||||
165
src/libs/qmlpuppetcommunication/commands/captureddatacommand.h
Normal file
165
src/libs/qmlpuppetcommunication/commands/captureddatacommand.h
Normal file
@@ -0,0 +1,165 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVariant>
|
||||
|
||||
#include "imagecontainer.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
template<typename Type>
|
||||
QDataStream &operator<<(QDataStream &out, const std::vector<Type> &vector)
|
||||
{
|
||||
out << quint64(vector.size());
|
||||
|
||||
for (auto &&entry : vector)
|
||||
out << entry;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
template<typename Type>
|
||||
QDataStream &operator>>(QDataStream &in, std::vector<Type> &vector)
|
||||
{
|
||||
vector.clear();
|
||||
|
||||
quint64 size;
|
||||
|
||||
in >> size;
|
||||
|
||||
vector.reserve(size);
|
||||
|
||||
for (quint64 i = 0; i < size; ++i) {
|
||||
Type entry;
|
||||
|
||||
in >> entry;
|
||||
|
||||
vector.push_back(std::move(entry));
|
||||
}
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
class CapturedDataCommand
|
||||
{
|
||||
public:
|
||||
struct Property
|
||||
{
|
||||
Property() = default;
|
||||
Property(QString key, QVariant value)
|
||||
: key(std::move(key))
|
||||
, value(std::move(value))
|
||||
{}
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const Property &property)
|
||||
{
|
||||
out << property.key;
|
||||
out << property.value;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in, Property &property)
|
||||
{
|
||||
in >> property.key;
|
||||
in >> property.value;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QString key;
|
||||
QVariant value;
|
||||
};
|
||||
|
||||
struct NodeData
|
||||
{
|
||||
friend QDataStream &operator<<(QDataStream &out, const NodeData &data)
|
||||
{
|
||||
out << data.nodeId;
|
||||
out << data.contentRect;
|
||||
out << data.sceneTransform;
|
||||
out << data.properties;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in, NodeData &data)
|
||||
{
|
||||
in >> data.nodeId;
|
||||
in >> data.contentRect;
|
||||
in >> data.sceneTransform;
|
||||
in >> data.properties;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
qint32 nodeId = -1;
|
||||
QRectF contentRect;
|
||||
QTransform sceneTransform;
|
||||
std::vector<Property> properties;
|
||||
};
|
||||
|
||||
struct StateData
|
||||
{
|
||||
friend QDataStream &operator<<(QDataStream &out, const StateData &data)
|
||||
{
|
||||
out << data.image;
|
||||
out << data.nodeData;
|
||||
out << data.nodeId;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in, StateData &data)
|
||||
{
|
||||
in >> data.image;
|
||||
in >> data.nodeData;
|
||||
in >> data.nodeId;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
ImageContainer image;
|
||||
std::vector<NodeData> nodeData;
|
||||
qint32 nodeId = -1;
|
||||
};
|
||||
|
||||
CapturedDataCommand() = default;
|
||||
|
||||
CapturedDataCommand(QVector<StateData> &&stateData)
|
||||
: stateData{std::move(stateData)}
|
||||
{}
|
||||
|
||||
CapturedDataCommand(QImage &&image)
|
||||
: image{std::move(image)}
|
||||
{}
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const CapturedDataCommand &command)
|
||||
{
|
||||
out << command.image;
|
||||
out << command.stateData;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in, CapturedDataCommand &command)
|
||||
{
|
||||
in >> command.image;
|
||||
in >> command.stateData;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
public:
|
||||
QImage image;
|
||||
QVector<StateData> stateData;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::CapturedDataCommand)
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "changeauxiliarycommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeAuxiliaryCommand &command)
|
||||
{
|
||||
return debug.nospace() << "ChangeAuxiliaryCommand(auxiliaryChanges: " << command.auxiliaryChanges << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
|
||||
#include "propertyvaluecontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ChangeAuxiliaryCommand
|
||||
{
|
||||
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);
|
||||
|
||||
QVector<PropertyValueContainer> auxiliaryChanges;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ChangeAuxiliaryCommand)
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "changebindingscommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeBindingsCommand &command)
|
||||
{
|
||||
return debug.nospace() << "PropertyValueContainer(bindingChanges: " << command.bindingChanges << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
|
||||
#include "propertybindingcontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ChangeBindingsCommand
|
||||
{
|
||||
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);
|
||||
|
||||
QVector<PropertyBindingContainer> bindingChanges;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ChangeBindingsCommand)
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "changefileurlcommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeFileUrlCommand &command)
|
||||
{
|
||||
return debug.nospace() << "ChangeFileUrlCommand("
|
||||
<< "fileUrl: " << command.fileUrl << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <qmetatype.h>
|
||||
#include <QDataStream>
|
||||
#include <QUrl>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ChangeFileUrlCommand
|
||||
{
|
||||
public:
|
||||
friend QDataStream &operator>>(QDataStream &in, ChangeFileUrlCommand &command)
|
||||
{
|
||||
in >> command.fileUrl;
|
||||
return in;
|
||||
}
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const ChangeFileUrlCommand &command)
|
||||
{
|
||||
out << command.fileUrl;
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDebug operator <<(QDebug debug, const ChangeFileUrlCommand &command);
|
||||
|
||||
QUrl fileUrl;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ChangeFileUrlCommand)
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "changeidscommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeIdsCommand &command)
|
||||
{
|
||||
return debug.nospace() << "ChangeIdsCommand(ids: " << command.ids << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
35
src/libs/qmlpuppetcommunication/commands/changeidscommand.h
Normal file
35
src/libs/qmlpuppetcommunication/commands/changeidscommand.h
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
#include <QDataStream>
|
||||
|
||||
#include "idcontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ChangeIdsCommand
|
||||
{
|
||||
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);
|
||||
|
||||
QVector<IdContainer> ids;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ChangeIdsCommand)
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "changelanguagecommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
QDebug operator<<(QDebug debug, const ChangeLanguageCommand &command)
|
||||
{
|
||||
return debug.nospace() << "ChangeLanguageCommand(" << command.language << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
#include <QDataStream>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ChangeLanguageCommand
|
||||
{
|
||||
public:
|
||||
ChangeLanguageCommand() = default;
|
||||
ChangeLanguageCommand(QString language) : language(std::move(language)) {
|
||||
}
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const ChangeLanguageCommand &command)
|
||||
{
|
||||
return out << command.language;
|
||||
}
|
||||
friend QDataStream &operator>>(QDataStream &in, ChangeLanguageCommand &command)
|
||||
{
|
||||
return in >> command.language;
|
||||
}
|
||||
|
||||
friend QDebug operator<<(QDebug debug, const ChangeLanguageCommand &command);
|
||||
|
||||
QString language;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ChangeLanguageCommand)
|
||||
@@ -0,0 +1,51 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "changenodesourcecommand.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
ChangeNodeSourceCommand::ChangeNodeSourceCommand() = default;
|
||||
|
||||
ChangeNodeSourceCommand::ChangeNodeSourceCommand(qint32 newInstanceId, const QString &newNodeSource)
|
||||
: m_instanceId(newInstanceId), m_nodeSource(newNodeSource)
|
||||
{
|
||||
}
|
||||
|
||||
qint32 ChangeNodeSourceCommand::instanceId() const
|
||||
{
|
||||
return m_instanceId;
|
||||
}
|
||||
|
||||
QString ChangeNodeSourceCommand::nodeSource() const
|
||||
{
|
||||
return m_nodeSource;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChangeNodeSourceCommand &command)
|
||||
{
|
||||
out << command.instanceId();
|
||||
out << command.nodeSource();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ChangeNodeSourceCommand &command)
|
||||
{
|
||||
in >> command.m_instanceId;
|
||||
in >> command.m_nodeSource;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeNodeSourceCommand &command)
|
||||
{
|
||||
return debug.nospace() << "ReparentInstancesCommand("
|
||||
<< "instanceId: " << command.m_instanceId
|
||||
<< "nodeSource: " << command.m_nodeSource << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
#include <QDataStream>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ChangeNodeSourceCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, ChangeNodeSourceCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const ChangeNodeSourceCommand &command);
|
||||
|
||||
public:
|
||||
ChangeNodeSourceCommand();
|
||||
explicit ChangeNodeSourceCommand(qint32 instanceId, const QString &nodeSource);
|
||||
qint32 instanceId() const;
|
||||
QString nodeSource() const;
|
||||
|
||||
private:
|
||||
qint32 m_instanceId;
|
||||
QString m_nodeSource;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChangeNodeSourceCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, ChangeNodeSourceCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeNodeSourceCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ChangeNodeSourceCommand)
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
#include "changepreviewimagesizecommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChangePreviewImageSizeCommand &command)
|
||||
{
|
||||
return out << command.size;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ChangePreviewImageSizeCommand &command)
|
||||
{
|
||||
return in >> command.size;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const ChangePreviewImageSizeCommand &command)
|
||||
{
|
||||
return debug.nospace() << "ChangePreviewImageSizeCommand(" << command.size << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QSize>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ChangePreviewImageSizeCommand
|
||||
{
|
||||
public:
|
||||
ChangePreviewImageSizeCommand() = default;
|
||||
ChangePreviewImageSizeCommand(const QSize &size)
|
||||
: size(size)
|
||||
{}
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const ChangePreviewImageSizeCommand &command);
|
||||
friend QDataStream &operator>>(QDataStream &in, ChangePreviewImageSizeCommand &command);
|
||||
friend QDebug operator<<(QDebug debug, const ChangePreviewImageSizeCommand &command);
|
||||
|
||||
public:
|
||||
QSize size;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ChangePreviewImageSizeCommand)
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright (C) 2019 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "changeselectioncommand.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
ChangeSelectionCommand::ChangeSelectionCommand() = default;
|
||||
|
||||
ChangeSelectionCommand::ChangeSelectionCommand(const QVector<qint32> &idVector)
|
||||
: m_instanceIdVector(idVector)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<qint32> ChangeSelectionCommand::instanceIds() const
|
||||
{
|
||||
return m_instanceIdVector;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChangeSelectionCommand &command)
|
||||
{
|
||||
out << command.instanceIds();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ChangeSelectionCommand &command)
|
||||
{
|
||||
in >> command.m_instanceIdVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeSelectionCommand &command)
|
||||
{
|
||||
return debug.nospace() << "ChangeSelectionCommand(instanceIdVector: " << command.m_instanceIdVector << ")";
|
||||
}
|
||||
|
||||
bool operator ==(const ChangeSelectionCommand &first, const ChangeSelectionCommand &second)
|
||||
{
|
||||
return first.m_instanceIdVector == second.m_instanceIdVector;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright (C) 2019 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
#include <QDataStream>
|
||||
|
||||
#include "instancecontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ChangeSelectionCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, ChangeSelectionCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const ChangeSelectionCommand &command);
|
||||
friend bool operator ==(const ChangeSelectionCommand &first,
|
||||
const ChangeSelectionCommand &second);
|
||||
|
||||
public:
|
||||
ChangeSelectionCommand();
|
||||
explicit ChangeSelectionCommand(const QVector<qint32> &idVector);
|
||||
|
||||
QVector<qint32> instanceIds() const;
|
||||
|
||||
private:
|
||||
QVector<qint32> m_instanceIdVector;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChangeSelectionCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, ChangeSelectionCommand &command);
|
||||
bool operator ==(const ChangeSelectionCommand &first, const ChangeSelectionCommand &second);
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeSelectionCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ChangeSelectionCommand)
|
||||
@@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "changestatecommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
ChangeStateCommand::ChangeStateCommand()
|
||||
: m_stateInstanceId(-1)
|
||||
{
|
||||
}
|
||||
|
||||
ChangeStateCommand::ChangeStateCommand(qint32 stateInstanceId)
|
||||
: m_stateInstanceId(stateInstanceId)
|
||||
{
|
||||
}
|
||||
|
||||
qint32 ChangeStateCommand::stateInstanceId() const
|
||||
{
|
||||
return m_stateInstanceId;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChangeStateCommand &command)
|
||||
{
|
||||
out << command.stateInstanceId();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ChangeStateCommand &command)
|
||||
{
|
||||
in >> command.m_stateInstanceId;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeStateCommand &command)
|
||||
{
|
||||
return debug.nospace() << "ChangeStateCommand(stateInstanceId: " << command.m_stateInstanceId << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
|
||||
#include "propertyvaluecontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ChangeStateCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, ChangeStateCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const ChangeStateCommand &command);
|
||||
|
||||
public:
|
||||
ChangeStateCommand();
|
||||
explicit ChangeStateCommand(qint32 stateInstanceId);
|
||||
|
||||
qint32 stateInstanceId() const;
|
||||
|
||||
private:
|
||||
qint32 m_stateInstanceId;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChangeStateCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, ChangeStateCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeStateCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ChangeStateCommand)
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "changevaluescommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
ChangeValuesCommand::ChangeValuesCommand() = default;
|
||||
|
||||
ChangeValuesCommand::ChangeValuesCommand(const QVector<PropertyValueContainer> &valueChangeVector)
|
||||
: m_valueChangeVector (valueChangeVector)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<PropertyValueContainer> ChangeValuesCommand::valueChanges() const
|
||||
{
|
||||
return m_valueChangeVector;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChangeValuesCommand &command)
|
||||
{
|
||||
out << command.valueChanges();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ChangeValuesCommand &command)
|
||||
{
|
||||
in >> command.m_valueChangeVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeValuesCommand &command)
|
||||
{
|
||||
return debug.nospace() << "ChangeValuesCommand(valueChanges: " << command.m_valueChangeVector << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
|
||||
#include "propertyvaluecontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ChangeValuesCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, ChangeValuesCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const ChangeValuesCommand &command);
|
||||
|
||||
public:
|
||||
ChangeValuesCommand();
|
||||
explicit ChangeValuesCommand(const QVector<PropertyValueContainer> &valueChangeVector);
|
||||
|
||||
QVector<PropertyValueContainer> valueChanges() const;
|
||||
|
||||
private:
|
||||
QVector<PropertyValueContainer> m_valueChangeVector;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChangeValuesCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, ChangeValuesCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChangeValuesCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ChangeValuesCommand)
|
||||
@@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "childrenchangedcommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
ChildrenChangedCommand::ChildrenChangedCommand()
|
||||
: m_parentInstanceId(-1)
|
||||
{
|
||||
}
|
||||
|
||||
ChildrenChangedCommand::ChildrenChangedCommand(qint32 parentInstanceId, const QVector<qint32> &children, const QVector<InformationContainer> &informationVector)
|
||||
: m_parentInstanceId(parentInstanceId),
|
||||
m_childrenVector(children),
|
||||
m_informationVector(informationVector)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<qint32> ChildrenChangedCommand::childrenInstances() const
|
||||
{
|
||||
return m_childrenVector;
|
||||
}
|
||||
|
||||
qint32 ChildrenChangedCommand::parentInstanceId() const
|
||||
{
|
||||
return m_parentInstanceId;
|
||||
}
|
||||
|
||||
QVector<InformationContainer> ChildrenChangedCommand::informations() const
|
||||
{
|
||||
return m_informationVector;
|
||||
}
|
||||
|
||||
void ChildrenChangedCommand::sort()
|
||||
{
|
||||
std::sort(m_childrenVector.begin(), m_childrenVector.end());
|
||||
std::sort(m_informationVector.begin(), m_informationVector.end());
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChildrenChangedCommand &command)
|
||||
{
|
||||
out << command.parentInstanceId();
|
||||
out << command.childrenInstances();
|
||||
out << command.informations();
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ChildrenChangedCommand &command)
|
||||
{
|
||||
in >> command.m_parentInstanceId;
|
||||
in >> command.m_childrenVector;
|
||||
in >> command.m_informationVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator ==(const ChildrenChangedCommand &first, const ChildrenChangedCommand &second)
|
||||
{
|
||||
return first.m_parentInstanceId == second.m_parentInstanceId
|
||||
&& first.m_childrenVector == second.m_childrenVector
|
||||
&& first.m_informationVector == second.m_informationVector;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const ChildrenChangedCommand &command)
|
||||
{
|
||||
return debug.nospace() << "ChildrenChangedCommand("
|
||||
<< "parentInstanceId: " << command.parentInstanceId() << ", "
|
||||
<< "children: " << command.childrenInstances() << ", "
|
||||
<< "informations: " << command.informations() << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
#include "informationcontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ChildrenChangedCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, ChildrenChangedCommand &command);
|
||||
friend bool operator ==(const ChildrenChangedCommand &first, const ChildrenChangedCommand &second);
|
||||
|
||||
public:
|
||||
ChildrenChangedCommand();
|
||||
explicit ChildrenChangedCommand(qint32 parentInstanceId, const QVector<qint32> &childrenInstancesconst, const QVector<InformationContainer> &informationVector);
|
||||
|
||||
QVector<qint32> childrenInstances() const;
|
||||
qint32 parentInstanceId() const;
|
||||
QVector<InformationContainer> informations() const;
|
||||
|
||||
void sort();
|
||||
|
||||
private:
|
||||
qint32 m_parentInstanceId;
|
||||
QVector<qint32> m_childrenVector;
|
||||
QVector<InformationContainer> m_informationVector;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ChildrenChangedCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, ChildrenChangedCommand &command);
|
||||
|
||||
bool operator ==(const ChildrenChangedCommand &first, const ChildrenChangedCommand &second);
|
||||
QDebug operator <<(QDebug debug, const ChildrenChangedCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ChildrenChangedCommand)
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "clearscenecommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
ClearSceneCommand::ClearSceneCommand() = default;
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ClearSceneCommand &/*command*/)
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ClearSceneCommand &/*command*/)
|
||||
{
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const ClearSceneCommand &/*command*/)
|
||||
{
|
||||
return debug.nospace() << "ClearSceneCommand()";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
23
src/libs/qmlpuppetcommunication/commands/clearscenecommand.h
Normal file
23
src/libs/qmlpuppetcommunication/commands/clearscenecommand.h
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <qmetatype.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ClearSceneCommand
|
||||
{
|
||||
public:
|
||||
ClearSceneCommand();
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ClearSceneCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, ClearSceneCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const ClearSceneCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ClearSceneCommand)
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "completecomponentcommand.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
CompleteComponentCommand::CompleteComponentCommand() = default;
|
||||
|
||||
CompleteComponentCommand::CompleteComponentCommand(const QVector<qint32> &container)
|
||||
: m_instanceVector(container)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<qint32> CompleteComponentCommand::instances() const
|
||||
{
|
||||
return m_instanceVector;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CompleteComponentCommand &command)
|
||||
{
|
||||
out << command.instances();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, CompleteComponentCommand &command)
|
||||
{
|
||||
in >> command.m_instanceVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const CompleteComponentCommand &command)
|
||||
{
|
||||
return debug.nospace() << "CompleteComponentCommand(instances: " << command.m_instanceVector << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
#include <QDataStream>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class CompleteComponentCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, CompleteComponentCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const CompleteComponentCommand &command);
|
||||
|
||||
public:
|
||||
CompleteComponentCommand();
|
||||
explicit CompleteComponentCommand(const QVector<qint32> &container);
|
||||
|
||||
QVector<qint32> instances() const;
|
||||
|
||||
private:
|
||||
QVector<qint32> m_instanceVector;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CompleteComponentCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, CompleteComponentCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const CompleteComponentCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::CompleteComponentCommand)
|
||||
@@ -0,0 +1,56 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "componentcompletedcommand.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
ComponentCompletedCommand::ComponentCompletedCommand() = default;
|
||||
|
||||
ComponentCompletedCommand::ComponentCompletedCommand(const QVector<qint32> &container)
|
||||
: m_instanceVector(container)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<qint32> ComponentCompletedCommand::instances() const
|
||||
{
|
||||
return m_instanceVector;
|
||||
}
|
||||
|
||||
void ComponentCompletedCommand::sort()
|
||||
{
|
||||
std::sort(m_instanceVector.begin(), m_instanceVector.end());
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ComponentCompletedCommand &command)
|
||||
{
|
||||
out << command.instances();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ComponentCompletedCommand &command)
|
||||
{
|
||||
in >> command.m_instanceVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator ==(const ComponentCompletedCommand &first, const ComponentCompletedCommand &second)
|
||||
{
|
||||
return first.m_instanceVector == second.m_instanceVector;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const ComponentCompletedCommand &command)
|
||||
{
|
||||
return debug.nospace() << "ComponentCompletedCommand(" << command.instances() << ")";
|
||||
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
#include <QDataStream>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ComponentCompletedCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, ComponentCompletedCommand &command);
|
||||
friend bool operator ==(const ComponentCompletedCommand &first, const ComponentCompletedCommand &second);
|
||||
|
||||
public:
|
||||
ComponentCompletedCommand();
|
||||
explicit ComponentCompletedCommand(const QVector<qint32> &container);
|
||||
|
||||
QVector<qint32> instances() const;
|
||||
|
||||
void sort();
|
||||
|
||||
private:
|
||||
QVector<qint32> m_instanceVector;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ComponentCompletedCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, ComponentCompletedCommand &command);
|
||||
|
||||
bool operator ==(const ComponentCompletedCommand &first, const ComponentCompletedCommand &second);
|
||||
QDebug operator <<(QDebug debug, const ComponentCompletedCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ComponentCompletedCommand)
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "createinstancescommand.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
CreateInstancesCommand::CreateInstancesCommand() = default;
|
||||
|
||||
CreateInstancesCommand::CreateInstancesCommand(const QVector<InstanceContainer> &container)
|
||||
: m_instanceVector(container)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<InstanceContainer> CreateInstancesCommand::instances() const
|
||||
{
|
||||
return m_instanceVector;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CreateInstancesCommand &command)
|
||||
{
|
||||
out << command.instances();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, CreateInstancesCommand &command)
|
||||
{
|
||||
in >> command.m_instanceVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const CreateInstancesCommand &command)
|
||||
{
|
||||
return debug.nospace() << "CreateInstancesCommand(" << command.instances() << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
|
||||
#include "instancecontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class CreateInstancesCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, CreateInstancesCommand &command);
|
||||
|
||||
public:
|
||||
CreateInstancesCommand();
|
||||
explicit CreateInstancesCommand(const QVector<InstanceContainer> &container);
|
||||
|
||||
QVector<InstanceContainer> instances() const;
|
||||
|
||||
private:
|
||||
QVector<InstanceContainer> m_instanceVector;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CreateInstancesCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, CreateInstancesCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const CreateInstancesCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::CreateInstancesCommand)
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "createscenecommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
QDebug operator <<(QDebug debug, const CreateSceneCommand &command)
|
||||
{
|
||||
return debug.nospace() << "CreateSceneCommand("
|
||||
<< "instances: " << command.instances << ", "
|
||||
<< "reparentInstances: " << command.reparentInstances << ", "
|
||||
<< "ids: " << command.ids << ", "
|
||||
<< "valueChanges: " << command.valueChanges << ", "
|
||||
<< "bindingChanges: " << command.bindingChanges << ", "
|
||||
<< "auxiliaryChanges: " << command.auxiliaryChanges << ", "
|
||||
<< "imports: " << command.imports << ", "
|
||||
<< "mockupTypes: " << command.mockupTypes << ", "
|
||||
<< "fileUrl: " << command.fileUrl << ", "
|
||||
<< "resourceUrl: " << command.resourceUrl << ", "
|
||||
<< "edit3dToolStates: " << command.edit3dToolStates << ", "
|
||||
<< "language: " << command.language << ")";
|
||||
}
|
||||
|
||||
}
|
||||
133
src/libs/qmlpuppetcommunication/commands/createscenecommand.h
Normal file
133
src/libs/qmlpuppetcommunication/commands/createscenecommand.h
Normal file
@@ -0,0 +1,133 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QSize>
|
||||
#include <QUrl>
|
||||
#include <QVector>
|
||||
#include <QList>
|
||||
#include <QColor>
|
||||
#include <qmetatype.h>
|
||||
|
||||
#include "instancecontainer.h"
|
||||
#include "reparentcontainer.h"
|
||||
#include "idcontainer.h"
|
||||
#include "mockuptypecontainer.h"
|
||||
#include "propertyvaluecontainer.h"
|
||||
#include "propertybindingcontainer.h"
|
||||
#include "addimportcontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class CreateSceneCommand
|
||||
{
|
||||
public:
|
||||
CreateSceneCommand() = default;
|
||||
explicit CreateSceneCommand(const QVector<InstanceContainer> &instanceContainer,
|
||||
const QVector<ReparentContainer> &reparentContainer,
|
||||
const QVector<IdContainer> &idVector,
|
||||
const QVector<PropertyValueContainer> &valueChangeVector,
|
||||
const QVector<PropertyBindingContainer> &bindingChangeVector,
|
||||
const QVector<PropertyValueContainer> &auxiliaryChangeVector,
|
||||
const QVector<AddImportContainer> &importVector,
|
||||
const QVector<MockupTypeContainer> &mockupTypeVector,
|
||||
const QUrl &fileUrl,
|
||||
const QUrl &resourceUrl,
|
||||
const QHash<QString, QVariantMap> &edit3dToolStates,
|
||||
const QString &language,
|
||||
QSize captureImageMinimumSize,
|
||||
QSize captureImageMaximumSize,
|
||||
qint32 stateInstanceId,
|
||||
const QList<QColor> &edit3dBackgroundColor,
|
||||
const QColor &edit3dGridColor)
|
||||
: instances(instanceContainer)
|
||||
, reparentInstances(reparentContainer)
|
||||
, ids(idVector)
|
||||
, valueChanges(valueChangeVector)
|
||||
, bindingChanges(bindingChangeVector)
|
||||
, auxiliaryChanges(auxiliaryChangeVector)
|
||||
, imports(importVector)
|
||||
, mockupTypes(mockupTypeVector)
|
||||
, fileUrl(fileUrl)
|
||||
, resourceUrl(resourceUrl)
|
||||
, edit3dToolStates(edit3dToolStates)
|
||||
, language(language)
|
||||
, captureImageMinimumSize(captureImageMinimumSize)
|
||||
, captureImageMaximumSize(captureImageMaximumSize)
|
||||
, stateInstanceId{stateInstanceId}
|
||||
, edit3dBackgroundColor{edit3dBackgroundColor}
|
||||
, edit3dGridColor{edit3dGridColor}
|
||||
{}
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const CreateSceneCommand &command)
|
||||
{
|
||||
out << command.instances;
|
||||
out << command.reparentInstances;
|
||||
out << command.ids;
|
||||
out << command.valueChanges;
|
||||
out << command.bindingChanges;
|
||||
out << command.auxiliaryChanges;
|
||||
out << command.imports;
|
||||
out << command.mockupTypes;
|
||||
out << command.fileUrl;
|
||||
out << command.resourceUrl;
|
||||
out << command.edit3dToolStates;
|
||||
out << command.language;
|
||||
out << command.stateInstanceId;
|
||||
out << command.captureImageMinimumSize;
|
||||
out << command.captureImageMaximumSize;
|
||||
out << command.edit3dBackgroundColor;
|
||||
out << command.edit3dGridColor;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in, CreateSceneCommand &command)
|
||||
{
|
||||
in >> command.instances;
|
||||
in >> command.reparentInstances;
|
||||
in >> command.ids;
|
||||
in >> command.valueChanges;
|
||||
in >> command.bindingChanges;
|
||||
in >> command.auxiliaryChanges;
|
||||
in >> command.imports;
|
||||
in >> command.mockupTypes;
|
||||
in >> command.fileUrl;
|
||||
in >> command.resourceUrl;
|
||||
in >> command.edit3dToolStates;
|
||||
in >> command.language;
|
||||
in >> command.stateInstanceId;
|
||||
in >> command.captureImageMinimumSize;
|
||||
in >> command.captureImageMaximumSize;
|
||||
in >> command.edit3dBackgroundColor;
|
||||
in >> command.edit3dGridColor;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
public:
|
||||
QVector<InstanceContainer> instances;
|
||||
QVector<ReparentContainer> reparentInstances;
|
||||
QVector<IdContainer> ids;
|
||||
QVector<PropertyValueContainer> valueChanges;
|
||||
QVector<PropertyBindingContainer> bindingChanges;
|
||||
QVector<PropertyValueContainer> auxiliaryChanges;
|
||||
QVector<AddImportContainer> imports;
|
||||
QVector<MockupTypeContainer> mockupTypes;
|
||||
QUrl fileUrl;
|
||||
QUrl resourceUrl;
|
||||
QHash<QString, QVariantMap> edit3dToolStates;
|
||||
QString language;
|
||||
QSize captureImageMinimumSize;
|
||||
QSize captureImageMaximumSize;
|
||||
qint32 stateInstanceId = 0;
|
||||
QList<QColor> edit3dBackgroundColor;
|
||||
QColor edit3dGridColor;
|
||||
};
|
||||
|
||||
QDebug operator<<(QDebug debug, const CreateSceneCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::CreateSceneCommand)
|
||||
@@ -0,0 +1,65 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "debugoutputcommand.h"
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
DebugOutputCommand::DebugOutputCommand() = default;
|
||||
|
||||
DebugOutputCommand::DebugOutputCommand(const QString &text, DebugOutputCommand::Type type, const QVector<qint32> &instanceIds)
|
||||
: m_instanceIds(instanceIds)
|
||||
, m_text(text)
|
||||
, m_type(type)
|
||||
{
|
||||
}
|
||||
|
||||
qint32 DebugOutputCommand::type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
QString DebugOutputCommand::text() const
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
QVector<qint32> DebugOutputCommand::instanceIds() const
|
||||
{
|
||||
return m_instanceIds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const DebugOutputCommand &command)
|
||||
{
|
||||
out << command.type();
|
||||
out << command.text();
|
||||
out << command.instanceIds();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, DebugOutputCommand &command)
|
||||
{
|
||||
in >> command.m_type;
|
||||
in >> command.m_text;
|
||||
in >> command.m_instanceIds;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator ==(const DebugOutputCommand &first, const DebugOutputCommand &second)
|
||||
{
|
||||
return first.m_type == second.m_type
|
||||
&& first.m_text == second.m_text;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const DebugOutputCommand &command)
|
||||
{
|
||||
return debug.nospace() << "DebugOutputCommand("
|
||||
<< "type: " << command.type() << ", "
|
||||
<< "text: " << command.text() << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
#include <QDataStream>
|
||||
#include <QVector>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class DebugOutputCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, DebugOutputCommand &command);
|
||||
friend bool operator ==(const DebugOutputCommand &first, const DebugOutputCommand &second);
|
||||
|
||||
public:
|
||||
enum Type {
|
||||
DebugType,
|
||||
WarningType,
|
||||
ErrorType,
|
||||
FatalType
|
||||
};
|
||||
|
||||
DebugOutputCommand();
|
||||
explicit DebugOutputCommand(const QString &text, Type type, const QVector<qint32> &instanceIds);
|
||||
|
||||
qint32 type() const;
|
||||
QString text() const;
|
||||
QVector<qint32> instanceIds() const;
|
||||
|
||||
private:
|
||||
QVector<qint32> m_instanceIds;
|
||||
QString m_text;
|
||||
quint32 m_type;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const DebugOutputCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, DebugOutputCommand &command);
|
||||
|
||||
bool operator ==(const DebugOutputCommand &first, const DebugOutputCommand &second);
|
||||
QDebug operator <<(QDebug debug, const DebugOutputCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::DebugOutputCommand)
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "endpuppetcommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
EndPuppetCommand::EndPuppetCommand() = default;
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const EndPuppetCommand &/*command*/)
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, EndPuppetCommand &/*command*/)
|
||||
{
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const EndPuppetCommand &/*command*/)
|
||||
{
|
||||
return debug.nospace() << "EndPuppetCommand()";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
23
src/libs/qmlpuppetcommunication/commands/endpuppetcommand.h
Normal file
23
src/libs/qmlpuppetcommunication/commands/endpuppetcommand.h
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <qmetatype.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class EndPuppetCommand
|
||||
{
|
||||
public:
|
||||
EndPuppetCommand();
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const EndPuppetCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, EndPuppetCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const EndPuppetCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::EndPuppetCommand)
|
||||
@@ -0,0 +1,57 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "informationchangedcommand.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QtDebug>
|
||||
|
||||
#include "propertyvaluecontainer.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
InformationChangedCommand::InformationChangedCommand() = default;
|
||||
|
||||
InformationChangedCommand::InformationChangedCommand(const QVector<InformationContainer> &informationVector)
|
||||
: m_informationVector(informationVector)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<InformationContainer> InformationChangedCommand::informations() const
|
||||
{
|
||||
return m_informationVector;
|
||||
}
|
||||
|
||||
void InformationChangedCommand::sort()
|
||||
{
|
||||
std::sort(m_informationVector.begin(), m_informationVector.end());
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const InformationChangedCommand &command)
|
||||
{
|
||||
out << command.informations();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, InformationChangedCommand &command)
|
||||
{
|
||||
in >> command.m_informationVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator ==(const InformationChangedCommand &first, const InformationChangedCommand &second)
|
||||
{
|
||||
return first.m_informationVector == second.m_informationVector;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const InformationChangedCommand &command)
|
||||
{
|
||||
return debug.nospace() << "InformationChangedCommand(" << command.informations() << ")";
|
||||
}
|
||||
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
|
||||
#include "informationcontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class InformationChangedCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, InformationChangedCommand &command);
|
||||
friend bool operator ==(const InformationChangedCommand &first, const InformationChangedCommand &second);
|
||||
|
||||
public:
|
||||
InformationChangedCommand();
|
||||
explicit InformationChangedCommand(const QVector<InformationContainer> &informationVector);
|
||||
|
||||
QVector<InformationContainer> informations() const;
|
||||
|
||||
void sort();
|
||||
|
||||
private:
|
||||
QVector<InformationContainer> m_informationVector;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const InformationChangedCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, InformationChangedCommand &command);
|
||||
|
||||
bool operator ==(const InformationChangedCommand &first, const InformationChangedCommand &second);
|
||||
QDebug operator <<(QDebug debug, const InformationChangedCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::InformationChangedCommand)
|
||||
@@ -0,0 +1,88 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "inputeventcommand.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
InputEventCommand::InputEventCommand() = default;
|
||||
|
||||
InputEventCommand::InputEventCommand(QInputEvent *e)
|
||||
: m_type(e->type()),
|
||||
m_modifiers(e->modifiers())
|
||||
{
|
||||
if (m_type == QEvent::Wheel) {
|
||||
auto we = static_cast<QWheelEvent *>(e);
|
||||
#if QT_VERSION <= QT_VERSION_CHECK(5, 15, 0)
|
||||
m_pos = we->pos();
|
||||
#else
|
||||
m_pos = we->position().toPoint();
|
||||
#endif
|
||||
m_buttons = we->buttons();
|
||||
m_angleDelta = we->angleDelta().y();
|
||||
} else if (m_type == QEvent::KeyPress || m_type == QEvent::KeyRelease) {
|
||||
auto ke = static_cast<QKeyEvent *>(e);
|
||||
m_key = ke->key();
|
||||
m_count = ke->count();
|
||||
m_autoRepeat = ke->isAutoRepeat();
|
||||
} else {
|
||||
auto me = static_cast<QMouseEvent *>(e);
|
||||
m_pos = me->pos();
|
||||
m_button = me->button();
|
||||
m_buttons = me->buttons();
|
||||
}
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const InputEventCommand &command)
|
||||
{
|
||||
out << int(command.type());
|
||||
out << command.pos();
|
||||
out << int(command.button());
|
||||
out << command.buttons();
|
||||
out << command.modifiers();
|
||||
out << command.angleDelta();
|
||||
out << command.key();
|
||||
out << command.count();
|
||||
out << command.autoRepeat();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, InputEventCommand &command)
|
||||
{
|
||||
int type;
|
||||
int button;
|
||||
in >> type;
|
||||
command.m_type = (QEvent::Type)type;
|
||||
in >> command.m_pos;
|
||||
in >> button;
|
||||
command.m_button = (Qt::MouseButton)button;
|
||||
in >> command.m_buttons;
|
||||
in >> command.m_modifiers;
|
||||
in >> command.m_angleDelta;
|
||||
in >> command.m_key;
|
||||
in >> command.m_count;
|
||||
in >> command.m_autoRepeat;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const InputEventCommand &command)
|
||||
{
|
||||
return debug.nospace() << "InputEventCommand("
|
||||
<< "type: " << command.type() << ", "
|
||||
<< "pos: " << command.pos() << ", "
|
||||
<< "button: " << command.button() << ", "
|
||||
<< "buttons: " << command.buttons() << ", "
|
||||
<< "modifiers: " << command.modifiers() << ", "
|
||||
<< "angleDelta: " << command.angleDelta() << ", "
|
||||
<< "key: " << command.key() << ", "
|
||||
<< "count: " << command.count() << ", "
|
||||
<< "autoRepeat: " << command.autoRepeat() << ")";
|
||||
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
58
src/libs/qmlpuppetcommunication/commands/inputeventcommand.h
Normal file
58
src/libs/qmlpuppetcommunication/commands/inputeventcommand.h
Normal file
@@ -0,0 +1,58 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/qmetatype.h>
|
||||
#include <QtCore/qdatastream.h>
|
||||
#include <QtGui/qevent.h>
|
||||
|
||||
#include "instancecontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class InputEventCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, InputEventCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const InputEventCommand &command);
|
||||
|
||||
public:
|
||||
InputEventCommand();
|
||||
explicit InputEventCommand(QInputEvent *e);
|
||||
|
||||
QEvent::Type type() const { return m_type; }
|
||||
QPoint pos() const { return m_pos; }
|
||||
Qt::MouseButton button() const { return m_button; }
|
||||
Qt::MouseButtons buttons() const { return m_buttons; }
|
||||
Qt::KeyboardModifiers modifiers() const { return m_modifiers; }
|
||||
int angleDelta() const { return m_angleDelta; }
|
||||
int key() const { return m_key; }
|
||||
int count() const { return m_count; }
|
||||
bool autoRepeat() const { return m_autoRepeat; }
|
||||
|
||||
private:
|
||||
QEvent::Type m_type = QEvent::None;
|
||||
Qt::KeyboardModifiers m_modifiers = Qt::NoModifier;
|
||||
|
||||
// Mouse events
|
||||
QPoint m_pos;
|
||||
Qt::MouseButton m_button = Qt::NoButton;
|
||||
Qt::MouseButtons m_buttons = Qt::NoButton;
|
||||
|
||||
// Wheel events
|
||||
int m_angleDelta = 0;
|
||||
|
||||
// Key events
|
||||
int m_key = 0;
|
||||
int m_count = 1;
|
||||
bool m_autoRepeat = false;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const InputEventCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, InputEventCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const InputEventCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::InputEventCommand)
|
||||
@@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "nanotracecommand.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
StartNanotraceCommand::StartNanotraceCommand(const QString &path)
|
||||
: m_filePath(path)
|
||||
{ }
|
||||
|
||||
QString StartNanotraceCommand::path() const
|
||||
{
|
||||
return m_filePath;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const StartNanotraceCommand &command)
|
||||
{
|
||||
out << command.m_filePath;
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, StartNanotraceCommand &command)
|
||||
{
|
||||
in >> command.m_filePath;
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const StartNanotraceCommand &command)
|
||||
{
|
||||
return debug.nospace() << "StartNanotraceCommand(" << command.m_filePath << ")";
|
||||
}
|
||||
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const EndNanotraceCommand &/*command*/)
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, EndNanotraceCommand &/*command*/)
|
||||
{
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const EndNanotraceCommand &/*command*/)
|
||||
{
|
||||
return debug.nospace() << "EndNanotraceCommand()";
|
||||
}
|
||||
|
||||
|
||||
SyncNanotraceCommand::SyncNanotraceCommand(const QString &name)
|
||||
: m_name(name)
|
||||
{ }
|
||||
|
||||
QString SyncNanotraceCommand::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, SyncNanotraceCommand &command)
|
||||
{
|
||||
in >> command.m_name;
|
||||
return in;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const SyncNanotraceCommand &command)
|
||||
{
|
||||
out << command.m_name;
|
||||
return out;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const SyncNanotraceCommand &command)
|
||||
{
|
||||
return debug.nospace() << "SyncNanotraceCommand(" << command.m_name << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
55
src/libs/qmlpuppetcommunication/commands/nanotracecommand.h
Normal file
55
src/libs/qmlpuppetcommunication/commands/nanotracecommand.h
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class StartNanotraceCommand
|
||||
{
|
||||
public:
|
||||
StartNanotraceCommand() = default;
|
||||
StartNanotraceCommand(const QString &path);
|
||||
QString path() const;
|
||||
friend QDataStream &operator<<(QDataStream &out, const StartNanotraceCommand &command);
|
||||
friend QDataStream &operator>>(QDataStream &in, StartNanotraceCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const StartNanotraceCommand &command);
|
||||
private:
|
||||
QString m_filePath;
|
||||
};
|
||||
|
||||
|
||||
class EndNanotraceCommand
|
||||
{
|
||||
public:
|
||||
EndNanotraceCommand() = default;
|
||||
friend QDataStream &operator<<(QDataStream &out, const EndNanotraceCommand &command);
|
||||
friend QDataStream &operator>>(QDataStream &in, EndNanotraceCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const EndNanotraceCommand &command);
|
||||
};
|
||||
|
||||
|
||||
class SyncNanotraceCommand
|
||||
{
|
||||
public:
|
||||
SyncNanotraceCommand() = default;
|
||||
SyncNanotraceCommand(const QString& name);
|
||||
QString name() const;
|
||||
friend QDataStream &operator>>(QDataStream &in, SyncNanotraceCommand &command);
|
||||
friend QDataStream &operator<<(QDataStream &out, const SyncNanotraceCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const SyncNanotraceCommand &command);
|
||||
private:
|
||||
QString m_name;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::StartNanotraceCommand)
|
||||
Q_DECLARE_METATYPE(QmlDesigner::EndNanotraceCommand)
|
||||
Q_DECLARE_METATYPE(QmlDesigner::SyncNanotraceCommand)
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "pixmapchangedcommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <QVarLengthArray>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
PixmapChangedCommand::PixmapChangedCommand() = default;
|
||||
|
||||
PixmapChangedCommand::PixmapChangedCommand(const QVector<ImageContainer> &imageVector)
|
||||
: m_imageVector(imageVector)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<ImageContainer> PixmapChangedCommand::images() const
|
||||
{
|
||||
return m_imageVector;
|
||||
}
|
||||
|
||||
void PixmapChangedCommand::sort()
|
||||
{
|
||||
std::sort(m_imageVector.begin(), m_imageVector.end());
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const PixmapChangedCommand &command)
|
||||
{
|
||||
out << command.images();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, PixmapChangedCommand &command)
|
||||
{
|
||||
in >> command.m_imageVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator ==(const PixmapChangedCommand &first, const PixmapChangedCommand &second)
|
||||
{
|
||||
return first.m_imageVector == second.m_imageVector;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const PixmapChangedCommand &command)
|
||||
{
|
||||
return debug.nospace() << "PixmapChangedCommand(" << command.images() << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include "imagecontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class PixmapChangedCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, PixmapChangedCommand &command);
|
||||
friend bool operator ==(const PixmapChangedCommand &first, const PixmapChangedCommand &second);
|
||||
|
||||
public:
|
||||
PixmapChangedCommand();
|
||||
explicit PixmapChangedCommand(const QVector<ImageContainer> &imageVector);
|
||||
|
||||
QVector<ImageContainer> images() const;
|
||||
|
||||
void sort();
|
||||
|
||||
private:
|
||||
QVector<ImageContainer> m_imageVector;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const PixmapChangedCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, PixmapChangedCommand &command);
|
||||
|
||||
bool operator ==(const PixmapChangedCommand &first, const PixmapChangedCommand &second);
|
||||
QDebug operator <<(QDebug debug, const PixmapChangedCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::PixmapChangedCommand)
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "puppetalivecommand.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
PuppetAliveCommand::PuppetAliveCommand() = default;
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const PuppetAliveCommand &/*command*/)
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, PuppetAliveCommand &/*command*/)
|
||||
{
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const PuppetAliveCommand &/*command*/)
|
||||
{
|
||||
return debug.nospace() << "PuppetAliveCommand()";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class PuppetAliveCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, PuppetAliveCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const PuppetAliveCommand &command);
|
||||
|
||||
public:
|
||||
PuppetAliveCommand();
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const PuppetAliveCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, PuppetAliveCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const PuppetAliveCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::PuppetAliveCommand)
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "puppettocreatorcommand.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
// A generic command that can hold a variant data from puppet to creator
|
||||
|
||||
PuppetToCreatorCommand::PuppetToCreatorCommand(Type type, const QVariant &data)
|
||||
: m_type(type)
|
||||
, m_data(data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const PuppetToCreatorCommand &command)
|
||||
{
|
||||
out << qint32(command.type());
|
||||
out << command.data();
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, PuppetToCreatorCommand &command)
|
||||
{
|
||||
qint32 type;
|
||||
in >> type;
|
||||
command.m_type = PuppetToCreatorCommand::Type(type);
|
||||
in >> command.m_data;
|
||||
return in;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <qmetatype.h>
|
||||
#include <QDataStream>
|
||||
#include <QVariant>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class PuppetToCreatorCommand
|
||||
{
|
||||
public:
|
||||
enum Type {
|
||||
Edit3DToolState,
|
||||
Render3DView,
|
||||
ActiveSceneChanged,
|
||||
RenderModelNodePreviewImage,
|
||||
Import3DSupport,
|
||||
NodeAtPos,
|
||||
None };
|
||||
|
||||
PuppetToCreatorCommand(Type type, const QVariant &data);
|
||||
PuppetToCreatorCommand() = default;
|
||||
|
||||
Type type() const { return m_type; }
|
||||
QVariant data() const { return m_data; }
|
||||
|
||||
private:
|
||||
Type m_type = None;
|
||||
QVariant m_data;
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in, PuppetToCreatorCommand &command);
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const PuppetToCreatorCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, PuppetToCreatorCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::PuppetToCreatorCommand)
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "removeinstancescommand.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
RemoveInstancesCommand::RemoveInstancesCommand() = default;
|
||||
|
||||
RemoveInstancesCommand::RemoveInstancesCommand(const QVector<qint32> &idVector)
|
||||
: m_instanceIdVector(idVector)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<qint32> RemoveInstancesCommand::instanceIds() const
|
||||
{
|
||||
return m_instanceIdVector;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const RemoveInstancesCommand &command)
|
||||
{
|
||||
out << command.instanceIds();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, RemoveInstancesCommand &command)
|
||||
{
|
||||
in >> command.m_instanceIdVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const RemoveInstancesCommand &command)
|
||||
{
|
||||
return debug.nospace() << "RemoveInstancesCommand(instanceIdVector: " << command.m_instanceIdVector << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
#include <QDataStream>
|
||||
|
||||
#include "instancecontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class RemoveInstancesCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, RemoveInstancesCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const RemoveInstancesCommand &command);
|
||||
|
||||
public:
|
||||
RemoveInstancesCommand();
|
||||
explicit RemoveInstancesCommand(const QVector<qint32> &idVector);
|
||||
|
||||
QVector<qint32> instanceIds() const;
|
||||
|
||||
private:
|
||||
QVector<qint32> m_instanceIdVector;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const RemoveInstancesCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, RemoveInstancesCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const RemoveInstancesCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::RemoveInstancesCommand)
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "removepropertiescommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
RemovePropertiesCommand::RemovePropertiesCommand() = default;
|
||||
|
||||
RemovePropertiesCommand::RemovePropertiesCommand(const QVector<PropertyAbstractContainer> &properties)
|
||||
: m_properties(properties)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<PropertyAbstractContainer> RemovePropertiesCommand::properties() const
|
||||
{
|
||||
return m_properties;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const RemovePropertiesCommand &command)
|
||||
{
|
||||
out << command.properties();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, RemovePropertiesCommand &command)
|
||||
{
|
||||
in >> command.m_properties;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const RemovePropertiesCommand &command)
|
||||
{
|
||||
return debug.nospace() << "RemovePropertiesCommand(properties: " << command.m_properties << ")";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
|
||||
#include "propertyabstractcontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class RemovePropertiesCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, RemovePropertiesCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const RemovePropertiesCommand &command);
|
||||
|
||||
public:
|
||||
RemovePropertiesCommand();
|
||||
explicit RemovePropertiesCommand(const QVector<PropertyAbstractContainer> &properties);
|
||||
|
||||
QVector<PropertyAbstractContainer> properties() const;
|
||||
|
||||
private:
|
||||
QVector<PropertyAbstractContainer> m_properties;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const RemovePropertiesCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, RemovePropertiesCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const RemovePropertiesCommand &command);
|
||||
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::RemovePropertiesCommand)
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "removesharedmemorycommand.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
RemoveSharedMemoryCommand::RemoveSharedMemoryCommand() = default;
|
||||
|
||||
RemoveSharedMemoryCommand::RemoveSharedMemoryCommand(const QString &typeName, const QVector<qint32> &keyNumberVector)
|
||||
: m_typeName(typeName),
|
||||
m_keyNumberVector(keyNumberVector)
|
||||
{
|
||||
}
|
||||
|
||||
QString RemoveSharedMemoryCommand::typeName() const
|
||||
{
|
||||
return m_typeName;
|
||||
}
|
||||
|
||||
QVector<qint32> RemoveSharedMemoryCommand::keyNumbers() const
|
||||
{
|
||||
return m_keyNumberVector;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const RemoveSharedMemoryCommand &command)
|
||||
{
|
||||
out << command.typeName();
|
||||
out << command.keyNumbers();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, RemoveSharedMemoryCommand &command)
|
||||
{
|
||||
in >> command.m_typeName;
|
||||
in >> command.m_keyNumberVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const RemoveSharedMemoryCommand &command)
|
||||
{
|
||||
return debug.nospace() << "RemoveSharedMemoryCommand("
|
||||
<< "typeName: " << command.m_typeName
|
||||
<< "keyNumbers: " << command.m_keyNumberVector << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class RemoveSharedMemoryCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, RemoveSharedMemoryCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const RemoveSharedMemoryCommand &command);
|
||||
|
||||
public:
|
||||
RemoveSharedMemoryCommand();
|
||||
explicit RemoveSharedMemoryCommand(const QString &typeName, const QVector<qint32> &keyNumberVector);
|
||||
|
||||
QString typeName() const;
|
||||
QVector<qint32> keyNumbers() const;
|
||||
|
||||
private:
|
||||
QString m_typeName;
|
||||
QVector<qint32> m_keyNumberVector;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const RemoveSharedMemoryCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, RemoveSharedMemoryCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const RemoveSharedMemoryCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::RemoveSharedMemoryCommand)
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "reparentinstancescommand.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
ReparentInstancesCommand::ReparentInstancesCommand() = default;
|
||||
|
||||
ReparentInstancesCommand::ReparentInstancesCommand(const QVector<ReparentContainer> &container)
|
||||
: m_reparentInstanceVector(container)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<ReparentContainer> ReparentInstancesCommand::reparentInstances() const
|
||||
{
|
||||
return m_reparentInstanceVector;
|
||||
}
|
||||
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ReparentInstancesCommand &command)
|
||||
{
|
||||
out << command.reparentInstances();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ReparentInstancesCommand &command)
|
||||
{
|
||||
in >> command.m_reparentInstanceVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const ReparentInstancesCommand &command)
|
||||
{
|
||||
return debug.nospace() << "ReparentInstancesCommand(reparentInstances: " << command.m_reparentInstanceVector << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
|
||||
#include "reparentcontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ReparentInstancesCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, ReparentInstancesCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const ReparentInstancesCommand &command);
|
||||
|
||||
public:
|
||||
ReparentInstancesCommand();
|
||||
explicit ReparentInstancesCommand(const QVector<ReparentContainer> &container);
|
||||
|
||||
QVector<ReparentContainer> reparentInstances() const;
|
||||
|
||||
private:
|
||||
QVector<ReparentContainer> m_reparentInstanceVector;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ReparentInstancesCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, ReparentInstancesCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const ReparentInstancesCommand &command);
|
||||
|
||||
} //
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ReparentInstancesCommand)
|
||||
@@ -0,0 +1,71 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "requestmodelnodepreviewimagecommand.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
RequestModelNodePreviewImageCommand::RequestModelNodePreviewImageCommand() = default;
|
||||
|
||||
RequestModelNodePreviewImageCommand::RequestModelNodePreviewImageCommand(qint32 id, const QSize &size,
|
||||
const QString &componentPath,
|
||||
qint32 renderItemId)
|
||||
: m_instanceId(id)
|
||||
, m_size(size)
|
||||
, m_componentPath(componentPath)
|
||||
, m_renderItemId(renderItemId)
|
||||
{
|
||||
}
|
||||
|
||||
qint32 RequestModelNodePreviewImageCommand::instanceId() const
|
||||
{
|
||||
return m_instanceId;
|
||||
}
|
||||
|
||||
QSize QmlDesigner::RequestModelNodePreviewImageCommand::size() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
QString RequestModelNodePreviewImageCommand::componentPath() const
|
||||
{
|
||||
return m_componentPath;
|
||||
}
|
||||
|
||||
qint32 RequestModelNodePreviewImageCommand::renderItemId() const
|
||||
{
|
||||
return m_renderItemId;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const RequestModelNodePreviewImageCommand &command)
|
||||
{
|
||||
out << int(command.instanceId());
|
||||
out << command.size();
|
||||
out << command.componentPath();
|
||||
out << command.renderItemId();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, RequestModelNodePreviewImageCommand &command)
|
||||
{
|
||||
in >> command.m_instanceId;
|
||||
in >> command.m_size;
|
||||
in >> command.m_componentPath;
|
||||
in >> command.m_renderItemId;
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const RequestModelNodePreviewImageCommand &command)
|
||||
{
|
||||
return debug.nospace() << "RequestModelNodePreviewImageCommand("
|
||||
<< "instanceId: " << command.instanceId() << ", "
|
||||
<< "size: " << command.size() << ", "
|
||||
<< "componentPath: " << command.componentPath() << ", "
|
||||
<< "renderItemId: " << command.renderItemId() << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,63 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/qmetatype.h>
|
||||
#include <QtCore/qdatastream.h>
|
||||
#include <QtGui/qevent.h>
|
||||
|
||||
#include "instancecontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class RequestModelNodePreviewImageCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, RequestModelNodePreviewImageCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const RequestModelNodePreviewImageCommand &command);
|
||||
|
||||
public:
|
||||
RequestModelNodePreviewImageCommand();
|
||||
explicit RequestModelNodePreviewImageCommand(qint32 id, const QSize &size,
|
||||
const QString &componentPath, qint32 renderItemId);
|
||||
|
||||
qint32 instanceId() const;
|
||||
QSize size() const;
|
||||
QString componentPath() const;
|
||||
qint32 renderItemId() const;
|
||||
|
||||
private:
|
||||
qint32 m_instanceId;
|
||||
QSize m_size;
|
||||
QString m_componentPath;
|
||||
qint32 m_renderItemId;
|
||||
};
|
||||
|
||||
inline bool operator==(const RequestModelNodePreviewImageCommand &first,
|
||||
const RequestModelNodePreviewImageCommand &second)
|
||||
{
|
||||
return first.instanceId() == second.instanceId()
|
||||
&& first.size() == second.size()
|
||||
&& first.componentPath() == second.componentPath()
|
||||
&& first.renderItemId() == second.renderItemId();
|
||||
}
|
||||
|
||||
inline size_t qHash(const RequestModelNodePreviewImageCommand &key, size_t seed = 0)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
return ::qHash(key.instanceId(), seed)
|
||||
^ ::qHash(std::make_pair(key.size().width(), key.size().height()), seed)
|
||||
^ ::qHash(key.componentPath(), seed) ^ ::qHash(key.renderItemId(), seed);
|
||||
#else
|
||||
return qHashMulti(seed, key.instanceId(), key.size(), key.componentPath(), key.renderItemId());
|
||||
#endif
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const RequestModelNodePreviewImageCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, RequestModelNodePreviewImageCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const RequestModelNodePreviewImageCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::RequestModelNodePreviewImageCommand)
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class SceneCreatedCommand
|
||||
{
|
||||
public:
|
||||
friend QDataStream &operator<<(QDataStream &out, const SceneCreatedCommand &) { return out; }
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in, SceneCreatedCommand &) { return in; }
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::SceneCreatedCommand)
|
||||
@@ -0,0 +1,54 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "statepreviewimagechangedcommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
StatePreviewImageChangedCommand::StatePreviewImageChangedCommand() = default;
|
||||
|
||||
StatePreviewImageChangedCommand::StatePreviewImageChangedCommand(const QVector<ImageContainer> &imageVector)
|
||||
: m_previewVector(imageVector)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<ImageContainer> StatePreviewImageChangedCommand::previews()const
|
||||
{
|
||||
return m_previewVector;
|
||||
}
|
||||
|
||||
void StatePreviewImageChangedCommand::sort()
|
||||
{
|
||||
std::sort(m_previewVector.begin(), m_previewVector.end());
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const StatePreviewImageChangedCommand &command)
|
||||
{
|
||||
out << command.previews();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, StatePreviewImageChangedCommand &command)
|
||||
{
|
||||
in >> command.m_previewVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator ==(const StatePreviewImageChangedCommand &first, const StatePreviewImageChangedCommand &second)
|
||||
{
|
||||
return first.m_previewVector == second.m_previewVector;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const StatePreviewImageChangedCommand &command)
|
||||
{
|
||||
return debug.nospace() << "StatePreviewImageChangedCommand(" << command.previews() << ")";
|
||||
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
|
||||
#include "imagecontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class StatePreviewImageChangedCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, StatePreviewImageChangedCommand &command);
|
||||
friend bool operator ==(const StatePreviewImageChangedCommand &first, const StatePreviewImageChangedCommand &second);
|
||||
|
||||
public:
|
||||
StatePreviewImageChangedCommand();
|
||||
explicit StatePreviewImageChangedCommand(const QVector<ImageContainer> &imageVector);
|
||||
|
||||
QVector<ImageContainer> previews() const;
|
||||
|
||||
void sort();
|
||||
|
||||
private:
|
||||
QVector<ImageContainer> m_previewVector;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const StatePreviewImageChangedCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, StatePreviewImageChangedCommand &command);
|
||||
|
||||
bool operator ==(const StatePreviewImageChangedCommand &first, const StatePreviewImageChangedCommand &second);
|
||||
QDebug operator <<(QDebug debug, const StatePreviewImageChangedCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::StatePreviewImageChangedCommand)
|
||||
@@ -0,0 +1,58 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class SynchronizeCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, SynchronizeCommand &command);
|
||||
friend bool operator ==(const SynchronizeCommand &first, const SynchronizeCommand &second);
|
||||
|
||||
public:
|
||||
SynchronizeCommand()
|
||||
: m_synchronizeId(-1)
|
||||
{}
|
||||
explicit SynchronizeCommand(int synchronizeId)
|
||||
: m_synchronizeId(synchronizeId)
|
||||
{}
|
||||
|
||||
int synchronizeId() const { return m_synchronizeId; }
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const SynchronizeCommand &command)
|
||||
{
|
||||
out << command.synchronizeId();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in, SynchronizeCommand &command)
|
||||
{
|
||||
in >> command.m_synchronizeId;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
friend bool operator==(const SynchronizeCommand &first, const SynchronizeCommand &second)
|
||||
{
|
||||
return first.m_synchronizeId == second.m_synchronizeId;
|
||||
}
|
||||
|
||||
friend QDebug operator<<(QDebug debug, const SynchronizeCommand &command)
|
||||
{
|
||||
return debug.nospace() << "SynchronizeCommand(synchronizeId: " << command.synchronizeId()
|
||||
<< ")";
|
||||
}
|
||||
|
||||
private:
|
||||
int m_synchronizeId;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::SynchronizeCommand)
|
||||
77
src/libs/qmlpuppetcommunication/commands/tokencommand.cpp
Normal file
77
src/libs/qmlpuppetcommunication/commands/tokencommand.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "tokencommand.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
TokenCommand::TokenCommand()
|
||||
: m_tokenNumber(-1)
|
||||
{
|
||||
}
|
||||
|
||||
TokenCommand::TokenCommand(const QString &tokenName, qint32 tokenNumber, const QVector<qint32> &instanceIdVector)
|
||||
: m_tokenName(tokenName),
|
||||
m_tokenNumber(tokenNumber),
|
||||
m_instanceIdVector(instanceIdVector)
|
||||
{
|
||||
}
|
||||
|
||||
QString TokenCommand::tokenName() const
|
||||
{
|
||||
return m_tokenName;
|
||||
}
|
||||
|
||||
qint32 TokenCommand::tokenNumber() const
|
||||
{
|
||||
return m_tokenNumber;
|
||||
}
|
||||
|
||||
QVector<qint32> TokenCommand::instances() const
|
||||
{
|
||||
return m_instanceIdVector;
|
||||
}
|
||||
|
||||
void TokenCommand::sort()
|
||||
{
|
||||
std::sort(m_instanceIdVector.begin(), m_instanceIdVector.end());
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const TokenCommand &command)
|
||||
{
|
||||
out << command.tokenName();
|
||||
out << command.tokenNumber();
|
||||
out << command.instances();
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, TokenCommand &command)
|
||||
{
|
||||
in >> command.m_tokenName;
|
||||
in >> command.m_tokenNumber;
|
||||
in >> command.m_instanceIdVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator ==(const TokenCommand &first, const TokenCommand &second)
|
||||
{
|
||||
return first.m_tokenName == second.m_tokenName
|
||||
&& first.m_tokenNumber == second.m_tokenNumber
|
||||
&& first.m_instanceIdVector == second.m_instanceIdVector;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const TokenCommand &command)
|
||||
{
|
||||
return debug.nospace() << "TokenCommand("
|
||||
<< "tokenName: " << command.tokenName() << ", "
|
||||
<< "tokenNumber: " << command.tokenNumber() << ", "
|
||||
<< "instances: " << command.instances() << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
43
src/libs/qmlpuppetcommunication/commands/tokencommand.h
Normal file
43
src/libs/qmlpuppetcommunication/commands/tokencommand.h
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
#include <QString>
|
||||
#include <QDataStream>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class TokenCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, TokenCommand &command);
|
||||
friend bool operator ==(const TokenCommand &first, const TokenCommand &second);
|
||||
|
||||
public:
|
||||
TokenCommand();
|
||||
explicit TokenCommand(const QString &tokenName, qint32 tokenNumber, const QVector<qint32> &instances);
|
||||
|
||||
QString tokenName() const;
|
||||
qint32 tokenNumber() const;
|
||||
QVector<qint32> instances() const;
|
||||
|
||||
void sort();
|
||||
|
||||
private:
|
||||
QString m_tokenName;
|
||||
qint32 m_tokenNumber;
|
||||
QVector<qint32> m_instanceIdVector;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const TokenCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, TokenCommand &command);
|
||||
|
||||
bool operator ==(const TokenCommand &first, const TokenCommand &second);
|
||||
QDebug operator <<(QDebug debug, const TokenCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::TokenCommand)
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright (C) 2019 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "update3dviewstatecommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDataStream>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
Update3dViewStateCommand::Update3dViewStateCommand(const QSize &size)
|
||||
: m_size(size)
|
||||
, m_type(Update3dViewStateCommand::SizeChange)
|
||||
{
|
||||
}
|
||||
|
||||
QSize Update3dViewStateCommand::size() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
Update3dViewStateCommand::Type Update3dViewStateCommand::type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const Update3dViewStateCommand &command)
|
||||
{
|
||||
out << qint32(command.type());
|
||||
out << command.size();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, Update3dViewStateCommand &command)
|
||||
{
|
||||
qint32 type;
|
||||
in >> type;
|
||||
command.m_type = Update3dViewStateCommand::Type(type);
|
||||
in >> command.m_size;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const Update3dViewStateCommand &command)
|
||||
{
|
||||
return debug.nospace() << "Update3dViewStateCommand(type: "
|
||||
<< command.m_type << ","
|
||||
<< command.m_size << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2019 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QtCore/qsize.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class Update3dViewStateCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, Update3dViewStateCommand &command);
|
||||
friend QDebug operator<<(QDebug debug, const Update3dViewStateCommand &command);
|
||||
|
||||
public:
|
||||
enum Type { SizeChange, Empty };
|
||||
|
||||
explicit Update3dViewStateCommand(const QSize &size);
|
||||
Update3dViewStateCommand() = default;
|
||||
|
||||
QSize size() const;
|
||||
Type type() const;
|
||||
|
||||
private:
|
||||
QSize m_size;
|
||||
|
||||
Type m_type = Empty;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const Update3dViewStateCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, Update3dViewStateCommand &command);
|
||||
|
||||
QDebug operator<<(QDebug debug, const Update3dViewStateCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::Update3dViewStateCommand)
|
||||
@@ -0,0 +1,181 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "valueschangedcommand.h"
|
||||
|
||||
#include "sharedmemory.h"
|
||||
|
||||
#include <QCache>
|
||||
#include <QDebug>
|
||||
#include <QIODevice>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
// using cache as a container which deletes sharedmemory pointers at process exit
|
||||
using GlobalSharedMemoryContainer = QCache<qint32, SharedMemory>;
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(GlobalSharedMemoryContainer, globalSharedMemoryContainer, (10000))
|
||||
|
||||
ValuesChangedCommand::ValuesChangedCommand()
|
||||
: m_keyNumber(0)
|
||||
{
|
||||
}
|
||||
|
||||
ValuesChangedCommand::ValuesChangedCommand(const QVector<PropertyValueContainer> &valueChangeVector)
|
||||
: m_valueChangeVector (valueChangeVector),
|
||||
m_keyNumber(0)
|
||||
{
|
||||
}
|
||||
|
||||
const QVector<PropertyValueContainer> ValuesChangedCommand::valueChanges() const
|
||||
{
|
||||
return m_valueChangeVector;
|
||||
}
|
||||
|
||||
quint32 ValuesChangedCommand::keyNumber() const
|
||||
{
|
||||
return m_keyNumber;
|
||||
}
|
||||
|
||||
void ValuesChangedCommand::removeSharedMemorys(const QVector<qint32> &keyNumberVector)
|
||||
{
|
||||
for (qint32 keyNumber : keyNumberVector) {
|
||||
SharedMemory *sharedMemory = globalSharedMemoryContainer()->take(keyNumber);
|
||||
delete sharedMemory;
|
||||
}
|
||||
}
|
||||
|
||||
void ValuesChangedCommand::sort()
|
||||
{
|
||||
std::sort(m_valueChangeVector.begin(), m_valueChangeVector.end());
|
||||
}
|
||||
|
||||
static const QLatin1String valueKeyTemplateString("Values-%1");
|
||||
|
||||
static SharedMemory *createSharedMemory(qint32 key, int byteCount)
|
||||
{
|
||||
SharedMemory *sharedMemory = new SharedMemory(QString(valueKeyTemplateString).arg(key));
|
||||
|
||||
bool sharedMemoryIsCreated = sharedMemory->create(byteCount);
|
||||
|
||||
if (sharedMemoryIsCreated) {
|
||||
globalSharedMemoryContainer()->insert(key, sharedMemory);
|
||||
return sharedMemory;
|
||||
} else {
|
||||
delete sharedMemory;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ValuesChangedCommand &command)
|
||||
{
|
||||
static const bool dontUseSharedMemory = qEnvironmentVariableIsSet("DESIGNER_DONT_USE_SHARED_MEMORY");
|
||||
|
||||
QVector<PropertyValueContainer> propertyValueContainer = command.valueChanges();
|
||||
|
||||
if (command.transactionOption != ValuesChangedCommand::TransactionOption::None) {
|
||||
PropertyValueContainer optionContainer(command.transactionOption);
|
||||
propertyValueContainer.append(optionContainer);
|
||||
}
|
||||
|
||||
if (!dontUseSharedMemory && propertyValueContainer.count() > 5) {
|
||||
static quint32 keyCounter = 0;
|
||||
++keyCounter;
|
||||
command.m_keyNumber = keyCounter;
|
||||
QByteArray outDataStreamByteArray;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream temporaryOutDataStream(&outDataStreamByteArray, QIODevice::WriteOnly);
|
||||
#else
|
||||
QDataStream temporaryOutDataStream(&outDataStreamByteArray, QDataStream::WriteOnly);
|
||||
#endif
|
||||
temporaryOutDataStream.setVersion(QDataStream::Qt_4_8);
|
||||
|
||||
temporaryOutDataStream << propertyValueContainer;
|
||||
|
||||
SharedMemory *sharedMemory = createSharedMemory(keyCounter, outDataStreamByteArray.size());
|
||||
|
||||
if (sharedMemory) {
|
||||
sharedMemory->lock();
|
||||
std::memcpy(sharedMemory->data(), outDataStreamByteArray.constData(), sharedMemory->size());
|
||||
sharedMemory->unlock();
|
||||
|
||||
out << command.keyNumber();
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
out << qint32(0);
|
||||
out << propertyValueContainer;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void readSharedMemory(qint32 key, QVector<PropertyValueContainer> *valueChangeVector)
|
||||
{
|
||||
SharedMemory sharedMemory(QString(valueKeyTemplateString).arg(key));
|
||||
bool canAttach = sharedMemory.attach(QSharedMemory::ReadOnly);
|
||||
|
||||
if (canAttach) {
|
||||
sharedMemory.lock();
|
||||
|
||||
QDataStream in(QByteArray::fromRawData(static_cast<const char*>(sharedMemory.constData()), sharedMemory.size()));
|
||||
in.setVersion(QDataStream::Qt_4_8);
|
||||
in >> *valueChangeVector;
|
||||
|
||||
sharedMemory.unlock();
|
||||
sharedMemory.detach();
|
||||
}
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ValuesChangedCommand &command)
|
||||
{
|
||||
in >> command.m_keyNumber;
|
||||
|
||||
QVector<PropertyValueContainer> valueChangeVector;
|
||||
|
||||
if (command.keyNumber() > 0)
|
||||
readSharedMemory(command.keyNumber(), &valueChangeVector);
|
||||
else
|
||||
in >> valueChangeVector;
|
||||
|
||||
// '-option-' is not a valid property name and indicates that we store the transaction option.
|
||||
if (!valueChangeVector.isEmpty() && valueChangeVector.last().name() == "-option-") {
|
||||
command.transactionOption =
|
||||
static_cast<ValuesChangedCommand::TransactionOption>(valueChangeVector.last().instanceId());
|
||||
valueChangeVector.removeLast();
|
||||
}
|
||||
|
||||
command.m_valueChangeVector = valueChangeVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator ==(const ValuesChangedCommand &first, const ValuesChangedCommand &second)
|
||||
{
|
||||
return first.m_valueChangeVector == second.m_valueChangeVector
|
||||
&& first.transactionOption == second.transactionOption;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const ValuesChangedCommand &command)
|
||||
{
|
||||
return debug.nospace() << "ValuesChangedCommand("
|
||||
<< "keyNumber: " << command.keyNumber() << ", "
|
||||
<< command.valueChanges() << ")";
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ValuesModifiedCommand &command)
|
||||
{
|
||||
return out << static_cast<const ValuesChangedCommand &>(command);
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ValuesModifiedCommand &command)
|
||||
{
|
||||
return in >> static_cast<ValuesChangedCommand &>(command);
|
||||
}
|
||||
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,66 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
|
||||
#include "propertyvaluecontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ValuesChangedCommand
|
||||
{
|
||||
friend QDataStream &operator<<(QDataStream &out, const ValuesChangedCommand &command);
|
||||
friend QDataStream &operator>>(QDataStream &in, ValuesChangedCommand &command);
|
||||
friend bool operator ==(const ValuesChangedCommand &first, const ValuesChangedCommand &second);
|
||||
|
||||
public:
|
||||
enum TransactionOption { Start = 1, End = 2, None = 0 };
|
||||
ValuesChangedCommand();
|
||||
explicit ValuesChangedCommand(const QVector<PropertyValueContainer> &valueChangeVector);
|
||||
|
||||
const QVector<PropertyValueContainer> valueChanges() const;
|
||||
quint32 keyNumber() const;
|
||||
|
||||
static void removeSharedMemorys(const QVector<qint32> &keyNumberVector);
|
||||
|
||||
void sort();
|
||||
TransactionOption transactionOption = TransactionOption::None;
|
||||
|
||||
private:
|
||||
QVector<PropertyValueContainer> m_valueChangeVector;
|
||||
mutable quint32 m_keyNumber;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ValuesChangedCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, ValuesChangedCommand &command);
|
||||
|
||||
bool operator ==(const ValuesChangedCommand &first, const ValuesChangedCommand &second);
|
||||
QDebug operator <<(QDebug debug, const ValuesChangedCommand &instance);
|
||||
|
||||
/* ValuesChangedCommand is used to notify that the values of a specific instatiated
|
||||
* QObject changed.
|
||||
* The ValuesModifiedCommand is used to notify that a user changed a QML property and
|
||||
* that this property should be changed in the data model.
|
||||
*/
|
||||
|
||||
class ValuesModifiedCommand : public ValuesChangedCommand
|
||||
{
|
||||
public:
|
||||
ValuesModifiedCommand() = default;
|
||||
|
||||
explicit ValuesModifiedCommand(const QVector<PropertyValueContainer> &valueChangeVector)
|
||||
: ValuesChangedCommand(valueChangeVector)
|
||||
{}
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ValuesModifiedCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, ValuesModifiedCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ValuesModifiedCommand)
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ValuesChangedCommand)
|
||||
@@ -0,0 +1,79 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "view3dactioncommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDataStream>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
View3DActionCommand::View3DActionCommand(View3DActionType type, const QVariant &value)
|
||||
: m_type(type)
|
||||
, m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
bool View3DActionCommand::isEnabled() const
|
||||
{
|
||||
return m_value.toBool();
|
||||
}
|
||||
|
||||
QVariant View3DActionCommand::value() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
View3DActionType View3DActionCommand::type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
int View3DActionCommand::position() const
|
||||
{
|
||||
bool ok = false;
|
||||
int result = m_value.toInt(&ok);
|
||||
if (!ok) {
|
||||
qWarning() << "View3DActionCommand: returning a position that is not int; command type = "
|
||||
<< m_type;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const View3DActionCommand &command)
|
||||
{
|
||||
out << command.value();
|
||||
out << command.type();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, View3DActionCommand &command)
|
||||
{
|
||||
in >> command.m_value;
|
||||
in >> command.m_type;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const View3DActionCommand &command)
|
||||
{
|
||||
return debug.nospace() << "View3DActionCommand(type: "
|
||||
<< command.m_type << ","
|
||||
<< command.m_value << ")\n";
|
||||
}
|
||||
|
||||
template<typename Enumeration>
|
||||
constexpr std::underlying_type_t<Enumeration> to_underlying(Enumeration enumeration) noexcept
|
||||
{
|
||||
static_assert(std::is_enum_v<Enumeration>, "to_underlying expect an enumeration");
|
||||
return static_cast<std::underlying_type_t<Enumeration>>(enumeration);
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, View3DActionType type)
|
||||
{
|
||||
return debug.nospace() << to_underlying(type);
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nodeinstanceglobal.h>
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVariant>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class View3DActionCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, View3DActionCommand &command);
|
||||
friend QDebug operator<<(QDebug debug, const View3DActionCommand &command);
|
||||
|
||||
public:
|
||||
View3DActionCommand(View3DActionType type, const QVariant &value);
|
||||
|
||||
View3DActionCommand() = default;
|
||||
|
||||
bool isEnabled() const;
|
||||
QVariant value() const;
|
||||
View3DActionType type() const;
|
||||
int position() const;
|
||||
|
||||
private:
|
||||
View3DActionType m_type = View3DActionType::Empty;
|
||||
QVariant m_value;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const View3DActionCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, View3DActionCommand &command);
|
||||
|
||||
QDebug operator<<(QDebug debug, const View3DActionCommand &command);
|
||||
QDebug operator<<(QDebug debug, View3DActionType type);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::View3DActionCommand)
|
||||
@@ -0,0 +1,90 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "addimportcontainer.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDataStream>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
AddImportContainer::AddImportContainer() = default;
|
||||
|
||||
AddImportContainer::AddImportContainer(const QUrl &url, const QString &fileName, const QString &version, const QString &alias, const QStringList &importPathList)
|
||||
: m_url(url),
|
||||
m_fileName(fileName),
|
||||
m_version(version),
|
||||
m_alias(alias),
|
||||
m_importPathList(importPathList)
|
||||
{
|
||||
}
|
||||
|
||||
QUrl AddImportContainer::url() const
|
||||
{
|
||||
return m_url;
|
||||
}
|
||||
|
||||
QString AddImportContainer::fileName() const
|
||||
{
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
QString AddImportContainer::version() const
|
||||
{
|
||||
return m_version;
|
||||
}
|
||||
|
||||
QString AddImportContainer::alias() const
|
||||
{
|
||||
return m_alias;
|
||||
}
|
||||
|
||||
QStringList AddImportContainer::importPaths() const
|
||||
{
|
||||
return m_importPathList;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const AddImportContainer &command)
|
||||
{
|
||||
out << command.url();
|
||||
out << command.fileName();
|
||||
out << command.version();
|
||||
out << command.alias();
|
||||
out << command.importPaths();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, AddImportContainer &command)
|
||||
{
|
||||
in >> command.m_url;
|
||||
in >> command.m_fileName;
|
||||
in >> command.m_version;
|
||||
in >> command.m_alias;
|
||||
in >> command.m_importPathList;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const AddImportContainer &container)
|
||||
{
|
||||
debug.nospace() << "AddImportContainer(";
|
||||
|
||||
if (!container.url().isEmpty())
|
||||
debug.nospace() << "url: " << container.url() << ", ";
|
||||
|
||||
if (!container.fileName().isEmpty())
|
||||
debug.nospace() << "fileName: " << container.fileName() << ", ";
|
||||
|
||||
if (!container.version().isEmpty())
|
||||
debug.nospace() << "version: " << container.version() << ", ";
|
||||
|
||||
if (!container.alias().isEmpty())
|
||||
debug.nospace() << "alias: " << container.alias() << ", ";
|
||||
|
||||
debug.nospace() << "importPaths: " << container.importPaths();
|
||||
|
||||
return debug.nospace() << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QUrl>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class AddImportContainer
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, AddImportContainer &command);
|
||||
public:
|
||||
AddImportContainer();
|
||||
AddImportContainer(const QUrl &url, const QString &fileName, const QString &version, const QString &alias, const QStringList &mportPathList);
|
||||
|
||||
QUrl url() const;
|
||||
QString fileName() const;
|
||||
QString version() const;
|
||||
QString alias() const;
|
||||
QStringList importPaths() const;
|
||||
|
||||
private:
|
||||
QUrl m_url;
|
||||
QString m_fileName;
|
||||
QString m_version;
|
||||
QString m_alias;
|
||||
QStringList m_importPathList;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const AddImportContainer &command);
|
||||
QDataStream &operator>>(QDataStream &in, AddImportContainer &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const AddImportContainer &container);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::AddImportContainer)
|
||||
54
src/libs/qmlpuppetcommunication/container/idcontainer.cpp
Normal file
54
src/libs/qmlpuppetcommunication/container/idcontainer.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "idcontainer.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
IdContainer::IdContainer()
|
||||
: m_instanceId(-1)
|
||||
{
|
||||
}
|
||||
|
||||
IdContainer::IdContainer(qint32 instanceId, const QString &id)
|
||||
: m_instanceId(instanceId),
|
||||
m_id(id)
|
||||
{
|
||||
}
|
||||
|
||||
qint32 IdContainer::instanceId() const
|
||||
{
|
||||
return m_instanceId;
|
||||
}
|
||||
|
||||
QString IdContainer::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const IdContainer &container)
|
||||
{
|
||||
out << container.instanceId();
|
||||
out << container.id();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, IdContainer &container)
|
||||
{
|
||||
in >> container.m_instanceId;
|
||||
in >> container.m_id;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const IdContainer &container)
|
||||
{
|
||||
return debug.nospace() << "IdContainer("
|
||||
<< "instanceId: " << container.instanceId() << ", "
|
||||
<< "id: " << container.id() << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
36
src/libs/qmlpuppetcommunication/container/idcontainer.h
Normal file
36
src/libs/qmlpuppetcommunication/container/idcontainer.h
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDataStream>
|
||||
#include <qmetatype.h>
|
||||
#include <QString>
|
||||
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class IdContainer
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, IdContainer &container);
|
||||
|
||||
public:
|
||||
IdContainer();
|
||||
IdContainer(qint32 instanceId, const QString &id);
|
||||
|
||||
qint32 instanceId() const;
|
||||
QString id() const;
|
||||
|
||||
private:
|
||||
qint32 m_instanceId;
|
||||
QString m_id;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const IdContainer &container);
|
||||
QDataStream &operator>>(QDataStream &in, IdContainer &container);
|
||||
|
||||
QDebug operator <<(QDebug debug, const IdContainer &container);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::IdContainer)
|
||||
267
src/libs/qmlpuppetcommunication/container/imagecontainer.cpp
Normal file
267
src/libs/qmlpuppetcommunication/container/imagecontainer.cpp
Normal file
@@ -0,0 +1,267 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "imagecontainer.h"
|
||||
|
||||
#include "sharedmemory.h"
|
||||
#include <QCache>
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#define QTC_ASSERT_STRINGIFY_HELPER(x) #x
|
||||
#define QTC_ASSERT_STRINGIFY(x) QTC_ASSERT_STRINGIFY_HELPER(x)
|
||||
#define QTC_ASSERT_STRING(cond) qDebug("SOFT ASSERT: \"" cond"\" in file " __FILE__ ", line " QTC_ASSERT_STRINGIFY(__LINE__))
|
||||
#define QTC_ASSERT(cond, action) if (cond) {} else { QTC_ASSERT_STRING(#cond); action; } do {} while (0)
|
||||
|
||||
static Q_LOGGING_CATEGORY(imageContainerDebug, "qtc.imagecontainer.debug", QtDebugMsg)
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
// using cache as a container which deletes sharedmemory pointers at process exit
|
||||
using GlobalSharedMemoryContainer = QCache<qint32, SharedMemory>;
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(GlobalSharedMemoryContainer, globalSharedMemoryContainer, (10000))
|
||||
|
||||
ImageContainer::ImageContainer()
|
||||
: m_instanceId(-1),
|
||||
m_keyNumber(-2)
|
||||
{
|
||||
}
|
||||
|
||||
ImageContainer::ImageContainer(qint32 instanceId, const QImage &image, qint32 keyNumber)
|
||||
: m_image(image),
|
||||
m_instanceId(instanceId),
|
||||
m_keyNumber(keyNumber)
|
||||
{
|
||||
}
|
||||
|
||||
qint32 ImageContainer::instanceId() const
|
||||
{
|
||||
return m_instanceId;
|
||||
}
|
||||
|
||||
QImage ImageContainer::image() const
|
||||
{
|
||||
return m_image;
|
||||
}
|
||||
|
||||
qint32 ImageContainer::keyNumber() const
|
||||
{
|
||||
return m_keyNumber;
|
||||
}
|
||||
|
||||
QRectF ImageContainer::rect() const
|
||||
{
|
||||
return m_rect;
|
||||
}
|
||||
|
||||
void ImageContainer::setImage(const QImage &image)
|
||||
{
|
||||
QTC_ASSERT(m_image.isNull(), /**/);
|
||||
|
||||
m_image = image;
|
||||
}
|
||||
|
||||
void ImageContainer::setRect(const QRectF &rectangle)
|
||||
{
|
||||
m_rect = rectangle;
|
||||
}
|
||||
|
||||
void ImageContainer::removeSharedMemorys(const QVector<qint32> &keyNumberVector)
|
||||
{
|
||||
for (qint32 keyNumber : keyNumberVector) {
|
||||
SharedMemory *sharedMemory = globalSharedMemoryContainer()->take(keyNumber);
|
||||
delete sharedMemory;
|
||||
}
|
||||
}
|
||||
|
||||
static const QLatin1String imageKeyTemplateString("Image-%1");
|
||||
|
||||
static SharedMemory *createSharedMemory(qint32 key, int byteCount)
|
||||
{
|
||||
SharedMemory *sharedMemory = (*globalSharedMemoryContainer())[key];
|
||||
|
||||
if (sharedMemory == nullptr) {
|
||||
sharedMemory = new SharedMemory(QString(imageKeyTemplateString).arg(key));
|
||||
bool sharedMemoryIsCreated = sharedMemory->create(byteCount);
|
||||
if (sharedMemoryIsCreated) {
|
||||
if (!globalSharedMemoryContainer()->insert(key, sharedMemory))
|
||||
return nullptr;
|
||||
} else {
|
||||
delete sharedMemory;
|
||||
sharedMemory = nullptr;
|
||||
}
|
||||
} else {
|
||||
bool sharedMemoryIsAttached = sharedMemory->isAttached();
|
||||
if (!sharedMemoryIsAttached)
|
||||
sharedMemoryIsAttached = sharedMemory->attach();
|
||||
|
||||
bool sharedMemorySizeIsSmallerThanByteCount = sharedMemory->size() < byteCount;
|
||||
bool sharedMemorySizeIsDoubleBiggerThanByteCount = sharedMemory->size() > (byteCount * 2);
|
||||
|
||||
if (!sharedMemoryIsAttached) {
|
||||
sharedMemory->create(byteCount);
|
||||
} else if (sharedMemorySizeIsSmallerThanByteCount || sharedMemorySizeIsDoubleBiggerThanByteCount) {
|
||||
sharedMemory->detach();
|
||||
sharedMemory->create(byteCount);
|
||||
}
|
||||
|
||||
if (!sharedMemory->isAttached()) {
|
||||
globalSharedMemoryContainer()->remove(key);
|
||||
sharedMemory = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return sharedMemory;
|
||||
}
|
||||
|
||||
static void writeSharedMemory(SharedMemory *sharedMemory, const QImage &image)
|
||||
{
|
||||
sharedMemory->lock();
|
||||
|
||||
qint32 headerData[6];
|
||||
headerData[0] = qint32(image.sizeInBytes());
|
||||
headerData[1] = image.bytesPerLine();
|
||||
headerData[2] = image.size().width();
|
||||
headerData[3] = image.size().height();
|
||||
headerData[4] = image.format();
|
||||
headerData[5] = image.devicePixelRatio() * 100;
|
||||
|
||||
std::memcpy(sharedMemory->data(), headerData, 24);
|
||||
std::memcpy(reinterpret_cast<char*>(sharedMemory->data()) + 24, image.constBits(), image.sizeInBytes());
|
||||
sharedMemory->unlock();
|
||||
}
|
||||
|
||||
static void writeStream(QDataStream &out, const QImage &image)
|
||||
{
|
||||
out << qint32(image.bytesPerLine());
|
||||
out << image.size();
|
||||
out << qint32(image.format());
|
||||
out << qint32(image.sizeInBytes());
|
||||
out << qint32(image.devicePixelRatio() * 100);
|
||||
out.writeRawData(reinterpret_cast<const char*>(image.constBits()), image.sizeInBytes());
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ImageContainer &container)
|
||||
{
|
||||
const int extraDataSize = 24;
|
||||
static const bool dontUseSharedMemory = qEnvironmentVariableIsSet("DESIGNER_DONT_USE_SHARED_MEMORY");
|
||||
|
||||
out << container.instanceId();
|
||||
out << container.keyNumber();
|
||||
out << container.rect();
|
||||
|
||||
const QImage image = container.image();
|
||||
|
||||
if (dontUseSharedMemory) {
|
||||
out << qint32(0);
|
||||
writeStream(out, image);
|
||||
} else {
|
||||
const qint32 totalSize = qint32(image.sizeInBytes()) + extraDataSize;
|
||||
SharedMemory *sharedMemory = createSharedMemory(container.keyNumber(), totalSize);
|
||||
|
||||
out << qint32(sharedMemory != nullptr); // send if shared memory is used
|
||||
|
||||
if (sharedMemory)
|
||||
writeSharedMemory(sharedMemory, image);
|
||||
else
|
||||
writeStream(out, image);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static void readSharedMemory(qint32 key, ImageContainer &container)
|
||||
{
|
||||
SharedMemory sharedMemory(QString(imageKeyTemplateString).arg(key));
|
||||
|
||||
bool canAttach = sharedMemory.attach(QSharedMemory::ReadOnly);
|
||||
|
||||
if (canAttach && sharedMemory.size() >= 24)
|
||||
{
|
||||
sharedMemory.lock();
|
||||
qint32 headerData[6];
|
||||
std::memcpy(headerData, sharedMemory.constData(), 24);
|
||||
|
||||
qint32 byteCount = headerData[0];
|
||||
// qint32 bytesPerLine = headerData[1];
|
||||
qint32 imageWidth = headerData[2];
|
||||
qint32 imageHeight = headerData[3];
|
||||
qint32 imageFormat = headerData[4];
|
||||
qreal pixelRatio = headerData[5] / 100.0;
|
||||
|
||||
QImage image = QImage(imageWidth, imageHeight, QImage::Format(imageFormat));
|
||||
image.setDevicePixelRatio(pixelRatio);
|
||||
|
||||
if (image.isNull())
|
||||
qCInfo(imageContainerDebug()) << Q_FUNC_INFO << "Not able to create image:" << imageWidth << imageHeight << imageFormat;
|
||||
else
|
||||
std::memcpy(image.bits(), reinterpret_cast<const qint32*>(sharedMemory.constData()) + 6, byteCount);
|
||||
|
||||
container.setImage(image);
|
||||
|
||||
sharedMemory.unlock();
|
||||
sharedMemory.detach();
|
||||
}
|
||||
}
|
||||
|
||||
static void readStream(QDataStream &in, ImageContainer &container)
|
||||
{
|
||||
qint32 byteCount;
|
||||
qint32 bytesPerLine;
|
||||
QSize imageSize;
|
||||
qint32 imageFormat;
|
||||
qint32 pixelRatio;
|
||||
|
||||
in >> bytesPerLine;
|
||||
in >> imageSize;
|
||||
in >> imageFormat;
|
||||
in >> byteCount;
|
||||
in >> pixelRatio;
|
||||
|
||||
QImage image = QImage(imageSize, QImage::Format(imageFormat));
|
||||
|
||||
in.readRawData(reinterpret_cast<char*>(image.bits()), byteCount);
|
||||
image.setDevicePixelRatio(pixelRatio / 100.0);
|
||||
|
||||
container.setImage(image);
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ImageContainer &container)
|
||||
{
|
||||
qint32 sharedMemoryIsUsed;
|
||||
|
||||
in >> container.m_instanceId;
|
||||
in >> container.m_keyNumber;
|
||||
in >> container.m_rect;
|
||||
in >> sharedMemoryIsUsed;
|
||||
|
||||
if (sharedMemoryIsUsed) {
|
||||
readSharedMemory(container.keyNumber(), container);
|
||||
} else
|
||||
readStream(in, container);
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator ==(const ImageContainer &first, const ImageContainer &second)
|
||||
{
|
||||
return first.m_instanceId == second.m_instanceId
|
||||
&& first.m_image == second.m_image;
|
||||
}
|
||||
|
||||
bool operator <(const ImageContainer &first, const ImageContainer &second)
|
||||
{
|
||||
return first.m_instanceId < second.m_instanceId;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const ImageContainer &container)
|
||||
{
|
||||
return debug.nospace() << "ImageContainer("
|
||||
<< "instanceId: " << container.instanceId() << ", "
|
||||
<< "size: " << container.image().size() << ")";
|
||||
}
|
||||
|
||||
|
||||
} // namespace QmlDesigner
|
||||
48
src/libs/qmlpuppetcommunication/container/imagecontainer.h
Normal file
48
src/libs/qmlpuppetcommunication/container/imagecontainer.h
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QImage>
|
||||
#include <QMetaType>
|
||||
#include <QRectF>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ImageContainer
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, ImageContainer &container);
|
||||
friend bool operator==(const ImageContainer &first, const ImageContainer &second);
|
||||
friend bool operator<(const ImageContainer &first, const ImageContainer &second);
|
||||
|
||||
public:
|
||||
ImageContainer();
|
||||
ImageContainer(qint32 instanceId, const QImage &image, qint32 keyNumber);
|
||||
|
||||
qint32 instanceId() const;
|
||||
QImage image() const;
|
||||
qint32 keyNumber() const;
|
||||
QRectF rect() const;
|
||||
|
||||
void setImage(const QImage &image);
|
||||
void setRect(const QRectF &rectangle);
|
||||
|
||||
static void removeSharedMemorys(const QVector<qint32> &keyNumberVector);
|
||||
|
||||
private:
|
||||
QImage m_image;
|
||||
qint32 m_instanceId;
|
||||
qint32 m_keyNumber;
|
||||
QRectF m_rect;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ImageContainer &container);
|
||||
QDataStream &operator>>(QDataStream &in, ImageContainer &container);
|
||||
|
||||
bool operator==(const ImageContainer &first, const ImageContainer &second);
|
||||
bool operator<(const ImageContainer &first, const ImageContainer &second);
|
||||
QDebug operator<<(QDebug debug, const ImageContainer &container);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::ImageContainer)
|
||||
@@ -0,0 +1,124 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "informationcontainer.h"
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
InformationContainer::InformationContainer()
|
||||
: m_instanceId(-1),
|
||||
m_name(NoName)
|
||||
{
|
||||
}
|
||||
|
||||
InformationContainer::InformationContainer(qint32 instanceId,
|
||||
InformationName name,
|
||||
const QVariant &information,
|
||||
const QVariant &secondInformation,
|
||||
const QVariant &thirdInformation)
|
||||
: m_instanceId(instanceId),
|
||||
m_name(name),
|
||||
m_information(information),
|
||||
m_secondInformation(secondInformation),
|
||||
m_thirdInformation(thirdInformation)
|
||||
{
|
||||
}
|
||||
|
||||
qint32 InformationContainer::instanceId() const
|
||||
{
|
||||
return m_instanceId;
|
||||
}
|
||||
|
||||
InformationName InformationContainer::name() const
|
||||
{
|
||||
return InformationName(m_name);
|
||||
}
|
||||
|
||||
QVariant InformationContainer::information() const
|
||||
{
|
||||
return m_information;
|
||||
}
|
||||
|
||||
QVariant InformationContainer::secondInformation() const
|
||||
{
|
||||
return m_secondInformation;
|
||||
}
|
||||
|
||||
QVariant InformationContainer::thirdInformation() const
|
||||
{
|
||||
return m_thirdInformation;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const InformationContainer &container)
|
||||
{
|
||||
out << container.instanceId();//
|
||||
out << container.m_name;
|
||||
out << container.information();
|
||||
out << container.secondInformation();
|
||||
out << container.thirdInformation();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, InformationContainer &container)
|
||||
{
|
||||
|
||||
in >> container.m_instanceId;
|
||||
in >> container.m_name;
|
||||
in >> container.m_information;
|
||||
in >> container.m_secondInformation;
|
||||
in >> container.m_thirdInformation;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator ==(const InformationContainer &first, const InformationContainer &second)
|
||||
{
|
||||
return first.m_instanceId == second.m_instanceId
|
||||
&& first.m_name == second.m_name
|
||||
&& first.m_information == second.m_information
|
||||
&& first.m_secondInformation == second.m_secondInformation
|
||||
&& first.m_thirdInformation == second.m_thirdInformation;
|
||||
}
|
||||
|
||||
static bool isFirstLessThenSecond(const QVariant &first, const QVariant &second)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) || QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
if (first.userType() == second.userType()) {
|
||||
if (first.canConvert<QByteArray>())
|
||||
return first.value<QByteArray>() < second.value<QByteArray>();
|
||||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
return first < second;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool operator <(const InformationContainer &first, const InformationContainer &second)
|
||||
{
|
||||
return (first.m_instanceId < second.m_instanceId)
|
||||
|| (first.m_instanceId == second.m_instanceId && first.m_name < second.m_name)
|
||||
|| (first.m_instanceId == second.m_instanceId && first.m_name == second.m_name
|
||||
&& isFirstLessThenSecond(first.m_information, second.m_information));
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const InformationContainer &container)
|
||||
{
|
||||
debug.nospace() << "InformationContainer("
|
||||
<< "instanceId: " << container.instanceId() << ", "
|
||||
<< "name: " << container.name() << ", "
|
||||
<< "information: " << container.information();
|
||||
|
||||
if (container.secondInformation().isValid())
|
||||
debug.nospace() << ", " << "secondInformation: " << container.secondInformation();
|
||||
|
||||
if (container.thirdInformation().isValid())
|
||||
debug.nospace() << ", " << "thirdInformation: " << container.thirdInformation();
|
||||
|
||||
return debug.nospace() << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,53 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QMetaType>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
#include "commondefines.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class InformationContainer
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, InformationContainer &container);
|
||||
friend QDataStream &operator<<(QDataStream &out, const InformationContainer &container);
|
||||
friend bool operator ==(const InformationContainer &first, const InformationContainer &second);
|
||||
friend bool operator <(const InformationContainer &first, const InformationContainer &second);
|
||||
|
||||
public:
|
||||
InformationContainer();
|
||||
InformationContainer(qint32 instanceId,
|
||||
InformationName name,
|
||||
const QVariant &information,
|
||||
const QVariant &secondInformation = QVariant(),
|
||||
const QVariant &thirdInformation = QVariant());
|
||||
|
||||
qint32 instanceId() const;
|
||||
InformationName name() const;
|
||||
QVariant information() const;
|
||||
QVariant secondInformation() const;
|
||||
QVariant thirdInformation() const;
|
||||
|
||||
private:
|
||||
qint32 m_instanceId;
|
||||
qint32 m_name;
|
||||
QVariant m_information;
|
||||
QVariant m_secondInformation;
|
||||
QVariant m_thirdInformation;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const InformationContainer &container);
|
||||
QDataStream &operator>>(QDataStream &in, InformationContainer &container);
|
||||
|
||||
bool operator ==(const InformationContainer &first, const InformationContainer &second);
|
||||
bool operator <(const InformationContainer &first, const InformationContainer &second);
|
||||
QDebug operator <<(QDebug debug, const InformationContainer &container);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::InformationContainer)
|
||||
155
src/libs/qmlpuppetcommunication/container/instancecontainer.cpp
Normal file
155
src/libs/qmlpuppetcommunication/container/instancecontainer.cpp
Normal file
@@ -0,0 +1,155 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "instancecontainer.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
static TypeName properDelemitingOfType(const TypeName &typeName)
|
||||
{
|
||||
TypeName convertedTypeName = typeName;
|
||||
int lastIndex = typeName.lastIndexOf('.');
|
||||
if (lastIndex > 0)
|
||||
convertedTypeName[lastIndex] = '/';
|
||||
|
||||
return convertedTypeName;
|
||||
}
|
||||
|
||||
InstanceContainer::InstanceContainer() = default;
|
||||
|
||||
InstanceContainer::InstanceContainer(qint32 instanceId,
|
||||
const TypeName &type,
|
||||
int majorNumber,
|
||||
int minorNumber,
|
||||
const QString &componentPath,
|
||||
const QString &nodeSource,
|
||||
NodeSourceType nodeSourceType,
|
||||
NodeMetaType metaType,
|
||||
NodeFlags metaFlags)
|
||||
: m_instanceId(instanceId)
|
||||
,m_type(properDelemitingOfType(type))
|
||||
,m_majorNumber(majorNumber)
|
||||
,m_minorNumber(minorNumber)
|
||||
,m_componentPath(componentPath)
|
||||
,m_nodeSource(nodeSource)
|
||||
,m_nodeSourceType(nodeSourceType)
|
||||
,m_metaType(metaType)
|
||||
,m_metaFlags(metaFlags)
|
||||
{
|
||||
}
|
||||
|
||||
qint32 InstanceContainer::instanceId() const
|
||||
{
|
||||
return m_instanceId;
|
||||
}
|
||||
|
||||
TypeName InstanceContainer::type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
int InstanceContainer::majorNumber() const
|
||||
{
|
||||
return m_majorNumber;
|
||||
}
|
||||
|
||||
int InstanceContainer::minorNumber() const
|
||||
{
|
||||
return m_minorNumber;
|
||||
}
|
||||
|
||||
QString InstanceContainer::componentPath() const
|
||||
{
|
||||
return m_componentPath;
|
||||
}
|
||||
|
||||
QString InstanceContainer::nodeSource() const
|
||||
{
|
||||
return m_nodeSource;
|
||||
}
|
||||
|
||||
InstanceContainer::NodeSourceType InstanceContainer::nodeSourceType() const
|
||||
{
|
||||
return static_cast<NodeSourceType>(m_nodeSourceType);
|
||||
}
|
||||
|
||||
InstanceContainer::NodeMetaType InstanceContainer::metaType() const
|
||||
{
|
||||
return static_cast<NodeMetaType>(m_metaType);
|
||||
}
|
||||
|
||||
InstanceContainer::NodeFlags InstanceContainer::metaFlags() const
|
||||
{
|
||||
return NodeFlags(m_metaFlags);
|
||||
}
|
||||
|
||||
bool InstanceContainer::checkFlag(NodeFlag flag) const
|
||||
{
|
||||
return NodeFlags(m_metaFlags).testFlag(flag);
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const InstanceContainer &container)
|
||||
{
|
||||
out << container.instanceId();
|
||||
out << container.type();
|
||||
out << container.majorNumber();
|
||||
out << container.minorNumber();
|
||||
out << container.componentPath();
|
||||
out << container.nodeSource();
|
||||
out << qint32(container.nodeSourceType());
|
||||
out << qint32(container.metaType());
|
||||
out << qint32(container.metaFlags());
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, InstanceContainer &container)
|
||||
{
|
||||
in >> container.m_instanceId;
|
||||
in >> container.m_type;
|
||||
in >> container.m_majorNumber;
|
||||
in >> container.m_minorNumber;
|
||||
in >> container.m_componentPath;
|
||||
in >> container.m_nodeSource;
|
||||
in >> container.m_nodeSourceType;
|
||||
in >> container.m_metaType;
|
||||
in >> container.m_metaFlags;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const InstanceContainer &command)
|
||||
{
|
||||
debug.nospace() << "InstanceContainer("
|
||||
<< "instanceId: " << command.instanceId() << ", "
|
||||
<< "type: " << command.type() << ", "
|
||||
<< "majorNumber: " << command.majorNumber() << ", "
|
||||
<< "minorNumber: " << command.minorNumber() << ", ";
|
||||
|
||||
if (!command.componentPath().isEmpty())
|
||||
debug.nospace() << "componentPath: " << command.componentPath() << ", ";
|
||||
|
||||
if (!command.nodeSource().isEmpty())
|
||||
debug.nospace() << "nodeSource: " << command.nodeSource() << ", ";
|
||||
|
||||
if (command.nodeSourceType() == InstanceContainer::NoSource)
|
||||
debug.nospace() << "nodeSourceType: NoSource, ";
|
||||
else if (command.nodeSourceType() == InstanceContainer::CustomParserSource)
|
||||
debug.nospace() << "nodeSourceType: CustomParserSource, ";
|
||||
else
|
||||
debug.nospace() << "nodeSourceType: ComponentSource, ";
|
||||
|
||||
if (command.metaType() == InstanceContainer::ObjectMetaType)
|
||||
debug.nospace() << "metatype: ObjectMetaType";
|
||||
else
|
||||
debug.nospace() << "metatype: ItemMetaType";
|
||||
|
||||
return debug.nospace() << ")";
|
||||
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,80 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <qmetatype.h>
|
||||
#include <QString>
|
||||
#include <QDataStream>
|
||||
|
||||
#include "nodeinstanceglobal.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class InstanceContainer;
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const InstanceContainer &container);
|
||||
QDataStream &operator>>(QDataStream &in, InstanceContainer &container);
|
||||
|
||||
class InstanceContainer
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, InstanceContainer &container);
|
||||
|
||||
public:
|
||||
enum NodeSourceType {
|
||||
NoSource = 0,
|
||||
CustomParserSource = 1,
|
||||
ComponentSource = 2
|
||||
};
|
||||
|
||||
enum NodeMetaType {
|
||||
ObjectMetaType,
|
||||
ItemMetaType
|
||||
};
|
||||
|
||||
enum NodeFlag {
|
||||
ParentTakesOverRendering = 1
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(NodeFlags, NodeFlag)
|
||||
|
||||
InstanceContainer();
|
||||
InstanceContainer(qint32 instanceId,
|
||||
const TypeName &type,
|
||||
int majorNumber,
|
||||
int minorNumber,
|
||||
const QString &componentPath,
|
||||
const QString &nodeSource,
|
||||
NodeSourceType nodeSourceType,
|
||||
NodeMetaType metaType,
|
||||
NodeFlags metaFlags);
|
||||
|
||||
qint32 instanceId() const;
|
||||
TypeName type() const;
|
||||
int majorNumber() const;
|
||||
int minorNumber() const;
|
||||
QString componentPath() const;
|
||||
QString nodeSource() const;
|
||||
NodeSourceType nodeSourceType() const;
|
||||
NodeMetaType metaType() const;
|
||||
bool checkFlag(NodeFlag flag) const;
|
||||
NodeFlags metaFlags() const;
|
||||
|
||||
private:
|
||||
qint32 m_instanceId = -1;
|
||||
TypeName m_type;
|
||||
qint32 m_majorNumber = -1;
|
||||
qint32 m_minorNumber = -1;
|
||||
QString m_componentPath;
|
||||
QString m_nodeSource;
|
||||
qint32 m_nodeSourceType = 0;
|
||||
qint32 m_metaType = 0;
|
||||
qint32 m_metaFlags = 0;
|
||||
};
|
||||
|
||||
QDebug operator <<(QDebug debug, const InstanceContainer &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::InstanceContainer)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QmlDesigner::InstanceContainer::NodeFlags)
|
||||
@@ -0,0 +1,63 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "mockuptypecontainer.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
QmlDesigner::MockupTypeContainer::MockupTypeContainer() = default;
|
||||
|
||||
QmlDesigner::MockupTypeContainer::MockupTypeContainer(const QmlDesigner::TypeName &type,
|
||||
const QString &importUri,
|
||||
int majorVersion,
|
||||
int minorVersion, bool isItem)
|
||||
: m_typeName(type)
|
||||
,m_importUri(importUri)
|
||||
,m_majorVersion(majorVersion)
|
||||
,m_minorVersion(minorVersion)
|
||||
,m_isItem(isItem)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString MockupTypeContainer::importUri() const
|
||||
{
|
||||
return m_importUri;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const MockupTypeContainer &container)
|
||||
{
|
||||
out << container.typeName();
|
||||
out << container.importUri();
|
||||
out << container.majorVersion();
|
||||
out << container.minorVersion();
|
||||
out << container.isItem();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, MockupTypeContainer &container)
|
||||
{
|
||||
in >> container.m_typeName;
|
||||
in >> container.m_importUri;
|
||||
in >> container.m_majorVersion;
|
||||
in >> container.m_minorVersion;
|
||||
in >> container.m_isItem;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const MockupTypeContainer &container)
|
||||
{
|
||||
return debug.nospace() << "MockupTypeContainer("
|
||||
<< "typeName: " << container.typeName() << ", "
|
||||
<< "importUri: " << container.importUri() << ", "
|
||||
<< "majorVersion: " << container.majorVersion() << ", "
|
||||
<< "minorVersion: " << container.minorVersion() << ", "
|
||||
<< "isItem: " << container.isItem() << ")";
|
||||
}
|
||||
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <qmetatype.h>
|
||||
#include <QString>
|
||||
#include <QDataStream>
|
||||
|
||||
#include "nodeinstanceglobal.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class MockupTypeContainer
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, MockupTypeContainer &container);
|
||||
|
||||
public:
|
||||
MockupTypeContainer();
|
||||
MockupTypeContainer(const TypeName &type, const QString &importUri, int majorVersion, int minorVersion, bool isItem);
|
||||
|
||||
TypeName typeName() const
|
||||
{ return m_typeName; }
|
||||
|
||||
QString importUri() const;
|
||||
|
||||
int majorVersion() const
|
||||
{ return m_majorVersion; }
|
||||
|
||||
int minorVersion() const
|
||||
{ return m_minorVersion; }
|
||||
|
||||
bool isItem() const
|
||||
{ return m_isItem; }
|
||||
|
||||
private:
|
||||
TypeName m_typeName;
|
||||
QString m_importUri;
|
||||
int m_majorVersion = -1;
|
||||
int m_minorVersion = -1;
|
||||
bool m_isItem = false;
|
||||
};
|
||||
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const MockupTypeContainer &container);
|
||||
QDataStream &operator>>(QDataStream &in, MockupTypeContainer &container);
|
||||
|
||||
QDebug operator <<(QDebug debug, const MockupTypeContainer &container);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::MockupTypeContainer)
|
||||
@@ -0,0 +1,75 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "propertyabstractcontainer.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
PropertyAbstractContainer::PropertyAbstractContainer()
|
||||
: m_instanceId(-1)
|
||||
{
|
||||
}
|
||||
|
||||
PropertyAbstractContainer::PropertyAbstractContainer(qint32 instanceId, const PropertyName &name, const TypeName &dynamicTypeName)
|
||||
: m_instanceId(instanceId),
|
||||
m_name(name),
|
||||
m_dynamicTypeName(dynamicTypeName)
|
||||
{
|
||||
}
|
||||
|
||||
qint32 PropertyAbstractContainer::instanceId() const
|
||||
{
|
||||
return m_instanceId;
|
||||
}
|
||||
|
||||
PropertyName PropertyAbstractContainer::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
bool PropertyAbstractContainer::isDynamic() const
|
||||
{
|
||||
return !m_dynamicTypeName.isEmpty();
|
||||
}
|
||||
|
||||
TypeName PropertyAbstractContainer::dynamicTypeName() const
|
||||
{
|
||||
return m_dynamicTypeName;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const PropertyAbstractContainer &container)
|
||||
{
|
||||
out << container.instanceId();
|
||||
out << container.name();
|
||||
out << container.dynamicTypeName();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, PropertyAbstractContainer &container)
|
||||
{
|
||||
in >> container.m_instanceId;
|
||||
in >> container.m_name;
|
||||
in >> container.m_dynamicTypeName;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const PropertyAbstractContainer &container)
|
||||
{
|
||||
debug.nospace() << "PropertyAbstractContainer("
|
||||
<< "instanceId: " << container.instanceId() << ", "
|
||||
<< "name: " << container.name();
|
||||
|
||||
if (!container.dynamicTypeName().isEmpty())
|
||||
debug.nospace() << ", " << "dynamicTypeName: " << container.dynamicTypeName();
|
||||
|
||||
debug.nospace() << ")";
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDataStream>
|
||||
#include <qmetatype.h>
|
||||
#include <QString>
|
||||
|
||||
#include "nodeinstanceglobal.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class PropertyAbstractContainer;
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const PropertyAbstractContainer &container);
|
||||
QDataStream &operator>>(QDataStream &in, PropertyAbstractContainer &container);
|
||||
|
||||
class PropertyAbstractContainer
|
||||
{
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const PropertyAbstractContainer &container);
|
||||
friend QDataStream &operator>>(QDataStream &in, PropertyAbstractContainer &container);
|
||||
friend QDebug operator <<(QDebug debug, const PropertyAbstractContainer &container);
|
||||
public:
|
||||
PropertyAbstractContainer();
|
||||
PropertyAbstractContainer(qint32 instanceId, const PropertyName &name, const TypeName &dynamicTypeName);
|
||||
|
||||
qint32 instanceId() const;
|
||||
PropertyName name() const;
|
||||
bool isDynamic() const;
|
||||
TypeName dynamicTypeName() const;
|
||||
|
||||
private:
|
||||
qint32 m_instanceId;
|
||||
PropertyName m_name;
|
||||
TypeName m_dynamicTypeName;
|
||||
};
|
||||
|
||||
QDebug operator <<(QDebug debug, const PropertyAbstractContainer &container);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::PropertyAbstractContainer)
|
||||
@@ -0,0 +1,81 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "propertybindingcontainer.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
PropertyBindingContainer::PropertyBindingContainer()
|
||||
: m_instanceId(-1)
|
||||
{
|
||||
}
|
||||
|
||||
PropertyBindingContainer::PropertyBindingContainer(qint32 instanceId, const PropertyName &name, const QString &expression, const TypeName &dynamicTypeName)
|
||||
: m_instanceId(instanceId),
|
||||
m_name(name),
|
||||
m_expression(expression),
|
||||
m_dynamicTypeName(dynamicTypeName)
|
||||
{
|
||||
}
|
||||
|
||||
qint32 PropertyBindingContainer::instanceId() const
|
||||
{
|
||||
return m_instanceId;
|
||||
}
|
||||
|
||||
PropertyName PropertyBindingContainer::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
QString PropertyBindingContainer::expression() const
|
||||
{
|
||||
return m_expression;
|
||||
}
|
||||
|
||||
bool PropertyBindingContainer::isDynamic() const
|
||||
{
|
||||
return !m_dynamicTypeName.isEmpty();
|
||||
}
|
||||
|
||||
TypeName PropertyBindingContainer::dynamicTypeName() const
|
||||
{
|
||||
return m_dynamicTypeName;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const PropertyBindingContainer &container)
|
||||
{
|
||||
out << container.instanceId();
|
||||
out << container.name();
|
||||
out << container.expression();
|
||||
out << container.dynamicTypeName();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, PropertyBindingContainer &container)
|
||||
{
|
||||
in >> container.m_instanceId;
|
||||
in >> container.m_name;
|
||||
in >> container.m_expression;
|
||||
in >> container.m_dynamicTypeName;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const PropertyBindingContainer &container)
|
||||
{
|
||||
debug.nospace() << "PropertyBindingContainer("
|
||||
<< "instanceId: " << container.instanceId() << ", "
|
||||
<< "name: " << container.name() << ", "
|
||||
<< "expression: " << container.expression();
|
||||
|
||||
if (!container.dynamicTypeName().isEmpty())
|
||||
debug.nospace() << ", " << "dynamicTypeName: " << container.dynamicTypeName();
|
||||
|
||||
return debug.nospace() << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDataStream>
|
||||
#include <qmetatype.h>
|
||||
#include <QString>
|
||||
|
||||
#include "nodeinstanceglobal.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class PropertyBindingContainer
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, PropertyBindingContainer &container);
|
||||
|
||||
public:
|
||||
PropertyBindingContainer();
|
||||
PropertyBindingContainer(qint32 instanceId, const PropertyName &name, const QString &expression, const TypeName &dynamicTypeName);
|
||||
|
||||
qint32 instanceId() const;
|
||||
PropertyName name() const;
|
||||
QString expression() const;
|
||||
bool isDynamic() const;
|
||||
TypeName dynamicTypeName() const;
|
||||
|
||||
private:
|
||||
qint32 m_instanceId;
|
||||
PropertyName m_name;
|
||||
QString m_expression;
|
||||
TypeName m_dynamicTypeName;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const PropertyBindingContainer &container);
|
||||
QDataStream &operator>>(QDataStream &in, PropertyBindingContainer &container);
|
||||
|
||||
QDebug operator <<(QDebug debug, const PropertyBindingContainer &container);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::PropertyBindingContainer)
|
||||
@@ -0,0 +1,134 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "propertyvaluecontainer.h"
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
PropertyValueContainer::PropertyValueContainer()
|
||||
: m_instanceId(-1)
|
||||
{
|
||||
}
|
||||
|
||||
PropertyValueContainer::PropertyValueContainer(qint32 instanceId,
|
||||
const PropertyName &name,
|
||||
const QVariant &value,
|
||||
const TypeName &dynamicTypeName,
|
||||
AuxiliaryDataType auxiliaryDataType)
|
||||
: m_instanceId(instanceId)
|
||||
, m_name(name)
|
||||
, m_value(value)
|
||||
, m_dynamicTypeName(dynamicTypeName)
|
||||
, m_auxiliaryDataType{auxiliaryDataType}
|
||||
{
|
||||
}
|
||||
|
||||
PropertyValueContainer::PropertyValueContainer(qint32 option)
|
||||
: m_instanceId(option),
|
||||
m_name("-option-")
|
||||
{
|
||||
// '-option-' is not a valid property name and indicates that we store the transaction option.
|
||||
}
|
||||
|
||||
qint32 PropertyValueContainer::instanceId() const
|
||||
{
|
||||
return m_instanceId;
|
||||
}
|
||||
|
||||
PropertyName PropertyValueContainer::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
QVariant PropertyValueContainer::value() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
bool PropertyValueContainer::isDynamic() const
|
||||
{
|
||||
return !m_dynamicTypeName.isEmpty();
|
||||
}
|
||||
|
||||
TypeName PropertyValueContainer::dynamicTypeName() const
|
||||
{
|
||||
return m_dynamicTypeName;
|
||||
}
|
||||
|
||||
// The reflection flag indicates that a property change notification
|
||||
// is reflected. This means that the notification is the reaction to a
|
||||
// property change original done by the puppet itself.
|
||||
// In the Qt5InformationNodeInstanceServer such notification are
|
||||
// therefore ignored.
|
||||
|
||||
void PropertyValueContainer::setReflectionFlag(bool b)
|
||||
{
|
||||
m_isReflected = b;
|
||||
}
|
||||
|
||||
bool PropertyValueContainer::isReflected() const
|
||||
{
|
||||
return m_isReflected;
|
||||
}
|
||||
|
||||
AuxiliaryDataType PropertyValueContainer::auxiliaryDataType() const
|
||||
{
|
||||
return m_auxiliaryDataType;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const PropertyValueContainer &container)
|
||||
{
|
||||
out << container.m_instanceId;
|
||||
out << container.m_name;
|
||||
out << container.m_value;
|
||||
out << container.m_dynamicTypeName;
|
||||
out << container.m_isReflected;
|
||||
out << container.m_auxiliaryDataType;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, PropertyValueContainer &container)
|
||||
{
|
||||
in >> container.m_instanceId;
|
||||
in >> container.m_name;
|
||||
in >> container.m_value;
|
||||
in >> container.m_dynamicTypeName;
|
||||
in >> container.m_isReflected;
|
||||
in >> container.m_auxiliaryDataType;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator ==(const PropertyValueContainer &first, const PropertyValueContainer &second)
|
||||
{
|
||||
return first.m_instanceId == second.m_instanceId && first.m_name == second.m_name
|
||||
&& first.m_value == second.m_value && first.m_dynamicTypeName == second.m_dynamicTypeName
|
||||
&& first.m_isReflected == second.m_isReflected
|
||||
&& first.m_auxiliaryDataType == second.m_auxiliaryDataType;
|
||||
}
|
||||
|
||||
bool operator <(const PropertyValueContainer &first, const PropertyValueContainer &second)
|
||||
{
|
||||
return (first.m_instanceId < second.m_instanceId)
|
||||
|| (first.m_instanceId == second.m_instanceId && first.m_name < second.m_name);
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const PropertyValueContainer &container)
|
||||
{
|
||||
debug.nospace() << "PropertyValueContainer("
|
||||
<< "instanceId: " << container.instanceId() << ", "
|
||||
<< "name: " << container.name() << ", "
|
||||
<< "value: " << container.value();
|
||||
|
||||
if (!container.dynamicTypeName().isEmpty())
|
||||
debug.nospace() << ", " << "dynamicTypeName: " << container.dynamicTypeName();
|
||||
|
||||
debug.nospace() << ")";
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,54 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QMetaType>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
#include "nodeinstanceglobal.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class PropertyValueContainer
|
||||
{
|
||||
public:
|
||||
PropertyValueContainer();
|
||||
PropertyValueContainer(qint32 instanceId,
|
||||
const PropertyName &name,
|
||||
const QVariant &value,
|
||||
const TypeName &dynamicTypeName,
|
||||
AuxiliaryDataType auxiliaryDataType = AuxiliaryDataType::None);
|
||||
PropertyValueContainer(qint32 option);
|
||||
|
||||
qint32 instanceId() const;
|
||||
PropertyName name() const;
|
||||
QVariant value() const;
|
||||
bool isDynamic() const;
|
||||
TypeName dynamicTypeName() const;
|
||||
void setReflectionFlag(bool b);
|
||||
bool isReflected() const;
|
||||
AuxiliaryDataType auxiliaryDataType() const;
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const PropertyValueContainer &container);
|
||||
friend QDataStream &operator>>(QDataStream &in, PropertyValueContainer &container);
|
||||
friend bool operator==(const PropertyValueContainer &first,
|
||||
const PropertyValueContainer &second);
|
||||
friend bool operator<(const PropertyValueContainer &first, const PropertyValueContainer &second);
|
||||
|
||||
private:
|
||||
qint32 m_instanceId;
|
||||
PropertyName m_name;
|
||||
QVariant m_value;
|
||||
TypeName m_dynamicTypeName;
|
||||
AuxiliaryDataType m_auxiliaryDataType = AuxiliaryDataType::None;
|
||||
bool m_isReflected = false;
|
||||
};
|
||||
|
||||
QDebug operator <<(QDebug debug, const PropertyValueContainer &container);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::PropertyValueContainer)
|
||||
@@ -0,0 +1,98 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "reparentcontainer.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
ReparentContainer::ReparentContainer()
|
||||
: m_instanceId(-1),
|
||||
m_oldParentInstanceId(-1),
|
||||
m_newParentInstanceId(-1)
|
||||
{
|
||||
}
|
||||
|
||||
ReparentContainer::ReparentContainer(qint32 instanceId,
|
||||
qint32 oldParentInstanceId,
|
||||
const PropertyName &oldParentProperty,
|
||||
qint32 newParentInstanceId,
|
||||
const PropertyName &newParentProperty)
|
||||
: m_instanceId(instanceId),
|
||||
m_oldParentInstanceId(oldParentInstanceId),
|
||||
m_oldParentProperty(oldParentProperty),
|
||||
m_newParentInstanceId(newParentInstanceId),
|
||||
m_newParentProperty(newParentProperty)
|
||||
{
|
||||
}
|
||||
|
||||
qint32 ReparentContainer::instanceId() const
|
||||
{
|
||||
return m_instanceId;
|
||||
}
|
||||
|
||||
qint32 ReparentContainer::oldParentInstanceId() const
|
||||
{
|
||||
return m_oldParentInstanceId;
|
||||
}
|
||||
|
||||
PropertyName ReparentContainer::oldParentProperty() const
|
||||
{
|
||||
return m_oldParentProperty;
|
||||
}
|
||||
|
||||
qint32 ReparentContainer::newParentInstanceId() const
|
||||
{
|
||||
return m_newParentInstanceId;
|
||||
}
|
||||
|
||||
PropertyName ReparentContainer::newParentProperty() const
|
||||
{
|
||||
return m_newParentProperty;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ReparentContainer &container)
|
||||
{
|
||||
out << container.instanceId();
|
||||
out << container.oldParentInstanceId();
|
||||
out << container.oldParentProperty();
|
||||
out << container.newParentInstanceId();
|
||||
out << container.newParentProperty();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ReparentContainer &container)
|
||||
{
|
||||
in >> container.m_instanceId;
|
||||
in >> container.m_oldParentInstanceId;
|
||||
in >> container.m_oldParentProperty;
|
||||
in >> container.m_newParentInstanceId;
|
||||
in >> container.m_newParentProperty;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const ReparentContainer &container)
|
||||
{
|
||||
debug.nospace() << "ReparentContainer("
|
||||
<< "instanceId: " << container.instanceId();
|
||||
|
||||
if (container.oldParentInstanceId() >= 0)
|
||||
debug.nospace() << ", " << "oldParentInstanceId: " << container.oldParentInstanceId();
|
||||
|
||||
if (container.oldParentProperty().isEmpty())
|
||||
debug.nospace() << ", " << "oldParentProperty: " << container.oldParentProperty();
|
||||
|
||||
if (container.newParentInstanceId() >= 0)
|
||||
debug.nospace() << ", " << "newParentInstanceId: " << container.newParentInstanceId();
|
||||
|
||||
if (container.newParentProperty().isEmpty())
|
||||
debug.nospace() << ", " << "newParentProperty: " << container.newParentProperty();
|
||||
|
||||
return debug.nospace() << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <qmetatype.h>
|
||||
#include <QString>
|
||||
#include <QDataStream>
|
||||
|
||||
#include "nodeinstanceglobal.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ReparentContainer
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, ReparentContainer &container);
|
||||
public:
|
||||
ReparentContainer();
|
||||
ReparentContainer(qint32 instanceId,
|
||||
qint32 oldParentInstanceId,
|
||||
const PropertyName &oldParentProperty,
|
||||
qint32 newParentInstanceId,
|
||||
const PropertyName &newParentProperty);
|
||||
|
||||
qint32 instanceId() const;
|
||||
qint32 oldParentInstanceId() const;
|
||||
PropertyName oldParentProperty() const;
|
||||
qint32 newParentInstanceId() const;
|
||||
PropertyName newParentProperty() const;
|
||||
|
||||
private:
|
||||
qint32 m_instanceId;
|
||||
qint32 m_oldParentInstanceId;
|
||||
PropertyName m_oldParentProperty;
|
||||
qint32 m_newParentInstanceId;
|
||||
PropertyName m_newParentProperty;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ReparentContainer &container);
|
||||
QDataStream &operator>>(QDataStream &in, ReparentContainer &container);
|
||||
|
||||
QDebug operator <<(QDebug debug, const ReparentContainer &container);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
67
src/libs/qmlpuppetcommunication/container/sharedmemory.h
Normal file
67
src/libs/qmlpuppetcommunication/container/sharedmemory.h
Normal file
@@ -0,0 +1,67 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QSharedMemory>
|
||||
#include <QSystemSemaphore>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class SharedMemory
|
||||
{
|
||||
friend class SharedMemoryLocker;
|
||||
public:
|
||||
SharedMemory();
|
||||
SharedMemory(const QString &key);
|
||||
~SharedMemory();
|
||||
|
||||
void setKey(const QString &key);
|
||||
QString key() const;
|
||||
|
||||
bool create(int size, QSharedMemory::AccessMode mode = QSharedMemory::ReadWrite);
|
||||
int size() const;
|
||||
|
||||
bool attach(QSharedMemory::AccessMode mode = QSharedMemory::ReadWrite);
|
||||
bool isAttached() const;
|
||||
bool detach();
|
||||
|
||||
void *data();
|
||||
const void* constData() const;
|
||||
const void *data() const;
|
||||
|
||||
bool lock();
|
||||
bool unlock();
|
||||
|
||||
QSharedMemory::SharedMemoryError error() const;
|
||||
QString errorString() const;
|
||||
|
||||
protected:
|
||||
#ifdef Q_OS_UNIX
|
||||
bool initKeyInternal();
|
||||
void cleanHandleInternal();
|
||||
bool createInternal(QSharedMemory::AccessMode mode, size_t size);
|
||||
bool attachInternal(QSharedMemory::AccessMode mode);
|
||||
bool detachInternal();
|
||||
int handle();
|
||||
|
||||
void setErrorString(const QString &function);
|
||||
#endif
|
||||
private:
|
||||
#ifndef Q_OS_UNIX
|
||||
QSharedMemory m_sharedMemory;
|
||||
#else
|
||||
void *m_memory;
|
||||
size_t m_size;
|
||||
QString m_key;
|
||||
QByteArray m_nativeKey;
|
||||
QSharedMemory::SharedMemoryError m_error;
|
||||
QString m_errorString;
|
||||
QSystemSemaphore m_systemSemaphore;
|
||||
bool m_lockedByMe;
|
||||
int m_fileHandle;
|
||||
bool m_createdByMe;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,87 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "sharedmemory.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
SharedMemory::SharedMemory() = default;
|
||||
|
||||
SharedMemory::SharedMemory(const QString &key)
|
||||
: m_sharedMemory(key)
|
||||
{
|
||||
}
|
||||
|
||||
SharedMemory::~SharedMemory() = default;
|
||||
|
||||
void SharedMemory::setKey(const QString &key)
|
||||
{
|
||||
m_sharedMemory.setKey(key);
|
||||
}
|
||||
|
||||
QString SharedMemory::key() const
|
||||
{
|
||||
return m_sharedMemory.key();
|
||||
}
|
||||
|
||||
bool SharedMemory::create(int size, QSharedMemory::AccessMode mode)
|
||||
{
|
||||
return m_sharedMemory.create(size, mode);
|
||||
}
|
||||
|
||||
int SharedMemory::size() const
|
||||
{
|
||||
return m_sharedMemory.size();
|
||||
}
|
||||
|
||||
bool SharedMemory::attach(QSharedMemory::AccessMode mode)
|
||||
{
|
||||
return m_sharedMemory.attach(mode);
|
||||
}
|
||||
|
||||
bool SharedMemory::isAttached() const
|
||||
{
|
||||
return m_sharedMemory.isAttached();
|
||||
}
|
||||
|
||||
bool SharedMemory::detach()
|
||||
{
|
||||
return m_sharedMemory.detach();
|
||||
}
|
||||
|
||||
void *SharedMemory::data()
|
||||
{
|
||||
return m_sharedMemory.data();
|
||||
}
|
||||
|
||||
const void *SharedMemory::constData() const
|
||||
{
|
||||
return m_sharedMemory.constData();
|
||||
}
|
||||
|
||||
const void *SharedMemory::data() const
|
||||
{
|
||||
return m_sharedMemory.data();
|
||||
}
|
||||
|
||||
bool SharedMemory::lock()
|
||||
{
|
||||
return m_sharedMemory.lock();
|
||||
}
|
||||
|
||||
bool SharedMemory::unlock()
|
||||
{
|
||||
return m_sharedMemory.unlock();
|
||||
}
|
||||
|
||||
QSharedMemory::SharedMemoryError SharedMemory::error() const
|
||||
{
|
||||
return m_sharedMemory.error();
|
||||
}
|
||||
|
||||
QString SharedMemory::errorString() const
|
||||
{
|
||||
return m_sharedMemory.errorString();
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
464
src/libs/qmlpuppetcommunication/container/sharedmemory_unix.cpp
Normal file
464
src/libs/qmlpuppetcommunication/container/sharedmemory_unix.cpp
Normal file
@@ -0,0 +1,464 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "sharedmemory.h"
|
||||
#include <qdir.h>
|
||||
#include <qcryptographichash.h>
|
||||
|
||||
#include "qplatformdefs.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h> /* For mode constants */
|
||||
#include <fcntl.h> /* For O_* constants */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef Q_OS_OSX
|
||||
#include <sys/posix_shm.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <private/qcore_unix_p.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class SharedMemoryLocker
|
||||
{
|
||||
public:
|
||||
SharedMemoryLocker(SharedMemory *sharedMemory) : m_sharedMemory(sharedMemory)
|
||||
{
|
||||
Q_ASSERT(m_sharedMemory);
|
||||
}
|
||||
|
||||
~SharedMemoryLocker()
|
||||
{
|
||||
if (m_sharedMemory)
|
||||
m_sharedMemory->unlock();
|
||||
}
|
||||
|
||||
bool tryLocker(const QString &function) {
|
||||
if (!m_sharedMemory)
|
||||
return false;
|
||||
|
||||
if (m_sharedMemory->lock())
|
||||
return true;
|
||||
|
||||
m_sharedMemory->m_errorString = QStringLiteral("%1: unable to lock").arg(function);
|
||||
m_sharedMemory->m_error = QSharedMemory::LockError;
|
||||
m_sharedMemory = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
SharedMemory *m_sharedMemory;
|
||||
};
|
||||
|
||||
static QByteArray makePlatformSafeKey(const QString &key)
|
||||
{
|
||||
if (key.isEmpty())
|
||||
return QByteArray();
|
||||
QByteArray data(QCryptographicHash::hash(key.toLatin1(), QCryptographicHash::Sha1).toBase64());
|
||||
|
||||
data = data.replace('+', '-');
|
||||
data = data.replace('/', '_');
|
||||
|
||||
data.truncate(31); // OS X is only supporting 31 byte long names
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
SharedMemory::SharedMemory()
|
||||
: m_memory(nullptr),
|
||||
m_size(0),
|
||||
m_error(QSharedMemory::NoError),
|
||||
m_systemSemaphore(QString()),
|
||||
m_lockedByMe(false),
|
||||
m_fileHandle(-1),
|
||||
m_createdByMe(false)
|
||||
{
|
||||
}
|
||||
|
||||
SharedMemory::SharedMemory(const QString &key)
|
||||
: m_memory(nullptr),
|
||||
m_size(0),
|
||||
m_error(QSharedMemory::NoError),
|
||||
m_systemSemaphore(QString()),
|
||||
m_lockedByMe(false),
|
||||
m_fileHandle(-1),
|
||||
m_createdByMe(false)
|
||||
{
|
||||
setKey(key);
|
||||
}
|
||||
|
||||
SharedMemory::~SharedMemory()
|
||||
{
|
||||
if (m_memory) {
|
||||
munmap(m_memory, m_size);
|
||||
m_memory = nullptr;
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
if (m_fileHandle != -1) {
|
||||
close(m_fileHandle);
|
||||
cleanHandleInternal();
|
||||
if (m_createdByMe)
|
||||
shm_unlink(m_nativeKey);
|
||||
}
|
||||
|
||||
setKey(QString());
|
||||
}
|
||||
|
||||
void SharedMemory::setKey(const QString &key)
|
||||
{
|
||||
if (key == m_key && makePlatformSafeKey(key) == m_nativeKey)
|
||||
return;
|
||||
|
||||
if (isAttached())
|
||||
detach();
|
||||
|
||||
m_key = key;
|
||||
m_nativeKey = makePlatformSafeKey(key);
|
||||
}
|
||||
|
||||
QString SharedMemory::key() const
|
||||
{
|
||||
return m_key;
|
||||
}
|
||||
|
||||
bool SharedMemory::create(int size, QSharedMemory::AccessMode mode)
|
||||
{
|
||||
if (!initKeyInternal())
|
||||
return false;
|
||||
|
||||
|
||||
m_systemSemaphore.setKey(m_key, 1, QSystemSemaphore::Create);
|
||||
|
||||
|
||||
QString function = QLatin1String("SharedMemory::create");
|
||||
|
||||
SharedMemoryLocker lock(this);
|
||||
if (!m_key.isNull() && !lock.tryLocker(function))
|
||||
return false;
|
||||
|
||||
if (size <= 0) {
|
||||
m_error = QSharedMemory::InvalidSize;
|
||||
m_errorString = QStringLiteral("%1: create size is less then 0").arg(function);
|
||||
return false;
|
||||
}
|
||||
|
||||
return createInternal(mode, size_t(size));
|
||||
}
|
||||
|
||||
int SharedMemory::size() const
|
||||
{
|
||||
return int(m_size);
|
||||
}
|
||||
|
||||
bool SharedMemory::attach(QSharedMemory::AccessMode mode)
|
||||
{
|
||||
if (isAttached() || !initKeyInternal())
|
||||
return false;
|
||||
|
||||
SharedMemoryLocker lock(this);
|
||||
if (!m_key.isNull() && !lock.tryLocker(QStringLiteral("SharedMemory::attach")))
|
||||
return false;
|
||||
|
||||
if (isAttached() || !handle())
|
||||
return false;
|
||||
|
||||
return attachInternal(mode);
|
||||
}
|
||||
|
||||
|
||||
bool SharedMemory::isAttached() const
|
||||
{
|
||||
return m_memory != nullptr;
|
||||
}
|
||||
|
||||
bool SharedMemory::detach()
|
||||
{
|
||||
if (!isAttached())
|
||||
return false;
|
||||
|
||||
SharedMemoryLocker lock(this);
|
||||
if (!m_key.isNull() && !lock.tryLocker(QStringLiteral("SharedMemory::detach")))
|
||||
return false;
|
||||
|
||||
return detachInternal();
|
||||
}
|
||||
|
||||
void *SharedMemory::data()
|
||||
{
|
||||
return m_memory;
|
||||
}
|
||||
|
||||
const void* SharedMemory::constData() const
|
||||
{
|
||||
return m_memory;
|
||||
}
|
||||
|
||||
const void *SharedMemory::data() const
|
||||
{
|
||||
return m_memory;
|
||||
}
|
||||
|
||||
bool SharedMemory::lock()
|
||||
{
|
||||
if (m_lockedByMe) {
|
||||
qWarning("SharedMemory::lock: already locked");
|
||||
return true;
|
||||
}
|
||||
if (m_systemSemaphore.acquire()) {
|
||||
m_lockedByMe = true;
|
||||
return true;
|
||||
}
|
||||
QString function = QStringLiteral("SharedMemory::lock");
|
||||
m_errorString = QStringLiteral("%1: unable to lock").arg(function);
|
||||
m_error = QSharedMemory::LockError;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SharedMemory::unlock()
|
||||
{
|
||||
if (!m_lockedByMe)
|
||||
return false;
|
||||
m_lockedByMe = false;
|
||||
if (m_systemSemaphore.release())
|
||||
return true;
|
||||
QString function = QStringLiteral("SharedMemory::unlock");
|
||||
m_errorString = QStringLiteral("%1: unable to unlock").arg(function);
|
||||
m_error = QSharedMemory::LockError;
|
||||
return false;
|
||||
}
|
||||
|
||||
QSharedMemory::SharedMemoryError SharedMemory::error() const
|
||||
{
|
||||
return m_error;
|
||||
}
|
||||
|
||||
QString SharedMemory::errorString() const
|
||||
{
|
||||
return m_errorString;
|
||||
}
|
||||
|
||||
void SharedMemory::setErrorString(const QString &function)
|
||||
{
|
||||
// EINVAL is handled in functions so they can give better error strings
|
||||
switch (errno) {
|
||||
case EACCES:
|
||||
m_errorString = QStringLiteral("%1: permission denied").arg(function);
|
||||
m_error = QSharedMemory::PermissionDenied;
|
||||
break;
|
||||
case EEXIST:
|
||||
m_errorString = QStringLiteral("%1: already exists").arg(function);
|
||||
m_error = QSharedMemory::AlreadyExists;
|
||||
break;
|
||||
case ENOENT:
|
||||
m_errorString = QStringLiteral("%1: doesn't exist").arg(function);
|
||||
m_error = QSharedMemory::NotFound;
|
||||
break;
|
||||
case EMFILE:
|
||||
case ENOMEM:
|
||||
case ENOSPC:
|
||||
m_errorString = QStringLiteral("%1: out of resources").arg(function);
|
||||
m_error = QSharedMemory::OutOfResources;
|
||||
break;
|
||||
default:
|
||||
m_errorString = QStringLiteral("%1: unknown error %2")
|
||||
.arg(function).arg(QString::fromLocal8Bit(strerror(errno)));
|
||||
m_error = QSharedMemory::UnknownError;
|
||||
}
|
||||
}
|
||||
|
||||
bool SharedMemory::initKeyInternal()
|
||||
{
|
||||
cleanHandleInternal();
|
||||
|
||||
m_systemSemaphore.setKey(QString(), 1);
|
||||
m_systemSemaphore.setKey(m_key, 1);
|
||||
if (m_systemSemaphore.error() != QSystemSemaphore::NoError) {
|
||||
m_errorString = QStringLiteral("SharedMemoryPrivate::initKey: unable to set key on lock");
|
||||
switch (m_systemSemaphore.error()) {
|
||||
case QSystemSemaphore::PermissionDenied:
|
||||
m_error = QSharedMemory::PermissionDenied;
|
||||
break;
|
||||
case QSystemSemaphore::KeyError:
|
||||
m_error = QSharedMemory::KeyError;
|
||||
break;
|
||||
case QSystemSemaphore::AlreadyExists:
|
||||
m_error = QSharedMemory::AlreadyExists;
|
||||
break;
|
||||
case QSystemSemaphore::NotFound:
|
||||
m_error = QSharedMemory::NotFound;
|
||||
break;
|
||||
case QSystemSemaphore::OutOfResources:
|
||||
m_error = QSharedMemory::OutOfResources;
|
||||
break;
|
||||
case QSystemSemaphore::UnknownError:
|
||||
default:
|
||||
m_error = QSharedMemory::UnknownError;
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_errorString.clear();
|
||||
m_error = QSharedMemory::NoError;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SharedMemory::handle()
|
||||
{
|
||||
return m_fileHandle;
|
||||
}
|
||||
|
||||
void SharedMemory::cleanHandleInternal()
|
||||
{
|
||||
m_fileHandle = -1;
|
||||
}
|
||||
|
||||
bool SharedMemory::createInternal(QSharedMemory::AccessMode mode, size_t size)
|
||||
{
|
||||
detachInternal();
|
||||
|
||||
#ifdef Q_OS_OSX
|
||||
if (m_fileHandle > -1 && m_createdByMe) {
|
||||
close(m_fileHandle);
|
||||
shm_unlink(m_nativeKey.constData());
|
||||
m_fileHandle = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_fileHandle == -1) {
|
||||
int permission = mode == QSharedMemory::ReadOnly ? O_RDONLY : O_RDWR;
|
||||
m_fileHandle = shm_open(m_nativeKey.constData(), O_CREAT | permission, 0666);
|
||||
|
||||
if (m_fileHandle == -1) {
|
||||
switch (errno) {
|
||||
case EINVAL:
|
||||
m_errorString = QStringLiteral("QSharedMemory::create: key is not invalid");
|
||||
m_error = QSharedMemory::KeyError;
|
||||
break;
|
||||
case EMFILE:
|
||||
m_errorString = QStringLiteral("QSharedMemory::create: maximum file limit reached");
|
||||
m_error = QSharedMemory::UnknownError;
|
||||
break;
|
||||
case ENAMETOOLONG:
|
||||
m_errorString = QStringLiteral("QSharedMemory::create: key is to long");
|
||||
m_error = QSharedMemory::KeyError;
|
||||
break;
|
||||
default:
|
||||
setErrorString(QStringLiteral("SharedMemory::create"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_createdByMe = true;
|
||||
}
|
||||
|
||||
struct stat statBuffer;
|
||||
if (fstat(m_fileHandle, &statBuffer) == -1)
|
||||
return false;
|
||||
size_t fileSize = size_t(statBuffer.st_size);
|
||||
|
||||
if (fileSize < size) {
|
||||
int returnValue = ftruncate(m_fileHandle, ssize_t(size));
|
||||
if (returnValue == -1) {
|
||||
switch (errno) {
|
||||
case EFBIG:
|
||||
m_errorString = QStringLiteral("QSharedMemory::create: size is to large");
|
||||
m_error = QSharedMemory::InvalidSize;
|
||||
break;
|
||||
default:
|
||||
setErrorString(QStringLiteral("SharedMemory::create"));
|
||||
}
|
||||
|
||||
close(m_fileHandle);
|
||||
shm_unlink(m_nativeKey.constData());
|
||||
m_fileHandle = -1;
|
||||
m_size = 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int protection = mode == QSharedMemory::ReadOnly ? PROT_READ : PROT_WRITE;
|
||||
m_memory = mmap(nullptr, size, protection, MAP_SHARED, m_fileHandle, 0);
|
||||
|
||||
if (m_memory == MAP_FAILED) {
|
||||
close(m_fileHandle);
|
||||
shm_unlink(m_nativeKey.constData());
|
||||
m_memory = nullptr;
|
||||
m_fileHandle = -1;
|
||||
m_size = 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_size = size;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SharedMemory::attachInternal(QSharedMemory::AccessMode mode)
|
||||
{
|
||||
if (m_fileHandle == -1) {
|
||||
int permission = mode == QSharedMemory::ReadOnly ? O_RDONLY : O_RDWR;
|
||||
m_fileHandle = shm_open(m_nativeKey.constData(), permission, 0666);
|
||||
if (m_fileHandle == -1) {
|
||||
switch (errno) {
|
||||
case EINVAL:
|
||||
m_errorString = QStringLiteral("QSharedMemory::attach: key is invalid");
|
||||
m_error = QSharedMemory::KeyError;
|
||||
break;
|
||||
case EMFILE:
|
||||
m_errorString = QStringLiteral("QSharedMemory::attach: maximum file limit reached");
|
||||
m_error = QSharedMemory::UnknownError;
|
||||
break;
|
||||
case ENAMETOOLONG:
|
||||
m_errorString = QStringLiteral("QSharedMemory::attach: key is to long");
|
||||
m_error = QSharedMemory::KeyError;
|
||||
break;
|
||||
default:
|
||||
setErrorString(QStringLiteral("SharedMemory::attach"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
struct stat statBuffer;
|
||||
if (fstat(m_fileHandle, &statBuffer) == -1)
|
||||
return false;
|
||||
size_t size = size_t(statBuffer.st_size);
|
||||
|
||||
int protection = mode == QSharedMemory::ReadOnly ? PROT_READ : PROT_WRITE;
|
||||
m_memory = mmap(nullptr, size, protection, MAP_SHARED, m_fileHandle, 0);
|
||||
|
||||
if (m_memory == MAP_FAILED) {
|
||||
m_memory = nullptr;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_size = size;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SharedMemory::detachInternal()
|
||||
{
|
||||
if (m_memory) {
|
||||
munmap(m_memory, m_size);
|
||||
m_memory = nullptr;
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
40
src/libs/qmlpuppetcommunication/interfaces/commondefines.h
Normal file
40
src/libs/qmlpuppetcommunication/interfaces/commondefines.h
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QPair>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
enum InformationName {
|
||||
NoName,
|
||||
NoInformationChange = NoName,
|
||||
AllStates,
|
||||
Size,
|
||||
BoundingRect,
|
||||
BoundingRectPixmap,
|
||||
Transform,
|
||||
HasAnchor,
|
||||
Anchor,
|
||||
InstanceTypeForProperty,
|
||||
PenWidth,
|
||||
Position,
|
||||
IsInLayoutable,
|
||||
SceneTransform,
|
||||
IsResizable,
|
||||
IsMovable,
|
||||
IsAnchoredByChildren,
|
||||
IsAnchoredBySibling,
|
||||
HasContent,
|
||||
HasBindingForProperty,
|
||||
ContentTransform,
|
||||
ContentItemTransform,
|
||||
ContentItemBoundingRect,
|
||||
MoveView,
|
||||
ShowView,
|
||||
ResizeView,
|
||||
HideView
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ValuesChangedCommand;
|
||||
class ValuesModifiedCommand;
|
||||
class PixmapChangedCommand;
|
||||
class InformationChangedCommand;
|
||||
class ChildrenChangedCommand;
|
||||
class StatePreviewImageChangedCommand;
|
||||
class ComponentCompletedCommand;
|
||||
class TokenCommand;
|
||||
class RemoveSharedMemoryCommand;
|
||||
class DebugOutputCommand;
|
||||
class PuppetAliveCommand;
|
||||
class ChangeSelectionCommand;
|
||||
class PuppetToCreatorCommand;
|
||||
class CapturedDataCommand;
|
||||
class SceneCreatedCommand;
|
||||
|
||||
class NodeInstanceClientInterface
|
||||
{
|
||||
public:
|
||||
virtual void informationChanged(const InformationChangedCommand &command) = 0;
|
||||
virtual void valuesChanged(const ValuesChangedCommand &command) = 0;
|
||||
virtual void valuesModified(const ValuesModifiedCommand &command) = 0;
|
||||
virtual void pixmapChanged(const PixmapChangedCommand &command) = 0;
|
||||
virtual void childrenChanged(const ChildrenChangedCommand &command) = 0;
|
||||
virtual void statePreviewImagesChanged(const StatePreviewImageChangedCommand &command) = 0;
|
||||
virtual void componentCompleted(const ComponentCompletedCommand &command) = 0;
|
||||
virtual void token(const TokenCommand &command) = 0;
|
||||
virtual void debugOutput(const DebugOutputCommand &command) = 0;
|
||||
virtual void selectionChanged(const ChangeSelectionCommand &command) = 0;
|
||||
virtual void handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) = 0;
|
||||
virtual void capturedData(const CapturedDataCommand &command) = 0;
|
||||
virtual void sceneCreated(const SceneCreatedCommand &command) = 0;
|
||||
|
||||
virtual void flush() {}
|
||||
virtual void synchronizeWithClientProcess() {}
|
||||
virtual qint64 bytesToWrite() const {return 0;}
|
||||
};
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user