diff options
author | Marco Bubke <marco.bubke@digia.com> | 2013-07-04 17:06:31 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@digia.com> | 2013-07-08 11:28:38 +0200 |
commit | 90ce3aec8b31cb24bf729da91d6eb8b0cf300b28 (patch) | |
tree | 6b8823f14188bf2372e23fae056172c264030cfa /share/qtcreator/qml/qmlpuppet | |
parent | 6312cc18e2e2d9a3a1d4146ad94e22a87e66d6e0 (diff) | |
download | qt-creator-90ce3aec8b31cb24bf729da91d6eb8b0cf300b28.tar.gz |
QmlDesigner: Test mode for qml puppet streams
Change-Id: I93128c60892900d6b4728569b84efb0ed835b51f
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
Diffstat (limited to 'share/qtcreator/qml/qmlpuppet')
35 files changed, 836 insertions, 72 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/commands/childrenchangedcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/childrenchangedcommand.cpp index e0378eee69..3d9f9096f2 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/childrenchangedcommand.cpp +++ b/share/qtcreator/qml/qmlpuppet/commands/childrenchangedcommand.cpp @@ -58,6 +58,12 @@ QVector<InformationContainer> ChildrenChangedCommand::informations() const return m_informationVector; } +void ChildrenChangedCommand::sort() +{ + qSort(m_childrenVector); + qSort(m_informationVector); +} + QDataStream &operator<<(QDataStream &out, const ChildrenChangedCommand &command) { out << command.parentInstanceId(); @@ -75,4 +81,11 @@ QDataStream &operator>>(QDataStream &in, ChildrenChangedCommand &command) 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; +} + } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/childrenchangedcommand.h b/share/qtcreator/qml/qmlpuppet/commands/childrenchangedcommand.h index 4f9cff6ee5..a4e1804050 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/childrenchangedcommand.h +++ b/share/qtcreator/qml/qmlpuppet/commands/childrenchangedcommand.h @@ -39,6 +39,8 @@ 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); @@ -47,6 +49,8 @@ public: qint32 parentInstanceId() const; QVector<InformationContainer> informations() const; + void sort(); + private: qint32 m_parentInstanceId; QVector<qint32> m_childrenVector; @@ -56,6 +60,8 @@ private: QDataStream &operator<<(QDataStream &out, const ChildrenChangedCommand &command); QDataStream &operator>>(QDataStream &in, ChildrenChangedCommand &command); +bool operator ==(const ChildrenChangedCommand &first, const ChildrenChangedCommand &second); + } // namespace QmlDesigner Q_DECLARE_METATYPE(QmlDesigner::ChildrenChangedCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/componentcompletedcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/componentcompletedcommand.cpp index 478710ba78..ac54f3b964 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/componentcompletedcommand.cpp +++ b/share/qtcreator/qml/qmlpuppet/commands/componentcompletedcommand.cpp @@ -47,6 +47,11 @@ QVector<qint32> ComponentCompletedCommand::instances() const return m_instanceVector; } +void ComponentCompletedCommand::sort() +{ + qSort(m_instanceVector); +} + QDataStream &operator<<(QDataStream &out, const ComponentCompletedCommand &command) { out << command.instances(); @@ -61,5 +66,10 @@ QDataStream &operator>>(QDataStream &in, ComponentCompletedCommand &command) return in; } +bool operator ==(const ComponentCompletedCommand &first, const ComponentCompletedCommand &second) +{ + return first.m_instanceVector == second.m_instanceVector; +} + } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/componentcompletedcommand.h b/share/qtcreator/qml/qmlpuppet/commands/componentcompletedcommand.h index 176733aca8..6b65c61c8d 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/componentcompletedcommand.h +++ b/share/qtcreator/qml/qmlpuppet/commands/componentcompletedcommand.h @@ -38,6 +38,7 @@ namespace QmlDesigner { class ComponentCompletedCommand { friend QDataStream &operator>>(QDataStream &in, ComponentCompletedCommand &command); + friend bool operator ==(const ComponentCompletedCommand &first, const ComponentCompletedCommand &second); public: ComponentCompletedCommand(); @@ -45,6 +46,8 @@ public: QVector<qint32> instances() const; + void sort(); + private: QVector<qint32> m_instanceVector; }; @@ -52,6 +55,8 @@ private: QDataStream &operator<<(QDataStream &out, const ComponentCompletedCommand &command); QDataStream &operator>>(QDataStream &in, ComponentCompletedCommand &command); +bool operator ==(const ComponentCompletedCommand &first, const ComponentCompletedCommand &second); + } // namespace QmlDesigner Q_DECLARE_METATYPE(QmlDesigner::ComponentCompletedCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/debugoutputcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/debugoutputcommand.cpp index 8e9c1cdeac..dcfb7a5344 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/debugoutputcommand.cpp +++ b/share/qtcreator/qml/qmlpuppet/commands/debugoutputcommand.cpp @@ -68,4 +68,10 @@ QDataStream &operator>>(QDataStream &in, DebugOutputCommand &command) return in; } +bool operator ==(const DebugOutputCommand &first, const DebugOutputCommand &second) +{ + return first.m_type == second.m_type + && second.m_text == second.m_text; +} + } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/debugoutputcommand.h b/share/qtcreator/qml/qmlpuppet/commands/debugoutputcommand.h index 5f47cb9ea0..3cd6e006d8 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/debugoutputcommand.h +++ b/share/qtcreator/qml/qmlpuppet/commands/debugoutputcommand.h @@ -39,6 +39,7 @@ namespace QmlDesigner { class DebugOutputCommand { friend QDataStream &operator>>(QDataStream &in, DebugOutputCommand &command); + friend bool operator ==(const DebugOutputCommand &first, const DebugOutputCommand &second); public: enum Type { @@ -62,6 +63,8 @@ private: QDataStream &operator<<(QDataStream &out, const DebugOutputCommand &command); QDataStream &operator>>(QDataStream &in, DebugOutputCommand &command); +bool operator ==(const DebugOutputCommand &first, const DebugOutputCommand &second); + } // namespace QmlDesigner Q_DECLARE_METATYPE(QmlDesigner::DebugOutputCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/informationchangedcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/informationchangedcommand.cpp index f817b4555f..b32afd7b02 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/informationchangedcommand.cpp +++ b/share/qtcreator/qml/qmlpuppet/commands/informationchangedcommand.cpp @@ -49,6 +49,11 @@ QVector<InformationContainer> InformationChangedCommand::informations() const return m_informationVector; } +void InformationChangedCommand::sort() +{ + qSort(m_informationVector); +} + QDataStream &operator<<(QDataStream &out, const InformationChangedCommand &command) { out << command.informations(); @@ -63,4 +68,9 @@ QDataStream &operator>>(QDataStream &in, InformationChangedCommand &command) return in; } +bool operator ==(const InformationChangedCommand &first, const InformationChangedCommand &second) +{ + return first.m_informationVector == second.m_informationVector; +} + } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/informationchangedcommand.h b/share/qtcreator/qml/qmlpuppet/commands/informationchangedcommand.h index 46d3d6e956..1a61807b70 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/informationchangedcommand.h +++ b/share/qtcreator/qml/qmlpuppet/commands/informationchangedcommand.h @@ -41,6 +41,7 @@ namespace QmlDesigner { class InformationChangedCommand { friend QDataStream &operator>>(QDataStream &in, InformationChangedCommand &command); + friend bool operator ==(const InformationChangedCommand &first, const InformationChangedCommand &second); public: InformationChangedCommand(); @@ -48,6 +49,8 @@ public: QVector<InformationContainer> informations() const; + void sort(); + private: QVector<InformationContainer> m_informationVector; }; @@ -55,6 +58,8 @@ private: QDataStream &operator<<(QDataStream &out, const InformationChangedCommand &command); QDataStream &operator>>(QDataStream &in, InformationChangedCommand &command); +bool operator ==(const InformationChangedCommand &first, const InformationChangedCommand &second); + } // namespace QmlDesigner Q_DECLARE_METATYPE(QmlDesigner::InformationChangedCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/pixmapchangedcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/pixmapchangedcommand.cpp index 4bbc88db92..6dc0d13391 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/pixmapchangedcommand.cpp +++ b/share/qtcreator/qml/qmlpuppet/commands/pixmapchangedcommand.cpp @@ -49,6 +49,11 @@ QVector<ImageContainer> PixmapChangedCommand::images() const return m_imageVector; } +void PixmapChangedCommand::sort() +{ + qSort(m_imageVector); +} + QDataStream &operator<<(QDataStream &out, const PixmapChangedCommand &command) { out << command.images(); @@ -63,4 +68,9 @@ QDataStream &operator>>(QDataStream &in, PixmapChangedCommand &command) return in; } +bool operator ==(const PixmapChangedCommand &first, const PixmapChangedCommand &second) +{ + return first.m_imageVector == second.m_imageVector; +} + } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/pixmapchangedcommand.h b/share/qtcreator/qml/qmlpuppet/commands/pixmapchangedcommand.h index 45c02094d6..65eca7665d 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/pixmapchangedcommand.h +++ b/share/qtcreator/qml/qmlpuppet/commands/pixmapchangedcommand.h @@ -38,12 +38,16 @@ 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; }; @@ -51,6 +55,8 @@ private: QDataStream &operator<<(QDataStream &out, const PixmapChangedCommand &command); QDataStream &operator>>(QDataStream &in, PixmapChangedCommand &command); +bool operator ==(const PixmapChangedCommand &first, const PixmapChangedCommand &second); + } // namespace QmlDesigner Q_DECLARE_METATYPE(QmlDesigner::PixmapChangedCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/statepreviewimagechangedcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/statepreviewimagechangedcommand.cpp index c70b0ec2b2..4129e2191d 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/statepreviewimagechangedcommand.cpp +++ b/share/qtcreator/qml/qmlpuppet/commands/statepreviewimagechangedcommand.cpp @@ -45,6 +45,11 @@ QVector<ImageContainer> StatePreviewImageChangedCommand::previews()const return m_previewVector; } +void StatePreviewImageChangedCommand::sort() +{ + qSort(m_previewVector); +} + QDataStream &operator<<(QDataStream &out, const StatePreviewImageChangedCommand &command) { out << command.previews(); @@ -58,4 +63,10 @@ QDataStream &operator>>(QDataStream &in, StatePreviewImageChangedCommand &comman return in; } + +bool operator ==(const StatePreviewImageChangedCommand &first, const StatePreviewImageChangedCommand &second) +{ + return first.m_previewVector == second.m_previewVector; +} + } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/statepreviewimagechangedcommand.h b/share/qtcreator/qml/qmlpuppet/commands/statepreviewimagechangedcommand.h index 7d01dbba8f..bf31f588d6 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/statepreviewimagechangedcommand.h +++ b/share/qtcreator/qml/qmlpuppet/commands/statepreviewimagechangedcommand.h @@ -39,12 +39,16 @@ 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; }; @@ -52,6 +56,8 @@ private: QDataStream &operator<<(QDataStream &out, const StatePreviewImageChangedCommand &command); QDataStream &operator>>(QDataStream &in, StatePreviewImageChangedCommand &command); +bool operator ==(const StatePreviewImageChangedCommand &first, const StatePreviewImageChangedCommand &second); + } // namespace QmlDesigner Q_DECLARE_METATYPE(QmlDesigner::StatePreviewImageChangedCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/synchronizecommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/synchronizecommand.cpp index d215c2bd8a..5307798e14 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/synchronizecommand.cpp +++ b/share/qtcreator/qml/qmlpuppet/commands/synchronizecommand.cpp @@ -61,5 +61,9 @@ QDataStream &operator>>(QDataStream &in, SynchronizeCommand &command) return in; } +bool operator ==(const SynchronizeCommand &first, const SynchronizeCommand &second) +{ + return first.m_synchronizeId == second.m_synchronizeId; +} } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/synchronizecommand.h b/share/qtcreator/qml/qmlpuppet/commands/synchronizecommand.h index d82d253f0e..fd4d9904df 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/synchronizecommand.h +++ b/share/qtcreator/qml/qmlpuppet/commands/synchronizecommand.h @@ -40,6 +40,7 @@ namespace QmlDesigner { class SynchronizeCommand { friend QDataStream &operator>>(QDataStream &in, SynchronizeCommand &command); + friend bool operator ==(const SynchronizeCommand &first, const SynchronizeCommand &second); public: SynchronizeCommand(); @@ -54,6 +55,8 @@ private: QDataStream &operator<<(QDataStream &out, const SynchronizeCommand &command); QDataStream &operator>>(QDataStream &in, SynchronizeCommand &command); +bool operator ==(const SynchronizeCommand &first, const SynchronizeCommand &second); + } // namespace QmlDesigner Q_DECLARE_METATYPE(QmlDesigner::SynchronizeCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/tokencommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/tokencommand.cpp index 024dc9a997..91abc7a245 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/tokencommand.cpp +++ b/share/qtcreator/qml/qmlpuppet/commands/tokencommand.cpp @@ -60,6 +60,11 @@ QVector<qint32> TokenCommand::instances() const return m_instanceIdVector; } +void TokenCommand::sort() +{ + qSort(m_instanceIdVector); +} + QDataStream &operator<<(QDataStream &out, const TokenCommand &command) { out << command.tokenName(); @@ -77,5 +82,11 @@ QDataStream &operator>>(QDataStream &in, TokenCommand &command) return in; } +bool operator ==(const TokenCommand &first, const TokenCommand &second) +{ + return first.m_tokenNumber == second.m_tokenNumber + && first.m_tokenNumber == second.m_tokenNumber + && first.m_instanceIdVector == second.m_instanceIdVector; +} } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/tokencommand.h b/share/qtcreator/qml/qmlpuppet/commands/tokencommand.h index 5241e64dc9..bf42b809ca 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/tokencommand.h +++ b/share/qtcreator/qml/qmlpuppet/commands/tokencommand.h @@ -41,6 +41,7 @@ namespace QmlDesigner { class TokenCommand { friend QDataStream &operator>>(QDataStream &in, TokenCommand &command); + friend bool operator ==(const TokenCommand &first, const TokenCommand &second); public: TokenCommand(); @@ -50,6 +51,8 @@ public: qint32 tokenNumber() const; QVector<qint32> instances() const; + void sort(); + private: QString m_tokenName; qint32 m_tokenNumber; @@ -59,6 +62,8 @@ private: QDataStream &operator<<(QDataStream &out, const TokenCommand &command); QDataStream &operator>>(QDataStream &in, TokenCommand &command); +bool operator ==(const TokenCommand &first, const TokenCommand &second); + } // namespace QmlDesigner Q_DECLARE_METATYPE(QmlDesigner::TokenCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp index f832a74b75..71e07d55da 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp +++ b/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp @@ -67,6 +67,11 @@ void ValuesChangedCommand::removeSharedMemorys(const QVector<qint32> &keyNumberV } } +void ValuesChangedCommand::sort() +{ + qSort(m_valueChangeVector); +} + static const QLatin1String valueKeyTemplateString("Values-%1"); static QSharedMemory *createSharedMemory(qint32 key, int byteCount) @@ -142,4 +147,9 @@ QDataStream &operator>>(QDataStream &in, ValuesChangedCommand &command) return in; } +bool operator ==(const ValuesChangedCommand &first, const ValuesChangedCommand &second) +{ + return first.m_valueChangeVector == second.m_valueChangeVector; +} + } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.h b/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.h index 44f501c5fa..9689c7d446 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.h +++ b/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.h @@ -41,6 +41,7 @@ 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: ValuesChangedCommand(); @@ -51,6 +52,8 @@ public: static void removeSharedMemorys(const QVector<qint32> &keyNumberVector); + void sort(); + private: QVector<PropertyValueContainer> m_valueChangeVector; mutable quint32 m_keyNumber; @@ -59,6 +62,8 @@ private: QDataStream &operator<<(QDataStream &out, const ValuesChangedCommand &command); QDataStream &operator>>(QDataStream &in, ValuesChangedCommand &command); +bool operator ==(const ValuesChangedCommand &first, const ValuesChangedCommand &second); + } // namespace QmlDesigner Q_DECLARE_METATYPE(QmlDesigner::ValuesChangedCommand) diff --git a/share/qtcreator/qml/qmlpuppet/container/imagecontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/imagecontainer.cpp index 8b26d407ac..ea8c5c2099 100644 --- a/share/qtcreator/qml/qmlpuppet/container/imagecontainer.cpp +++ b/share/qtcreator/qml/qmlpuppet/container/imagecontainer.cpp @@ -231,4 +231,15 @@ QDataStream &operator>>(QDataStream &in, ImageContainer &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; +} + } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/container/imagecontainer.h b/share/qtcreator/qml/qmlpuppet/container/imagecontainer.h index 0e15dbd75c..0b9fc32adb 100644 --- a/share/qtcreator/qml/qmlpuppet/container/imagecontainer.h +++ b/share/qtcreator/qml/qmlpuppet/container/imagecontainer.h @@ -38,6 +38,9 @@ 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); @@ -59,6 +62,9 @@ private: 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); + } // namespace QmlDesigner Q_DECLARE_METATYPE(QmlDesigner::ImageContainer) diff --git a/share/qtcreator/qml/qmlpuppet/container/informationcontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/informationcontainer.cpp index 611fad7611..f0993e89ab 100644 --- a/share/qtcreator/qml/qmlpuppet/container/informationcontainer.cpp +++ b/share/qtcreator/qml/qmlpuppet/container/informationcontainer.cpp @@ -98,4 +98,30 @@ QDataStream &operator>>(QDataStream &in, InformationContainer &container) 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 operator <(const QVariant &first, const QVariant &second) +{ + if (first.userType() == second.userType()) { + if (first.canConvert<QByteArray>()) + return first.value<QByteArray>() < second.value<QByteArray>(); + } + + return true; +} + +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 && first.m_information < second.m_information); +} + } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/container/informationcontainer.h b/share/qtcreator/qml/qmlpuppet/container/informationcontainer.h index d3d97a9379..2ffeaf1538 100644 --- a/share/qtcreator/qml/qmlpuppet/container/informationcontainer.h +++ b/share/qtcreator/qml/qmlpuppet/container/informationcontainer.h @@ -43,6 +43,8 @@ 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(); @@ -69,6 +71,9 @@ private: 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); + } // namespace QmlDesigner Q_DECLARE_METATYPE(QmlDesigner::InformationContainer) diff --git a/share/qtcreator/qml/qmlpuppet/container/propertyvaluecontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/propertyvaluecontainer.cpp index 894b90e47d..0508bb41e3 100644 --- a/share/qtcreator/qml/qmlpuppet/container/propertyvaluecontainer.cpp +++ b/share/qtcreator/qml/qmlpuppet/container/propertyvaluecontainer.cpp @@ -29,6 +29,8 @@ #include "propertyvaluecontainer.h" +#include <QtDebug> + namespace QmlDesigner { PropertyValueContainer::PropertyValueContainer() @@ -89,4 +91,19 @@ QDataStream &operator>>(QDataStream &in, PropertyValueContainer &container) 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; +} + +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); +} + + } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/container/propertyvaluecontainer.h b/share/qtcreator/qml/qmlpuppet/container/propertyvaluecontainer.h index a13e7cb9ea..b72374e90c 100644 --- a/share/qtcreator/qml/qmlpuppet/container/propertyvaluecontainer.h +++ b/share/qtcreator/qml/qmlpuppet/container/propertyvaluecontainer.h @@ -42,6 +42,8 @@ namespace QmlDesigner { class PropertyValueContainer { 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); public: PropertyValueContainer(); @@ -63,6 +65,9 @@ private: QDataStream &operator<<(QDataStream &out, const PropertyValueContainer &container); QDataStream &operator>>(QDataStream &in, PropertyValueContainer &container); +bool operator ==(const PropertyValueContainer &first, const PropertyValueContainer &second); +bool operator <(const PropertyValueContainer &first, const PropertyValueContainer &second); + } // namespace QmlDesigner Q_DECLARE_METATYPE(QmlDesigner::PropertyValueContainer) diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp index 05fd208112..5588ce0fd1 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp @@ -33,6 +33,9 @@ #include <QVariant> #include <QCoreApplication> #include <QStringList> +#include <QFile> +#include <QFileInfo> +#include <QBuffer> #include "nodeinstanceserverinterface.h" @@ -72,37 +75,116 @@ namespace QmlDesigner { NodeInstanceClientProxy::NodeInstanceClientProxy(QObject *parent) : QObject(parent), + m_inputIoDevice(0), + m_outputIoDevice(0), m_nodeInstanceServer(0), - m_blockSize(0), m_writeCommandCounter(0), - m_lastReadCommandCounter(0), m_synchronizeId(-1) { } void NodeInstanceClientProxy::initializeSocket() { - m_socket = new QLocalSocket(this); - connect(m_socket, SIGNAL(readyRead()), this, SLOT(readDataStream())); - connect(m_socket, SIGNAL(error(QLocalSocket::LocalSocketError)), QCoreApplication::instance(), SLOT(quit())); - connect(m_socket, SIGNAL(disconnected()), QCoreApplication::instance(), SLOT(quit())); - m_socket->connectToServer(QCoreApplication::arguments().at(1), QIODevice::ReadWrite | QIODevice::Unbuffered); - m_socket->waitForConnected(-1); + QLocalSocket *localSocket = new QLocalSocket(this); + connect(localSocket, SIGNAL(readyRead()), this, SLOT(readDataStream())); + connect(localSocket, SIGNAL(error(QLocalSocket::LocalSocketError)), QCoreApplication::instance(), SLOT(quit())); + connect(localSocket, SIGNAL(disconnected()), QCoreApplication::instance(), SLOT(quit())); + localSocket->connectToServer(QCoreApplication::arguments().at(1), QIODevice::ReadWrite | QIODevice::Unbuffered); + localSocket->waitForConnected(-1); + + m_inputIoDevice = localSocket; + m_outputIoDevice = localSocket; +} + +void NodeInstanceClientProxy::initializeCapturedStream(const QString &fileName) +{ + m_inputIoDevice = new QFile(fileName, this); + bool inputStreamCanBeOpened = m_inputIoDevice->open(QIODevice::ReadOnly); + if (!inputStreamCanBeOpened) { + qDebug() << "Input stream file cannot be opened: " << fileName; + QCoreApplication::exit(-1); + } + + if (QCoreApplication::arguments().count() == 3) { + QFileInfo inputFileInfo(fileName); + m_outputIoDevice = new QFile(inputFileInfo.path()+ "/" + inputFileInfo.baseName() + ".commandcontrolstream", this); + bool outputStreamCanBeOpened = m_outputIoDevice->open(QIODevice::WriteOnly); + if (!outputStreamCanBeOpened) { + qDebug() << "Output stream file cannot be opened"; + QCoreApplication::exit(-1); + } + } else if (QCoreApplication::arguments().count() == 4) { + m_controlStream.setFileName(QCoreApplication::arguments().at(3)); + bool controlStreamCanBeOpened = m_controlStream.open(QIODevice::ReadOnly); + if (!controlStreamCanBeOpened) { + qDebug() << "Control stream file cannot be opened"; + QCoreApplication::exit(-1); + } + } + +} + +bool compareCommands(const QVariant &command, const QVariant &controlCommand) +{ + static const int informationChangedCommandType = QMetaType::type("InformationChangedCommand"); + static const int valuesChangedCommandType = QMetaType::type("ValuesChangedCommand"); + static const int pixmapChangedCommandType = QMetaType::type("PixmapChangedCommand"); + static const int childrenChangedCommandType = QMetaType::type("ChildrenChangedCommand"); + static const int statePreviewImageChangedCommandType = QMetaType::type("StatePreviewImageChangedCommand"); + static const int componentCompletedCommandType = QMetaType::type("ComponentCompletedCommand"); + static const int synchronizeCommandType = QMetaType::type("SynchronizeCommand"); + static const int tokenCommandType = QMetaType::type("TokenCommand"); + static const int debugOutputCommandType = QMetaType::type("DebugOutputCommand"); + + if (command.userType() == controlCommand.userType()) { + if (command.userType() == informationChangedCommandType) + return command.value<InformationChangedCommand>() == controlCommand.value<InformationChangedCommand>(); + else if (command.userType() == valuesChangedCommandType) + return command.value<ValuesChangedCommand>() == controlCommand.value<ValuesChangedCommand>(); + else if (command.userType() == pixmapChangedCommandType) + return command.value<PixmapChangedCommand>() == controlCommand.value<PixmapChangedCommand>(); + else if (command.userType() == childrenChangedCommandType) + return command.value<ChildrenChangedCommand>() == controlCommand.value<ChildrenChangedCommand>(); + else if (command.userType() == statePreviewImageChangedCommandType) + return command.value<StatePreviewImageChangedCommand>() == controlCommand.value<StatePreviewImageChangedCommand>(); + else if (command.userType() == componentCompletedCommandType) + return command.value<ComponentCompletedCommand>() == controlCommand.value<ComponentCompletedCommand>(); + else if (command.userType() == synchronizeCommandType) + return command.value<SynchronizeCommand>() == controlCommand.value<SynchronizeCommand>(); + else if (command.userType() == tokenCommandType) + return command.value<TokenCommand>() == controlCommand.value<TokenCommand>(); + else if (command.userType() == debugOutputCommandType) + return command.value<DebugOutputCommand>() == controlCommand.value<DebugOutputCommand>(); + } + + return false; } void NodeInstanceClientProxy::writeCommand(const QVariant &command) { - QByteArray block; - QDataStream out(&block, QIODevice::WriteOnly); - out.setVersion(QDataStream::Qt_4_8); - out << quint32(0); - out << quint32(m_writeCommandCounter); - m_writeCommandCounter++; - out << command; - out.device()->seek(0); - out << quint32(block.size() - sizeof(quint32)); + if (m_controlStream.isReadable()) { + static quint32 readCommandCounter = 0; + static quint32 blockSize = 0; - m_socket->write(block); + QVariant controlCommand = readCommandFromIOStream(&m_controlStream, &readCommandCounter, &blockSize); + + if (!compareCommands(command, controlCommand)) { + qDebug() << "Commands differ!"; + QCoreApplication::exit(-1); + } + } else if (m_outputIoDevice) { + QByteArray block; + QDataStream out(&block, QIODevice::WriteOnly); + out.setVersion(QDataStream::Qt_4_8); + out << quint32(0); + out << quint32(m_writeCommandCounter); + m_writeCommandCounter++; + out << command; + out.device()->seek(0); + out << quint32(block.size() - sizeof(quint32)); + + m_outputIoDevice->write(block); + } } void NodeInstanceClientProxy::informationChanged(const InformationChangedCommand &command) @@ -159,44 +241,60 @@ void NodeInstanceClientProxy::synchronizeWithClientProcess() qint64 NodeInstanceClientProxy::bytesToWrite() const { - return m_socket->bytesToWrite(); + return m_inputIoDevice->bytesToWrite(); } -void NodeInstanceClientProxy::readDataStream() +QVariant NodeInstanceClientProxy::readCommandFromIOStream(QIODevice *ioDevice, quint32 *readCommandCounter, quint32 *blockSize) { - QList<QVariant> commandList; - while (!m_socket->atEnd()) { - if (m_socket->bytesAvailable() < int(sizeof(quint32))) - break; - QDataStream in(m_socket); - in.setVersion(QDataStream::Qt_4_8); - if (m_blockSize == 0) { - in >> m_blockSize; - } + QDataStream in(ioDevice); + in.setVersion(QDataStream::Qt_4_8); - if (m_socket->bytesAvailable() < m_blockSize) - break; + if (*blockSize == 0) { + in >> *blockSize; + } - quint32 commandCounter; - in >> commandCounter; - bool commandLost = !((m_lastReadCommandCounter == 0 && commandCounter == 0) || (m_lastReadCommandCounter + 1 == commandCounter)); - if (commandLost) - qDebug() << "client command lost: " << m_lastReadCommandCounter << commandCounter; - m_lastReadCommandCounter = commandCounter; + if (ioDevice->bytesAvailable() < *blockSize) + return QVariant(); - QVariant command; - in >> command; - m_blockSize = 0; + quint32 commandCounter; + in >> commandCounter; + bool commandLost = !((commandCounter == 0 && *readCommandCounter == 0) || (*readCommandCounter + 1 == commandCounter)); + if (commandLost) + qDebug() << "client command lost: " << *readCommandCounter << commandCounter; + *readCommandCounter = commandCounter; - if (in.status() != QDataStream::Ok) { - qWarning() << "Stream is no ok!!!"; - exit(1); - } + QVariant command; + in >> command; + *blockSize = 0; - commandList.append(command); + if (in.status() != QDataStream::Ok) { + qWarning() << "Stream is no ok!!!"; + exit(1); + } + + return command; +} + +void NodeInstanceClientProxy::readDataStream() +{ + QList<QVariant> commandList; + + while (!m_inputIoDevice->atEnd()) { + if (m_inputIoDevice->bytesAvailable() < int(sizeof(quint32))) + break; + + static quint32 readCommandCounter = 0; + static quint32 blockSize = 0; + + QVariant command = readCommandFromIOStream(m_inputIoDevice, &readCommandCounter, &blockSize); + + if (command.isValid()) + commandList.append(command); + else + break; } foreach (const QVariant &command, commandList) { @@ -295,6 +393,15 @@ void NodeInstanceClientProxy::redirectToken(const TokenCommand &command) void NodeInstanceClientProxy::redirectToken(const EndPuppetCommand & /*command*/) { + if (m_outputIoDevice && m_outputIoDevice->isOpen()) + m_outputIoDevice->close(); + + if (m_inputIoDevice && m_inputIoDevice->isOpen()) + m_inputIoDevice->close(); + + if (m_controlStream.isOpen()) + m_controlStream.close(); + qDebug() << "End Process: " << QCoreApplication::applicationPid(); QCoreApplication::exit(); } diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h index cf7e038ac1..dc17f8408f 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h @@ -35,9 +35,11 @@ #include <QObject> #include <QHash> #include <QWeakPointer> +#include <QFile> QT_BEGIN_NAMESPACE class QLocalSocket; +class QIODevice; QT_END_NAMESPACE namespace QmlDesigner { @@ -82,6 +84,7 @@ public: protected: void initializeSocket(); + void initializeCapturedStream(const QString &fileName); void writeCommand(const QVariant &command); void dispatchCommand(const QVariant &command); NodeInstanceServerInterface *nodeInstanceServer() const; @@ -104,16 +107,18 @@ protected: void removeSharedMemory(const RemoveSharedMemoryCommand &command); void redirectToken(const TokenCommand &command); void redirectToken(const EndPuppetCommand &command); + static QVariant readCommandFromIOStream(QIODevice *ioDevice, quint32 *readCommandCounter, quint32 *blockSize); -private slots: +protected slots: void readDataStream(); private: - QLocalSocket *m_socket; + QFile m_controlStream; + QIODevice *m_inputIoDevice; + QIODevice *m_outputIoDevice; NodeInstanceServerInterface *m_nodeInstanceServer; quint32 m_blockSize; quint32 m_writeCommandCounter; - quint32 m_lastReadCommandCounter; int m_synchronizeId; }; diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h index 064e9b6d9d..36beb442da 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h @@ -59,7 +59,6 @@ public: virtual void flush() {}; virtual void synchronizeWithClientProcess() {} virtual qint64 bytesToWrite() const {return 0;} - }; } diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceglobal.h b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceglobal.h index 02c45362ba..8f55ef7772 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceglobal.h +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceglobal.h @@ -6,6 +6,7 @@ namespace QmlDesigner { typedef QByteArray PropertyName; typedef QList<PropertyName> PropertyNameList; typedef QByteArray TypeName; + } #endif // NODEINSTANCEGLOBAL_H diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri index 2bb894ef1b..8b8ba5b4c0 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri @@ -1,7 +1,8 @@ INCLUDEPATH += $$PWD/ HEADERS += $$PWD/qt5nodeinstanceserver.h -HEADERS += $$PWD//graphicalnodeinstance.h +HEADERS += $$PWD/qt5testnodeinstanceserver.h +HEADERS += $$PWD/graphicalnodeinstance.h HEADERS += $$PWD/qt5informationnodeinstanceserver.h HEADERS += $$PWD/qt5rendernodeinstanceserver.h HEADERS += $$PWD/qt5previewnodeinstanceserver.h @@ -26,26 +27,27 @@ HEADERS += $$PWD/quickwindownodeinstance.h HEADERS += $$PWD/layoutnodeinstance.h SOURCES += $$PWD/qt5nodeinstanceserver.cpp +SOURCES += $$PWD/qt5testnodeinstanceserver.cpp SOURCES += $$PWD/graphicalnodeinstance.cpp SOURCES += $$PWD/qt5informationnodeinstanceserver.cpp SOURCES += $$PWD/qt5rendernodeinstanceserver.cpp SOURCES += $$PWD/qt5previewnodeinstanceserver.cpp SOURCES += $$PWD/qt5nodeinstanceclientproxy.cpp SOURCES += $$PWD/quickitemnodeinstance.cpp -SOURCES += $$PWD/behaviornodeinstance.cpp -SOURCES += $$PWD/dummycontextobject.cpp -SOURCES += $$PWD/childrenchangeeventfilter.cpp -SOURCES += $$PWD/componentnodeinstance.cpp -SOURCES += $$PWD/dummynodeinstance.cpp -SOURCES += $$PWD/nodeinstancemetaobject.cpp -SOURCES += $$PWD/nodeinstanceserver.cpp -SOURCES += $$PWD/nodeinstancesignalspy.cpp -SOURCES += $$PWD/objectnodeinstance.cpp -SOURCES += $$PWD/qmlpropertychangesnodeinstance.cpp -SOURCES += $$PWD/qmlstatenodeinstance.cpp -SOURCES += $$PWD/qmltransitionnodeinstance.cpp -SOURCES += $$PWD/servernodeinstance.cpp -SOURCES += $$PWD/anchorchangesnodeinstance.cpp +SOURCES += $$PWD/behaviornodeinstance.cpp +SOURCES += $$PWD/dummycontextobject.cpp +SOURCES += $$PWD/childrenchangeeventfilter.cpp +SOURCES += $$PWD/componentnodeinstance.cpp +SOURCES += $$PWD/dummynodeinstance.cpp +SOURCES += $$PWD/nodeinstancemetaobject.cpp +SOURCES += $$PWD/nodeinstanceserver.cpp +SOURCES += $$PWD/nodeinstancesignalspy.cpp +SOURCES += $$PWD/objectnodeinstance.cpp +SOURCES += $$PWD/qmlpropertychangesnodeinstance.cpp +SOURCES += $$PWD/qmlstatenodeinstance.cpp +SOURCES += $$PWD/qmltransitionnodeinstance.cpp +SOURCES += $$PWD/servernodeinstance.cpp +SOURCES += $$PWD/anchorchangesnodeinstance.cpp SOURCES += $$PWD/positionernodeinstance.cpp SOURCES += $$PWD/quickwindownodeinstance.cpp SOURCES += $$PWD/layoutnodeinstance.cpp diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp index 1b6e663af2..dfc6dcfb84 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp @@ -34,6 +34,7 @@ #include "qt5informationnodeinstanceserver.h" #include "qt5previewnodeinstanceserver.h" #include "qt5rendernodeinstanceserver.h" +#include "qt5testnodeinstanceserver.h" #include <designersupport.h> @@ -43,15 +44,22 @@ Qt5NodeInstanceClientProxy::Qt5NodeInstanceClientProxy(QObject *parent) : NodeInstanceClientProxy(parent) { DesignerSupport::activateDesignerWindowManager(); - if (QCoreApplication::arguments().at(2) == QLatin1String("previewmode")) { + if (QCoreApplication::arguments().at(1) == QLatin1String("--readcapturedstream")) { + qputenv("DESIGNER_DONT_USE_SHARED_MEMORY", "1"); + setNodeInstanceServer(new Qt5TestNodeInstanceServer(this)); + initializeCapturedStream(QCoreApplication::arguments().at(2)); + readDataStream(); + QCoreApplication::exit(); + } else if (QCoreApplication::arguments().at(2) == QLatin1String("previewmode")) { setNodeInstanceServer(new Qt5PreviewNodeInstanceServer(this)); + initializeSocket(); } else if (QCoreApplication::arguments().at(2) == QLatin1String("editormode")) { setNodeInstanceServer(new Qt5InformationNodeInstanceServer(this)); + initializeSocket(); } else if (QCoreApplication::arguments().at(2) == QLatin1String("rendermode")) { setNodeInstanceServer(new Qt5RenderNodeInstanceServer(this)); + initializeSocket(); } - - initializeSocket(); } } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5testnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5testnodeinstanceserver.cpp new file mode 100644 index 0000000000..e476d9ff4a --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5testnodeinstanceserver.cpp @@ -0,0 +1,364 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "qt5testnodeinstanceserver.h" + +#include <QQuickItem> +#include <QQuickView> + +#include "servernodeinstance.h" +#include "childrenchangeeventfilter.h" +#include "propertyabstractcontainer.h" +#include "propertybindingcontainer.h" +#include "propertyvaluecontainer.h" +#include "instancecontainer.h" +#include "createinstancescommand.h" +#include "changefileurlcommand.h" +#include "clearscenecommand.h" +#include "reparentinstancescommand.h" +#include "changevaluescommand.h" +#include "changebindingscommand.h" +#include "changeidscommand.h" +#include "removeinstancescommand.h" +#include "nodeinstanceclientinterface.h" +#include "removepropertiescommand.h" +#include "valueschangedcommand.h" +#include "informationchangedcommand.h" +#include "pixmapchangedcommand.h" +#include "commondefines.h" +#include "changestatecommand.h" +#include "childrenchangedcommand.h" +#include "completecomponentcommand.h" +#include "componentcompletedcommand.h" +#include "createscenecommand.h" +#include "tokencommand.h" +#include "removesharedmemorycommand.h" +#include "changeauxiliarycommand.h" +#include "changenodesourcecommand.h" + +#include "dummycontextobject.h" + +#include <designersupport.h> + +namespace QmlDesigner { + +Qt5TestNodeInstanceServer::Qt5TestNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) + : Qt5NodeInstanceServer(nodeInstanceClient) +{ +} + +void Qt5TestNodeInstanceServer::createInstances(const CreateInstancesCommand &command) +{ + createInstances(command.instances()); + + refreshBindings(); + + collectItemChangesAndSendChangeCommands(); +} + +void Qt5TestNodeInstanceServer::changeFileUrl(const ChangeFileUrlCommand &command) +{ + setupFileUrl(command.fileUrl()); + + refreshBindings(); + collectItemChangesAndSendChangeCommands(); +} + +void Qt5TestNodeInstanceServer::changePropertyValues(const ChangeValuesCommand &command) +{ + bool hasDynamicProperties = false; + foreach (const PropertyValueContainer &container, command.valueChanges()) { + hasDynamicProperties |= container.isDynamic(); + setInstancePropertyVariant(container); + } + + if (hasDynamicProperties) + refreshBindings(); + + collectItemChangesAndSendChangeCommands(); +} + +void Qt5TestNodeInstanceServer::changePropertyBindings(const ChangeBindingsCommand &command) +{ + bool hasDynamicProperties = false; + foreach (const PropertyBindingContainer &container, command.bindingChanges()) { + hasDynamicProperties |= container.isDynamic(); + setInstancePropertyBinding(container); + } + + if (hasDynamicProperties) + refreshBindings(); + + collectItemChangesAndSendChangeCommands(); +} + +void Qt5TestNodeInstanceServer::changeAuxiliaryValues(const ChangeAuxiliaryCommand &command) +{ + foreach (const PropertyValueContainer &container, command.auxiliaryChanges()) { + setInstanceAuxiliaryData(container); + } + + collectItemChangesAndSendChangeCommands(); +} + +void Qt5TestNodeInstanceServer::changeIds(const ChangeIdsCommand &command) +{ + foreach (const IdContainer &container, command.ids()) { + if (hasInstanceForId(container.instanceId())) + instanceForId(container.instanceId()).setId(container.id()); + } + + refreshBindings(); + + collectItemChangesAndSendChangeCommands(); +} + +void Qt5TestNodeInstanceServer::createScene(const CreateSceneCommand &command) +{ + Qt5NodeInstanceServer::createScene(command); + + stopRenderTimer(); + + refreshBindings(); + + collectItemChangesAndSendChangeCommands(); +} + +void Qt5TestNodeInstanceServer::clearScene(const ClearSceneCommand &command) +{ + Qt5NodeInstanceServer::clearScene(command); +} + +void Qt5TestNodeInstanceServer::removeInstances(const RemoveInstancesCommand &command) +{ + ServerNodeInstance oldState = activeStateInstance(); + if (activeStateInstance().isValid()) + activeStateInstance().deactivateState(); + + foreach (qint32 instanceId, command.instanceIds()) { + removeInstanceRelationsip(instanceId); + } + + if (oldState.isValid()) + oldState.activateState(); + + refreshBindings(); + + collectItemChangesAndSendChangeCommands(); +} + +void Qt5TestNodeInstanceServer::removeProperties(const RemovePropertiesCommand &command) +{ + bool hasDynamicProperties = false; + foreach (const PropertyAbstractContainer &container, command.properties()) { + hasDynamicProperties |= container.isDynamic(); + resetInstanceProperty(container); + } + + if (hasDynamicProperties) + refreshBindings(); + + collectItemChangesAndSendChangeCommands(); +} + +void Qt5TestNodeInstanceServer::reparentInstances(const ReparentInstancesCommand &command) +{ + foreach (const ReparentContainer &container, command.reparentInstances()) { + ServerNodeInstance instance = instanceForId(container.instanceId()); + if (instance.isValid()) { + instance.reparent(instanceForId(container.oldParentInstanceId()), container.oldParentProperty(), instanceForId(container.newParentInstanceId()), container.newParentProperty()); + } + } + + refreshBindings(); + + collectItemChangesAndSendChangeCommands(); +} + +void Qt5TestNodeInstanceServer::changeState(const ChangeStateCommand &command) +{ + if (hasInstanceForId(command.stateInstanceId())) { + if (activeStateInstance().isValid()) + activeStateInstance().deactivateState(); + ServerNodeInstance instance = instanceForId(command.stateInstanceId()); + instance.activateState(); + } else { + if (activeStateInstance().isValid()) + activeStateInstance().deactivateState(); + } + + collectItemChangesAndSendChangeCommands(); +} + +void Qt5TestNodeInstanceServer::completeComponent(const CompleteComponentCommand &command) +{ + QList<ServerNodeInstance> instanceList; + + foreach (qint32 instanceId, command.instances()) { + if (hasInstanceForId(instanceId)) { + ServerNodeInstance instance = instanceForId(instanceId); + instance.doComponentComplete(); + instanceList.append(instance); + } + } + + refreshBindings(); + + collectItemChangesAndSendChangeCommands(); +} + +void Qt5TestNodeInstanceServer::changeNodeSource(const ChangeNodeSourceCommand &command) +{ + if (hasInstanceForId(command.instanceId())) { + ServerNodeInstance instance = instanceForId(command.instanceId()); + if (instance.isValid()) + instance.setNodeSource(command.nodeSource()); + } + + refreshBindings(); + + collectItemChangesAndSendChangeCommands(); +} + +void Qt5TestNodeInstanceServer::removeSharedMemory(const RemoveSharedMemoryCommand &command) +{ + if (command.typeName() == "Values") + ValuesChangedCommand::removeSharedMemorys(command.keyNumbers()); +} + +void QmlDesigner::Qt5TestNodeInstanceServer::collectItemChangesAndSendChangeCommands() +{ + DesignerSupport::polishItems(quickView()); + + QSet<ServerNodeInstance> informationChangedInstanceSet; + QVector<InstancePropertyPair> propertyChangedList; + QSet<ServerNodeInstance> parentChangedSet; + + if (quickView()) { + foreach (QQuickItem *item, allItems()) { + if (item && hasInstanceForObject(item)) { + ServerNodeInstance instance = instanceForObject(item); + + if (isDirtyRecursiveForNonInstanceItems(item)) + informationChangedInstanceSet.insert(instance); + + + if (DesignerSupport::isDirty(item, DesignerSupport::ParentChanged)) { + parentChangedSet.insert(instance); + informationChangedInstanceSet.insert(instance); + } + } + } + + foreach (const InstancePropertyPair& property, changedPropertyList()) { + const ServerNodeInstance instance = property.first; + const QString propertyName = property.second; + + if (instance.isValid()) { + if (propertyName.contains("anchors")) + informationChangedInstanceSet.insert(instance); + + propertyChangedList.append(property); + } + } + + resetAllItems(); + clearChangedPropertyList(); + + if (!informationChangedInstanceSet.isEmpty()) { + InformationChangedCommand command = createAllInformationChangedCommand(informationChangedInstanceSet.toList()); + command.sort(); + nodeInstanceClient()->informationChanged(command); + } + if (!propertyChangedList.isEmpty()) { + ValuesChangedCommand command = createValuesChangedCommand(propertyChangedList); + command.sort(); + nodeInstanceClient()->valuesChanged(command); + } + + if (!parentChangedSet.isEmpty()) + sendChildrenChangedCommand(parentChangedSet.toList()); + } +} + +void Qt5TestNodeInstanceServer::sendChildrenChangedCommand(const QList<ServerNodeInstance> childList) +{ + QSet<ServerNodeInstance> parentSet; + QList<ServerNodeInstance> noParentList; + + foreach (const ServerNodeInstance &child, childList) { + if (!child.hasParent()) { + noParentList.append(child); + } else { + ServerNodeInstance parent = child.parent(); + if (parent.isValid()) { + parentSet.insert(parent); + } else { + noParentList.append(child); + } + } + } + + foreach (const ServerNodeInstance &parent, parentSet) { + ChildrenChangedCommand command = createChildrenChangedCommand(parent, parent.childItems()); + command.sort(); + nodeInstanceClient()->childrenChanged(command); + } + + if (!noParentList.isEmpty()) { + ChildrenChangedCommand command = createChildrenChangedCommand(ServerNodeInstance(), noParentList); + command.sort(); + nodeInstanceClient()->childrenChanged(command); + } +} + +bool Qt5TestNodeInstanceServer::isDirtyRecursiveForNonInstanceItems(QQuickItem *item) const +{ + static DesignerSupport::DirtyType informationsDirty = DesignerSupport::DirtyType(DesignerSupport::TransformUpdateMask + | DesignerSupport::ContentUpdateMask + | DesignerSupport::Visible + | DesignerSupport::ZValue + | DesignerSupport::OpacityValue); + + if (DesignerSupport::isDirty(item, informationsDirty)) + return true; + + foreach (QQuickItem *childItem, item->childItems()) { + if (!hasInstanceForObject(childItem)) { + if (DesignerSupport::isDirty(childItem, informationsDirty)) + return true; + else if (isDirtyRecursiveForNonInstanceItems(childItem)) + return true; + } + } + + return false; +} + +} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5testnodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5testnodeinstanceserver.h new file mode 100644 index 0000000000..c6eb49628b --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5testnodeinstanceserver.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + + +#ifndef QMLDESIGNER_QT5TESTNODEINSTANCESERVER_H +#define QMLDESIGNER_QT5TESTNODEINSTANCESERVER_H + +#include "qt5nodeinstanceserver.h" + +namespace QmlDesigner { + +class Qt5TestNodeInstanceServer : public Qt5NodeInstanceServer +{ +public: + Qt5TestNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient); + + + void createInstances(const CreateInstancesCommand &command); + void changeFileUrl(const ChangeFileUrlCommand &command); + void changePropertyValues(const ChangeValuesCommand &command); + void changePropertyBindings(const ChangeBindingsCommand &command); + void changeAuxiliaryValues(const ChangeAuxiliaryCommand &command); + void changeIds(const ChangeIdsCommand &command); + void createScene(const CreateSceneCommand &command); + void clearScene(const ClearSceneCommand &command); + void removeInstances(const RemoveInstancesCommand &command); + void removeProperties(const RemovePropertiesCommand &command); + void reparentInstances(const ReparentInstancesCommand &command); + void changeState(const ChangeStateCommand &command); + void completeComponent(const CompleteComponentCommand &command); + void changeNodeSource(const ChangeNodeSourceCommand &command); + void removeSharedMemory(const RemoveSharedMemoryCommand &command); + + using Qt5NodeInstanceServer::createInstances; + +protected: + void collectItemChangesAndSendChangeCommands() Q_DECL_OVERRIDE; + void sendChildrenChangedCommand(const QList<ServerNodeInstance> childList); + bool isDirtyRecursiveForNonInstanceItems(QQuickItem *item) const; +}; + +} // namespace QmlDesigner + +#endif // QMLDESIGNER_QT5TESTNODEINSTANCESERVER_H diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp index 548f371ac8..3d6d9d15e4 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp @@ -446,7 +446,7 @@ QPair<PropertyName, ServerNodeInstance> ServerNodeInstance::anchor(const Propert return m_nodeInstance->anchor(name); } -QDebug operator<<(QDebug debug, const ServerNodeInstance &instance) +QDebug operator <<(QDebug debug, const ServerNodeInstance &instance) { if (instance.isValid()) { debug.nospace() << "ServerNodeInstance(" @@ -466,11 +466,17 @@ uint qHash(const ServerNodeInstance &instance) return ::qHash(instance.instanceId()); } -bool operator==(const ServerNodeInstance &first, const ServerNodeInstance &second) +bool operator ==(const ServerNodeInstance &first, const ServerNodeInstance &second) { return first.instanceId() == second.instanceId(); } +bool operator <(const ServerNodeInstance &first, const ServerNodeInstance &second) +{ + return first.instanceId() < second.instanceId(); +} + + bool ServerNodeInstance::isWrappingThisObject(QObject *object) const { return internalObject() && internalObject() == object; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h index bb11386bb8..0ca5102ba5 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h @@ -55,6 +55,7 @@ class Qt4NodeInstanceServer; class Qt4PreviewNodeInstanceServer; class Qt5NodeInstanceServer; class Qt5PreviewNodeInstanceServer; +class Qt5TestNodeInstanceServer; class InstanceContainer; namespace Internal { @@ -73,6 +74,7 @@ class ServerNodeInstance friend class Qt4PreviewNodeInstanceServer; friend class Qt5NodeInstanceServer; friend class Qt5PreviewNodeInstanceServer; + friend class Qt5TestNodeInstanceServer; friend class QHash<qint32, ServerNodeInstance>; friend uint qHash(const ServerNodeInstance &instance); friend bool operator==(const ServerNodeInstance &first, const ServerNodeInstance &second); @@ -209,8 +211,9 @@ private: // variables }; uint qHash(const ServerNodeInstance &instance); -bool operator==(const ServerNodeInstance &first, const ServerNodeInstance &second); -QDebug operator<<(QDebug debug, const ServerNodeInstance &instance); +bool operator ==(const ServerNodeInstance &first, const ServerNodeInstance &second); +bool operator <(const ServerNodeInstance &first, const ServerNodeInstance &second); +QDebug operator <<(QDebug debug, const ServerNodeInstance &instance); } Q_DECLARE_METATYPE(QmlDesigner::ServerNodeInstance) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp index b2e2318f71..5d2886a161 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) return 0; } - if (application.arguments().count() < 4) { + if (application.arguments().at(1) != "--readcapturedstream" && application.arguments().count() < 4) { qDebug() << "Wrong argument count: " << application.arguments().count(); return -1; } |