From 2d4b5fcb65b83e404516f82c53d55a1dd5f05173 Mon Sep 17 00:00:00 2001 From: Marco Bubke <marco.bubke@nokia.com> Date: Tue, 28 Jun 2011 13:41:52 +0200 Subject: [PATCH] QmlDesigner: Fix slowness for many items The information change notifier provided no hint which infotmation changed. So the property editor has updated the anchors for all information changes. Now there is a hint and the update is only happen for a anchor change. Change-Id: I3b6d7546f43bce4c08757662e7af32604a8db56f Reviewed-on: http://codereview.qt.nokia.com/811 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com> --- .../qml/qmlpuppet/interfaces/commondefines.h | 2 + .../components/formeditor/formeditorview.cpp | 4 +- .../components/formeditor/formeditorview.h | 2 +- .../components/integration/componentview.cpp | 2 +- .../components/integration/componentview.h | 2 +- .../designdocumentcontrollerview.cpp | 2 +- .../designdocumentcontrollerview.h | 2 +- .../itemlibrary/itemlibraryview.cpp | 2 +- .../components/itemlibrary/itemlibraryview.h | 2 +- .../components/navigator/navigatorview.cpp | 2 +- .../components/navigator/navigatorview.h | 2 +- .../propertyeditor/propertyeditor.cpp | 5 +- .../propertyeditor/propertyeditor.h | 2 +- .../designercore/include/abstractview.h | 5 +- .../designercore/include/nodeinstance.h | 19 +- .../designercore/include/nodeinstanceview.h | 2 +- .../designercore/include/qmlmodelview.h | 2 +- .../designercore/include/rewriterview.h | 2 +- .../designercore/instances/nodeinstance.cpp | 197 ++++++++++++++++-- .../instances/nodeinstanceview.cpp | 15 +- .../designercore/model/abstractview.cpp | 4 +- .../qmldesigner/designercore/model/model.cpp | 24 ++- .../qmldesigner/designercore/model/model_p.h | 2 +- .../designercore/model/qmlmodelview.cpp | 2 +- .../designercore/model/rewriterview.cpp | 2 +- .../designercore/model/viewlogger.cpp | 10 +- .../designercore/model/viewlogger.h | 2 +- 27 files changed, 260 insertions(+), 59 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h b/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h index 1983c4eebcf..fb2ece65220 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 7e29dfb93e4..aae97ea6e46 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 ade7545d0f8..27fbc9df82c 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 f54cbf34423..a2d818d4dd2 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 190f6131abe..fef34556b51 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 41292833551..ead2ab44a1d 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 4cb1f9d1f08..a915eeb4cd9 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 3271a7d149e..611257b27f0 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 e316de2c61e..3c61139efe3 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 54609ff6abc..37f0d8d3edc 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 3f1fbd05b4b..dc05ac2bb45 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 8d5e2a8a227..d494e908780 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 42b1d71858c..d626b212463 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 ca48ad3773a..88fc9204c9c 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 dff3856d45c..cb630b4fac0 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 0bbfa742259..1cc469b4110 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 67336ed684c..4b72f12481b 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 b8cb4cd204f..2f3bf35e5c7 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 59c66c25957..cdbb363a9ed 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 8417c368911..75967a6eb49 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 6611e1f32bd..4117986b1ea 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 0f75621b69a..18404c3054b 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 23a626a45ce..c806b1b82ae 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 4252b8f98ba..682a6e2d4ae 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 db6fb1ec0cd..e586bbe007f 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 ffbcc334f94..b49a2358a95 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 cd503ea8d5b..01fc89ca25e 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); -- GitLab