aboutsummaryrefslogtreecommitdiffstats
path: root/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2021-10-08 13:59:02 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2021-10-11 08:44:13 +0000
commit9b6f60992cadf3835a9e6d752cfe860bf0da85bc (patch)
tree653d9a40ef8413d4df85f3bb4aaeb483f8710b00 /share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp
parent3395cdfd2668a4a3b9551bc16807c17e9caf1388 (diff)
QmlDesigner: Update repeater parent when repeater properties change
Any time repeater properties change, the repeater parent should be dirtied to ensure it rerenders. Often the rerender is triggered incidentally due to other triggers, but e.g. in case model value is changed to zero, or if model property is removed, no other trigger causes rerender. Also moved the repeater parent checks into QuickItemNodeInstance to avoid polluting Qt5NodeInstanceServer with such stuff. Fixes: QDS-5233 Change-Id: Idd89e23c5ad022d26f443d665dac81dc2cbb0b28 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp')
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp
index 34693cc0bc..403ba9fbe9 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp
@@ -767,6 +767,8 @@ void QuickItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParen
setMovable(true);
}
+ markRepeaterParentDirty();
+
ObjectNodeInstance::reparent(oldParentInstance, oldParentProperty, newParentInstance, newParentProperty);
if (!newParentInstance)
@@ -831,6 +833,8 @@ void QuickItemNodeInstance::setPropertyVariant(const PropertyName &name, const Q
if (name == "layer.enabled" || name == "layer.effect")
setAllNodesDirtyRecursive(quickItem());
+ markRepeaterParentDirty();
+
ObjectNodeInstance::setPropertyVariant(name, value);
refresh();
@@ -850,6 +854,8 @@ void QuickItemNodeInstance::setPropertyBinding(const PropertyName &name, const Q
if (name.startsWith("anchors.") && isRootNodeInstance())
return;
+ markRepeaterParentDirty();
+
ObjectNodeInstance::setPropertyBinding(name, expression);
refresh();
@@ -927,6 +933,8 @@ void QuickItemNodeInstance::resetProperty(const PropertyName &name)
resetVertical();
}
+ markRepeaterParentDirty();
+
ObjectNodeInstance::resetProperty(name);
if (isInLayoutable())
@@ -1003,6 +1011,35 @@ QQuickItem *QuickItemNodeInstance::quickItem() const
return static_cast<QQuickItem*>(object());
}
+void QuickItemNodeInstance::markRepeaterParentDirty() const
+{
+ const qint32 id = instanceId();
+ if (id <= 0 && !isValid())
+ return;
+
+ QQuickItem *item = quickItem();
+ if (!item)
+ return;
+
+ QQuickItem *parentItem = item->parentItem();
+ if (!parentItem)
+ return;
+
+ // If a Repeater instance was changed in any way, the parent must be marked dirty to rerender it
+ const QByteArray type("QQuickRepeater");
+ if (ServerNodeInstance::isSubclassOf(item, type))
+ DesignerSupport::addDirty(parentItem, QQuickDesignerSupport::Content);
+
+ // Repeater's parent must also be dirtied when a child of a repeater was changed
+ if (ServerNodeInstance::isSubclassOf(parentItem, type)) {
+ QQuickItem *parentsParent = parentItem->parentItem();
+ if (parentsParent)
+ DesignerSupport::addDirty(parentsParent, QQuickDesignerSupport::Content);
+ }
+}
+
+
+
} // namespace Internal
} // namespace QmlDesigner