diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h b/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h index 1983c4eebcf9c20c8e97bd2ed22cc2dc66bdab13..fb2ece65220f2f41b4b336b12c116a8989867180 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h +++ b/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h @@ -34,12 +34,14 @@ #define COMMONDEFINES_H #include <QMetaType> +#include <QPair> namespace QmlDesigner { enum InformationName { NoName, + NoInformationChange = NoName, Size, BoundingRect, Transform, diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp index 7e29dfb93e4faaf31c42d79944d3dc109d383ebe..aae97ea6e46559dc269f68c013dd3b5f311ac850 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp @@ -468,11 +468,11 @@ void FormEditorView::instancesCompleted(const QVector<ModelNode> &completedNodeL currentTool()->instancesCompleted(itemNodeList); } -void FormEditorView::instanceInformationsChange(const QVector<ModelNode> &nodeList) +void FormEditorView::instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash) { QList<FormEditorItem*> itemNodeList; - foreach (const ModelNode &node, nodeList) { + foreach (const ModelNode &node, informationChangeHash.keys()) { QmlItemNode qmlItemNode(node); if (qmlItemNode.isValid() && scene()->hasItemForQmlItemNode(qmlItemNode)) { scene()->synchronizeTransformation(qmlItemNode); diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.h b/src/plugins/qmldesigner/components/formeditor/formeditorview.h index ade7545d0f83a2913b2c474c402c7a47a6ef906b..27fbc9df82cbf0bc5dfd95972358eca16bd21a3a 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorview.h +++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.h @@ -106,7 +106,7 @@ public: void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data); void instancesCompleted(const QVector<ModelNode> &completedNodeList); - void instanceInformationsChange(const QVector<ModelNode> &nodeList); + void instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash); void instancesRenderImageChanged(const QVector<ModelNode> &nodeList); void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList); void instancesChildrenChanged(const QVector<ModelNode> &nodeList); diff --git a/src/plugins/qmldesigner/components/integration/componentview.cpp b/src/plugins/qmldesigner/components/integration/componentview.cpp index f54cbf34423844e6c158cac99846c169ac5c3e4b..a2d818d4dd260ecc2021290bfce2634518bb2fb0 100644 --- a/src/plugins/qmldesigner/components/integration/componentview.cpp +++ b/src/plugins/qmldesigner/components/integration/componentview.cpp @@ -208,7 +208,7 @@ void ComponentView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVers void ComponentView::scriptFunctionsChanged(const ModelNode &/*node*/, const QStringList &/*scriptFunctionList*/) {} void ComponentView::instancePropertyChange(const QList<QPair<ModelNode, QString> > &/*propertyList*/) {} void ComponentView::instancesCompleted(const QVector<ModelNode> &/*completedNodeList*/) {} -void ComponentView::instanceInformationsChange(const QVector<ModelNode> &/*nodeList*/) {} +void ComponentView::instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &/*informationChangeHash*/) {} void ComponentView::instancesRenderImageChanged(const QVector<ModelNode> &/*nodeList*/) {} void ComponentView::instancesPreviewImageChanged(const QVector<ModelNode> &/*nodeList*/) {} void ComponentView::instancesChildrenChanged(const QVector<ModelNode> &/*nodeList*/) {} diff --git a/src/plugins/qmldesigner/components/integration/componentview.h b/src/plugins/qmldesigner/components/integration/componentview.h index 190f6131abe81226202a655a6b06a2bcfbce6ec0..fef34556b511b714afe8dcfe7d22170ac53d288b 100644 --- a/src/plugins/qmldesigner/components/integration/componentview.h +++ b/src/plugins/qmldesigner/components/integration/componentview.h @@ -77,7 +77,7 @@ public: void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList); void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList); void instancesCompleted(const QVector<ModelNode> &completedNodeList); - void instanceInformationsChange(const QVector<ModelNode> &nodeList); + void instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &/*informationChangeHash*/); void instancesRenderImageChanged(const QVector<ModelNode> &nodeList); void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList); void instancesChildrenChanged(const QVector<ModelNode> &nodeList); diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp b/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp index 41292833551007fd98811dc179c335057f277d51..ead2ab44a1df169ac3a66833ed18a5c6ebfbfe58 100644 --- a/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp @@ -72,7 +72,7 @@ void DesignDocumentControllerView::instancesCompleted(const QVector<ModelNode> & { } -void DesignDocumentControllerView::instanceInformationsChange(const QVector<ModelNode> &/*nodeList*/) +void DesignDocumentControllerView::instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &/*informationChangeHash*/) { } diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.h b/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.h index 4cb1f9d1f080c741f4f04c3c36c4efab5cba714d..a915eeb4cd97a82da356aed627ffb74464dc72b5 100644 --- a/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.h +++ b/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.h @@ -64,7 +64,7 @@ public: virtual void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList); void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList); void instancesCompleted(const QVector<ModelNode> &completedNodeList); - void instanceInformationsChange(const QVector<ModelNode> &nodeList); + void instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash); void instancesRenderImageChanged(const QVector<ModelNode> &nodeList); void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList); void instancesChildrenChanged(const QVector<ModelNode> &nodeList); diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.cpp index 3271a7d149ef0624c30925db9b4b1f15bad20a85..611257b27f0fabb7daf9e1fa93fd34b6e9d8d3c8 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.cpp @@ -155,7 +155,7 @@ void ItemLibraryView::instancesCompleted(const QVector<ModelNode> &) } -void ItemLibraryView::instanceInformationsChange(const QVector<ModelNode> &/*nodeList*/) +void ItemLibraryView::instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &/*informationChangeHash*/) { } diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.h b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.h index e316de2c61e2af817b55a5824715ce3a02545a0e..3c61139efe3b5ae498a5be5dc3297d8c3c8863eb 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.h +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.h @@ -80,7 +80,7 @@ public: void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList); void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList); void instancesCompleted(const QVector<ModelNode> &completedNodeList); - void instanceInformationsChange(const QVector<ModelNode> &nodeList); + void instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash); void instancesRenderImageChanged(const QVector<ModelNode> &nodeList); void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList); void instancesChildrenChanged(const QVector<ModelNode> &nodeList); diff --git a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp index 54609ff6abc9dd70d5aeabef8c0d9d98a8a2a394..37f0d8d3edc58dbc868e95979ea4d55c79372255 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp +++ b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp @@ -218,7 +218,7 @@ void NavigatorView::instancesCompleted(const QVector<ModelNode> &/*completedNode { } -void NavigatorView::instanceInformationsChange(const QVector<ModelNode> &/*nodeList*/) +void NavigatorView::instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &/*informationChangeHash*/) { } diff --git a/src/plugins/qmldesigner/components/navigator/navigatorview.h b/src/plugins/qmldesigner/components/navigator/navigatorview.h index 3f1fbd05b4bf4f807b52444e52c07be8f700c4f5..dc05ac2bb4505dce67f640b0ba695f04820708aa 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatorview.h +++ b/src/plugins/qmldesigner/components/navigator/navigatorview.h @@ -88,7 +88,7 @@ public: void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList); void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList); void instancesCompleted(const QVector<ModelNode> &completedNodeList); - void instanceInformationsChange(const QVector<ModelNode> &nodeList); + void instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash); void instancesRenderImageChanged(const QVector<ModelNode> &nodeList); void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList); void instancesChildrenChanged(const QVector<ModelNode> &nodeList); diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp index 8d5e2a8a22750f8bf50d97c95e43531a136fa39d..d494e90878047b3df41a14b3ccedbdfb11d46e79 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp @@ -882,13 +882,14 @@ void PropertyEditor::bindingPropertiesChanged(const QList<BindingProperty>& prop } -void PropertyEditor::instanceInformationsChange(const QVector<ModelNode> &nodeList) +void PropertyEditor::instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash) { if (!m_selectedNode.isValid()) return; m_locked = true; - if (nodeList.contains(m_selectedNode)) + QList<InformationName> informationNameList = informationChangeHash.values(m_selectedNode); + if (informationNameList.contains(Anchor)) m_currentType->m_backendAnchorBinding.setup(QmlItemNode(m_selectedNode)); m_locked = false; } diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.h index 42b1d71858c79b39569076f14a70b7cdb7baa11d..d626b212463a6e044bbdde26388a1c331c5ed032 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.h @@ -105,7 +105,7 @@ public: void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange); void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange); - void instanceInformationsChange(const QVector<ModelNode> &nodeList); + void instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash); void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId); void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList); diff --git a/src/plugins/qmldesigner/designercore/include/abstractview.h b/src/plugins/qmldesigner/designercore/include/abstractview.h index ca48ad3773a564ffcb3d08cafd9ebe84a9b8f20a..88fc9204c9cd165066068cb1f4a563272f2a80a6 100644 --- a/src/plugins/qmldesigner/designercore/include/abstractview.h +++ b/src/plugins/qmldesigner/designercore/include/abstractview.h @@ -39,6 +39,7 @@ #include <modelnode.h> #include <abstractproperty.h> #include <rewritertransaction.h> +#include <commondefines.h> #include <QObject> @@ -114,7 +115,7 @@ public: void emitInstancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList); void emitInstancesCompleted(const QVector<ModelNode> &nodeList); - void emitInstanceInformationsChange(const QVector<ModelNode> &nodeList); + void emitInstanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash); void emitInstancesRenderImageChanged(const QVector<ModelNode> &nodeList); void emitInstancesPreviewImageChanged(const QVector<ModelNode> &nodeList); void emitInstancesChildrenChanged(const QVector<ModelNode> &nodeList); @@ -139,7 +140,7 @@ public: virtual void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList) = 0; virtual void instancesCompleted(const QVector<ModelNode> &completedNodeList) = 0; - virtual void instanceInformationsChange(const QVector<ModelNode> &nodeList) = 0; + virtual void instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash) = 0; virtual void instancesRenderImageChanged(const QVector<ModelNode> &nodeList) = 0; virtual void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList) = 0; virtual void instancesChildrenChanged(const QVector<ModelNode> &nodeList) = 0; diff --git a/src/plugins/qmldesigner/designercore/include/nodeinstance.h b/src/plugins/qmldesigner/designercore/include/nodeinstance.h index dff3856d45cf3920b7b1f5e4245193381eb74e82..cb630b4fac04dc550e758d389b0cd79f7973e238 100644 --- a/src/plugins/qmldesigner/designercore/include/nodeinstance.h +++ b/src/plugins/qmldesigner/designercore/include/nodeinstance.h @@ -85,11 +85,28 @@ public: protected: void setProperty(const QString &name, const QVariant &value); - void setInformation(InformationName name, + InformationName setInformation(InformationName name, const QVariant &information, const QVariant &secondInformation, const QVariant &thirdInformation); + InformationName setInformationSize(const QSizeF &size); + InformationName setInformationBoundingRect(const QRectF &rectangle); + InformationName setInformationTransform(const QTransform &transform); + InformationName setInformationPenWith(int penWidth); + InformationName setInformationPosition(const QPointF &position); + InformationName setInformationIsInPositioner(bool isInPositioner); + InformationName setInformationSceneTransform(const QTransform &sceneTransform); + InformationName setInformationIsResizable(bool isResizable); + InformationName setInformationIsMovable(bool isMovable); + InformationName setInformationIsAnchoredByChildren(bool isAnchoredByChildren); + InformationName setInformationIsAnchoredBySibling(bool isAnchoredBySibling); + InformationName setInformationHasContent(bool hasContent); + InformationName setInformationHasAnchor(const QString &sourceAnchorLine, bool hasAnchor); + InformationName setInformationAnchor(const QString &sourceAnchorLine, const QString &targetAnchorLine, qint32 targetInstanceId); + InformationName setInformationInstanceTypeForProperty(const QString &property, const QString &type); + InformationName setInformationHasBindingForProperty(const QString &property, bool hasProperty); + void setParentId(qint32 instanceId); void setRenderImage(const QImage &image); NodeInstance(ProxyNodeInstanceData *d); diff --git a/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h b/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h index 0bbfa74225961a1a21fd24c06b5e2e2daf186080..1cc469b411036b4f892fc17578a437053a0fd105 100644 --- a/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h +++ b/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h @@ -102,7 +102,7 @@ public: void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList); void instancesCompleted(const QVector<ModelNode> &completedNodeList); void importsChanged(const QList<Import> &addedImports, const QList<Import> &removedImports); - void instanceInformationsChange(const QVector<ModelNode> &nodeList); + void instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash); void instancesRenderImageChanged(const QVector<ModelNode> &nodeList); void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList); void instancesChildrenChanged(const QVector<ModelNode> &nodeList); diff --git a/src/plugins/qmldesigner/designercore/include/qmlmodelview.h b/src/plugins/qmldesigner/designercore/include/qmlmodelview.h index 67336ed684c36991da235cd6ccc8eb08cd35e35d..4b72f12481b9438f3780fa28e6b2ac12e21e56c0 100644 --- a/src/plugins/qmldesigner/designercore/include/qmlmodelview.h +++ b/src/plugins/qmldesigner/designercore/include/qmlmodelview.h @@ -94,7 +94,7 @@ public: void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList); void instancesCompleted(const QVector<ModelNode> &completedNodeList); - void instanceInformationsChange(const QVector<ModelNode> &nodeList); + void instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash); void instancesRenderImageChanged(const QVector<ModelNode> &nodeList); void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList); void instancesChildrenChanged(const QVector<ModelNode> &nodeList); diff --git a/src/plugins/qmldesigner/designercore/include/rewriterview.h b/src/plugins/qmldesigner/designercore/include/rewriterview.h index b8cb4cd204f98a916115bc60808793ffb92d5a85..2f3bf35e5c7d50b509422988e7621006c2015a0f 100644 --- a/src/plugins/qmldesigner/designercore/include/rewriterview.h +++ b/src/plugins/qmldesigner/designercore/include/rewriterview.h @@ -139,7 +139,7 @@ public: void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList); void instancesCompleted(const QVector<ModelNode> &completedNodeList); - void instanceInformationsChange(const QVector<ModelNode> &nodeList); + void instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash); void instancesRenderImageChanged(const QVector<ModelNode> &nodeList); void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList); void instancesChildrenChanged(const QVector<ModelNode> &nodeList); diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp index 59c66c2595724d9f725d21f55ca6374086882962..cdbb363a9ed44accc52400d24c34d4bd1246e00e 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp @@ -317,28 +317,191 @@ void NodeInstance::setParentId(qint32 instanceId) d->parentInstanceId = instanceId; } -void NodeInstance::setInformation(InformationName name, const QVariant &information, const QVariant &secondInformation, const QVariant &thirdInformation) +InformationName NodeInstance::setInformationSize(const QSizeF &size) +{ + if (d->size != size) { + d->size = size; + return Size; + } + + return NoInformationChange; +} + +InformationName NodeInstance::setInformationBoundingRect(const QRectF &rectangle) +{ + if (d->boundingRect != rectangle) { + d->boundingRect = rectangle; + return BoundingRect; + } + + return NoInformationChange; +} + +InformationName NodeInstance::setInformationTransform(const QTransform &transform) +{ + if (d->transform != transform) { + d->transform = transform; + return Transform; + } + + return NoInformationChange; +} + +InformationName NodeInstance::setInformationPenWith(int penWidth) +{ + if (d->penWidth != penWidth) { + d->penWidth = penWidth; + return PenWidth; + } + + return NoInformationChange; +} + +InformationName NodeInstance::setInformationPosition(const QPointF &position) +{ + if (d->position != position) { + d->position = position; + return Position; + } + + return NoInformationChange; +} + +InformationName NodeInstance::setInformationIsInPositioner(bool isInPositioner) +{ + if (d->isInPositioner != isInPositioner) { + d->isInPositioner = isInPositioner; + return IsInPositioner; + } + + return NoInformationChange; +} + +InformationName NodeInstance::setInformationSceneTransform(const QTransform &sceneTransform) +{ + if (d->sceneTransform != sceneTransform) { + d->sceneTransform = sceneTransform; + return SceneTransform; + } + + return NoInformationChange; +} + +InformationName NodeInstance::setInformationIsResizable(bool isResizable) +{ + if (d->isResizable != isResizable) { + d->isResizable = isResizable; + return IsResizable; + } + + return NoInformationChange; +} + +InformationName NodeInstance::setInformationIsMovable(bool isMovable) +{ + if (d->isMovable != isMovable) { + d->isMovable = isMovable; + return IsMovable; + } + + return NoInformationChange; +} + +InformationName NodeInstance::setInformationIsAnchoredByChildren(bool isAnchoredByChildren) +{ + if (d->isAnchoredByChildren != isAnchoredByChildren) { + d->isAnchoredByChildren = isAnchoredByChildren; + return IsAnchoredByChildren; + } + + return NoInformationChange; +} + +InformationName NodeInstance::setInformationIsAnchoredBySibling(bool isAnchoredBySibling) +{ + if (d->isAnchoredBySibling != isAnchoredBySibling) { + d->isAnchoredBySibling = isAnchoredBySibling; + return IsAnchoredBySibling; + } + + return NoInformationChange; +} + +InformationName NodeInstance::setInformationHasContent(bool hasContent) +{ + if (d->hasContent != hasContent) { + d->hasContent = hasContent; + return HasContent; + } + + return NoInformationChange; +} + +InformationName NodeInstance::setInformationHasAnchor(const QString &sourceAnchorLine, bool hasAnchor) +{ + if (d->hasAnchors.value(sourceAnchorLine) != hasAnchor) { + d->hasAnchors.insert(sourceAnchorLine, hasAnchor); + return HasAnchor; + } + + return NoInformationChange; +} + +InformationName NodeInstance::setInformationAnchor(const QString &sourceAnchorLine, const QString &targetAnchorLine, qint32 targetInstanceId) +{ + QPair<QString, qint32> anchorPair = QPair<QString, qint32>(targetAnchorLine, targetInstanceId); + if (d->anchors.value(sourceAnchorLine) != anchorPair) { + d->anchors.insert(sourceAnchorLine, anchorPair); + return Anchor; + } + + return NoInformationChange; +} + +InformationName NodeInstance::setInformationInstanceTypeForProperty(const QString &property, const QString &type) +{ + if (d->instanceTypes.value(property) != type) { + d->instanceTypes.insert(property, type); + return InstanceTypeForProperty; + } + + return NoInformationChange; +} + +InformationName NodeInstance::setInformationHasBindingForProperty(const QString &property, bool hasProperty) +{ + if (d->hasBindingForProperty.value(property) != hasProperty) { + d->hasBindingForProperty.insert(property, hasProperty); + return HasBindingForProperty; + } + + return NoInformationChange; +} + +InformationName NodeInstance::setInformation(InformationName name, const QVariant &information, const QVariant &secondInformation, const QVariant &thirdInformation) { switch (name) { - case Size: d->size = information.toSizeF(); break; - case BoundingRect: d->boundingRect = information.toRectF(); break; - case Transform: d->transform = information.value<QTransform>(); break; - case PenWidth: d->penWidth = information.toInt(); break; - case Position: d->position = information.toPointF(); break; - case IsInPositioner: d->isInPositioner = information.toBool(); break; - case SceneTransform: d->sceneTransform = information.value<QTransform>(); break; - case IsResizable: d->isResizable = information.toBool(); break; - case IsMovable: d->isMovable = information.toBool(); break; - case IsAnchoredByChildren: d->isAnchoredByChildren = information.toBool(); break; - case IsAnchoredBySibling: d->isAnchoredBySibling = information.toBool(); break; - case HasContent: d->hasContent = information.toBool(); break; - case HasAnchor: d->hasAnchors.insert(information.toString(), secondInformation.toBool());break; - case Anchor: d->anchors.insert(information.toString(), qMakePair(secondInformation.toString(), thirdInformation.value<qint32>())); break; - case InstanceTypeForProperty: d->instanceTypes.insert(information.toString(), secondInformation.toString()); break; - case HasBindingForProperty: d->hasBindingForProperty.insert(information.toString(), secondInformation.toBool()); break; + case Size: return setInformationSize(information.toSizeF()); break; + case BoundingRect: return setInformationBoundingRect(information.toRectF()); break; + case Transform: return setInformationTransform(information.value<QTransform>()); break; + case PenWidth: return setInformationPenWith(information.toInt()); break; + case Position: return setInformationPosition(information.toPointF()); break; + case IsInPositioner: return setInformationIsInPositioner(information.toBool()); break; + case SceneTransform: return setInformationSceneTransform(information.value<QTransform>()); break; + case IsResizable: return setInformationIsResizable(information.toBool()); break; + case IsMovable: return setInformationIsMovable(information.toBool()); break; + case IsAnchoredByChildren: return setInformationIsAnchoredByChildren(information.toBool()); break; + case IsAnchoredBySibling: return setInformationIsAnchoredBySibling(information.toBool()); break; + case HasContent: return setInformationHasContent(information.toBool()); break; + case HasAnchor: return setInformationHasAnchor(information.toString(), secondInformation.toBool());break; + case Anchor: return setInformationAnchor(information.toString(), secondInformation.toString(), thirdInformation.value<qint32>()); break; + case InstanceTypeForProperty: return setInformationInstanceTypeForProperty(information.toString(), secondInformation.toString()); break; + case HasBindingForProperty: return setInformationHasBindingForProperty(information.toString(), secondInformation.toBool()); break; case NoName: default: break; } + + return NoInformationChange; } bool operator ==(const NodeInstance &first, const NodeInstance &second) diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp index 8417c3689111d4cb690024cbf54eef51cd4bdfe9..75967a6eb499e1f26486a0960324d307390690e6 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp @@ -42,6 +42,7 @@ #include <QGraphicsScene> #include <QGraphicsObject> #include <QFileSystemWatcher> +#include <QMultiHash> #include <model.h> #include <modelnode.h> @@ -462,7 +463,7 @@ void NodeInstanceView::importsChanged(const QList<Import> &/*addedImports*/, con restartProcess(); } -void NodeInstanceView::instanceInformationsChange(const QVector<ModelNode> &/*nodeList*/) +void NodeInstanceView::instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &/*informationChangeHash*/) { } @@ -1062,21 +1063,21 @@ void NodeInstanceView::informationChanged(const InformationChangedCommand &comma if (!model()) return; - QVector<ModelNode> informationChangedVector; + QMultiHash<ModelNode, InformationName> informationChangeHash; foreach(const InformationContainer &container, command.informations()) { if (hasInstanceForId(container.instanceId())) { NodeInstance instance = instanceForId(container.instanceId()); if (instance.isValid()) { - instance.setInformation(container.name(), container.information(), container.secondInformation(), container.thirdInformation()); - if (!informationChangedVector.contains(instance.modelNode())) - informationChangedVector.append(instance.modelNode()); + InformationName informationChange = instance.setInformation(container.name(), container.information(), container.secondInformation(), container.thirdInformation()); + if (informationChange != NoInformationChange) + informationChangeHash.insert(instance.modelNode(), informationChange); } } } - if (!informationChangedVector.isEmpty()) - emitInstanceInformationsChange(informationChangedVector); + if (!informationChangeHash.isEmpty()) + emitInstanceInformationsChange(informationChangeHash); } QImage NodeInstanceView::statePreviewImage(const ModelNode &stateNode) const diff --git a/src/plugins/qmldesigner/designercore/model/abstractview.cpp b/src/plugins/qmldesigner/designercore/model/abstractview.cpp index 6611e1f32bdea955813ab3b27090ed69e191fe2d..4117986b1ea65eaf366d54b9a6ee4e7c68c2be31 100644 --- a/src/plugins/qmldesigner/designercore/model/abstractview.cpp +++ b/src/plugins/qmldesigner/designercore/model/abstractview.cpp @@ -399,10 +399,10 @@ void AbstractView::emitInstancesCompleted(const QVector<ModelNode> &nodeVector) model()->m_d->notifyInstancesCompleted(nodeVector); } -void AbstractView::emitInstanceInformationsChange(const QVector<ModelNode> &nodeVector) +void AbstractView::emitInstanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash) { if (model() && nodeInstanceView() == this) - model()->m_d->notifyInstancesInformationsChange(nodeVector); + model()->m_d->notifyInstancesInformationsChange(informationChangeHash); } void AbstractView::emitInstancesRenderImageChanged(const QVector<ModelNode> &nodeVector) diff --git a/src/plugins/qmldesigner/designercore/model/model.cpp b/src/plugins/qmldesigner/designercore/model/model.cpp index 0f75621b69a918c21619987365b134494617344b..18404c3054b9b48078bcbeb8d49ebc3b8e20bc35 100644 --- a/src/plugins/qmldesigner/designercore/model/model.cpp +++ b/src/plugins/qmldesigner/designercore/model/model.cpp @@ -45,6 +45,7 @@ #include <QtXml/QXmlStreamReader> #include <QtCore/QDebug> #include <QPlainTextEdit> +#include <QHashIterator> #include "abstractview.h" #include "nodeinstanceview.h" @@ -472,16 +473,27 @@ void ModelPrivate::notifyInstancesCompleted(const QVector<ModelNode> &nodeVector } } -void ModelPrivate::notifyInstancesInformationsChange(const QVector<ModelNode> &nodeVector) +QMultiHash<ModelNode, InformationName> convertModelNodeInformationHash(const QMultiHash<ModelNode, InformationName> &informationChangeHash, AbstractView *view) +{ + QMultiHash<ModelNode, InformationName> convertedModelNodeInformationHash; + + QHashIterator<ModelNode, InformationName> hashIterator(informationChangeHash); + while (hashIterator.hasNext()) { + hashIterator.next(); + convertedModelNodeInformationHash.insert(ModelNode(hashIterator.key(), view), hashIterator.value()); + } + + return convertedModelNodeInformationHash; +} + +void ModelPrivate::notifyInstancesInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash) { bool resetModel = false; QString description; - QVector<Internal::InternalNode::Pointer> internalVector(toInternalNodeVector(nodeVector)); - try { if (rewriterView()) - rewriterView()->instanceInformationsChange(toModelNodeVector(internalVector, rewriterView())); + rewriterView()->instanceInformationsChange(convertModelNodeInformationHash(informationChangeHash, rewriterView())); } catch (RewritingException &e) { description = e.description(); resetModel = true; @@ -489,11 +501,11 @@ void ModelPrivate::notifyInstancesInformationsChange(const QVector<ModelNode> &n foreach (const QWeakPointer<AbstractView> &view, m_viewList) { Q_ASSERT(view != 0); - view->instanceInformationsChange(toModelNodeVector(internalVector, view.data())); + view->instanceInformationsChange(convertModelNodeInformationHash(informationChangeHash, view.data())); } if (nodeInstanceView()) { - nodeInstanceView()->instanceInformationsChange(toModelNodeVector(internalVector, nodeInstanceView())); + nodeInstanceView()->instanceInformationsChange(convertModelNodeInformationHash(informationChangeHash, nodeInstanceView())); } if (resetModel) { diff --git a/src/plugins/qmldesigner/designercore/model/model_p.h b/src/plugins/qmldesigner/designercore/model/model_p.h index 23a626a45ceeab937687ceb4bddad2e5b3785bb9..c806b1b82ae7e27f7117c1488bbce33333ae1fa2 100644 --- a/src/plugins/qmldesigner/designercore/model/model_p.h +++ b/src/plugins/qmldesigner/designercore/model/model_p.h @@ -152,7 +152,7 @@ public: void notifyCustomNotification(const AbstractView *senderView, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data); void notifyInstancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList); void notifyInstancesCompleted(const QVector<ModelNode> &nodeList); - void notifyInstancesInformationsChange(const QVector<ModelNode> &nodeList); + void notifyInstancesInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash); void notifyInstancesRenderImageChanged(const QVector<ModelNode> &nodeList); void notifyInstancesPreviewImageChanged(const QVector<ModelNode> &nodeList); void notifyInstancesChildrenChanged(const QVector<ModelNode> &nodeList); diff --git a/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp b/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp index 4252b8f98baccf5ded6e1ea5eb71d4788a14b041..682a6e2d4ae5429dc283cd8b66cf22d66df121f6 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp @@ -389,7 +389,7 @@ void QmlModelView::instancesCompleted(const QVector<ModelNode> &/*completedNodeL { } -void QmlModelView::instanceInformationsChange(const QVector<ModelNode> &/*nodeList*/) +void QmlModelView::instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &/*informationChangeHash*/) { } diff --git a/src/plugins/qmldesigner/designercore/model/rewriterview.cpp b/src/plugins/qmldesigner/designercore/model/rewriterview.cpp index db6fb1ec0cd7437ddd33e040e40b43f45d094072..e586bbe007f8290d65c6ccadaca505aae6a41e7b 100644 --- a/src/plugins/qmldesigner/designercore/model/rewriterview.cpp +++ b/src/plugins/qmldesigner/designercore/model/rewriterview.cpp @@ -387,7 +387,7 @@ void RewriterView::instancesCompleted(const QVector<ModelNode> &/*completedNodeL { } -void RewriterView::instanceInformationsChange(const QVector<ModelNode> &/*nodeList*/) +void RewriterView::instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash) { } diff --git a/src/plugins/qmldesigner/designercore/model/viewlogger.cpp b/src/plugins/qmldesigner/designercore/model/viewlogger.cpp index ffbcc334f94cde0c39f6bc64fb077b1b9d6bf4c3..b49a2358a9520f9f495224534e8ed3696815b146 100644 --- a/src/plugins/qmldesigner/designercore/model/viewlogger.cpp +++ b/src/plugins/qmldesigner/designercore/model/viewlogger.cpp @@ -224,12 +224,16 @@ void ViewLogger::instancesCompleted(const QVector<ModelNode> &completedNodeList) } -void ViewLogger::instanceInformationsChange(const QVector<ModelNode> &nodeList) +void ViewLogger::instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash) { m_output << time() << indent("instanceInformationsChange:") << endl; - foreach(const ModelNode &node, nodeList) - m_output << time() << indent("node: ") << node << endl; + QHashIterator<ModelNode, InformationName> informationChangeHashIterator(informationChangeHash); + + while (informationChangeHashIterator.hasNext()) { + informationChangeHashIterator.next(); + m_output << time() << indent("node: ") << informationChangeHashIterator.key() << "\tinformation: " << informationChangeHashIterator.value() << endl; + } } void ViewLogger::instancesRenderImageChanged(const QVector<ModelNode> &nodeList) diff --git a/src/plugins/qmldesigner/designercore/model/viewlogger.h b/src/plugins/qmldesigner/designercore/model/viewlogger.h index cd503ea8d5bc6456823d62ce16ccedf2cb8a4ab7..01fc89ca25e80614e95c0c04ffd9a756897eac4a 100644 --- a/src/plugins/qmldesigner/designercore/model/viewlogger.h +++ b/src/plugins/qmldesigner/designercore/model/viewlogger.h @@ -77,7 +77,7 @@ public: void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList); void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList); void instancesCompleted(const QVector<ModelNode> &completedNodeList); - void instanceInformationsChange(const QVector<ModelNode> &nodeList); + void instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash); void instancesRenderImageChanged(const QVector<ModelNode> &nodeList); void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList); void instancesChildrenChanged(const QVector<ModelNode> &nodeList);