QmlDesigner: Fix issues with Components and Repeaters

- Fixed state preview rendering by deparenting nodes under
  component wraps.
- Ensure state preview image is always clipped to root item.
  The state preview bounding box broke when Repeater was direct
  child of root and had delegate with rotation.
- Allow dragging items under Repeater to create implicit component.
- Allow dragging Components under Repeater.
- Do not ask for target property when Component is dragged under
  any node.
- Update nodeSource properly when reparenting implicit component
  or removing last child of a Component item.
- Fixed scene update when last child of a repeater is deleted/moved.

Fixes: QDS-5197
Change-Id: Iaaf1745e25db3522ffc1dba7fd1b051da29f5aec
Reviewed-by: Samuel Ghinet <samuel.ghinet@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Miikka Heikkinen
2021-10-01 12:27:04 +03:00
parent 4036c20f63
commit 2ab6f800b3
11 changed files with 124 additions and 28 deletions

View File

@@ -415,6 +415,16 @@ bool ObjectNodeInstance::isLockedInEditor() const
return m_isLockedInEditor;
}
bool ObjectNodeInstance::isComponentWrap() const
{
return m_isComponentWrap;
}
void ObjectNodeInstance::setComponentWrap(bool wrap)
{
m_isComponentWrap = wrap;
}
void ObjectNodeInstance::setModifiedFlag(bool b)
{
m_isModified = b;
@@ -732,6 +742,10 @@ QObject *ObjectNodeInstance::createComponentWrap(const QString &nodeSource, cons
QQmlComponent *component = new QQmlComponent(context->engine());
QByteArray data(nodeSource.toUtf8());
if (data.isEmpty()) {
// Add a fake root element as an empty component is not valid and crashes in some cases
data.append("QtObject{}");
}
data.prepend(importCode);
component->setData(data, context->baseUrl().resolved(QUrl("createComponent.qml")));
QObject *object = component;