QmlDesigner: Fix DragTool for FlowEditor

In FlowEditor mode postions are stored in the auxiliary data.
This has to be taken into account in the DragTool.

Change-Id: I4d008a9d6eafc6fd731c2a634ded6d9c84355059
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2020-01-29 15:12:55 +01:00
committed by Tim Jenssen
parent ab7e7417d1
commit 61f3bb8cfe

View File

@@ -96,9 +96,17 @@ void DragTool::createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry,
MetaInfo metaInfo = MetaInfo::global();
FormEditorItem *parentItem = scene()->itemForQmlItemNode(parentNode);
QPointF positonInItemSpace = parentItem->qmlItemNode().instanceSceneContentItemTransform().inverted().map(scenePosition);
const QPointF positonInItemSpace = parentItem->qmlItemNode().instanceSceneContentItemTransform().inverted().map(scenePosition);
QPointF itemPos = positonInItemSpace;
m_dragNode = QmlItemNode::createQmlItemNode(view(), itemLibraryEntry, positonInItemSpace, parentNode);
const bool rootIsFlow = QmlItemNode(view()->rootModelNode()).isFlowView();
if (rootIsFlow)
itemPos = QPointF();
m_dragNode = QmlItemNode::createQmlItemNode(view(), itemLibraryEntry, itemPos, parentNode);
m_dragNode.setFlowItemPosition(positonInItemSpace);
QList<QmlItemNode> nodeList;
nodeList.append(m_dragNode);
@@ -223,8 +231,9 @@ void DragTool::dropEvent(const QList<QGraphicsItem *> &/*itemList*/, QGraphicsSc
end(generateUseSnapping(event->modifiers()));
if (m_dragNode.isValid()) {
if (m_dragNode.instanceParentItem().isValid()
&& m_dragNode.instanceParent().modelNode().metaInfo().isLayoutable()) {
if ((m_dragNode.instanceParentItem().isValid()
&& m_dragNode.instanceParent().modelNode().metaInfo().isLayoutable())
|| m_dragNode.isFlowItem()) {
m_dragNode.removeProperty("x");
m_dragNode.removeProperty("y");
view()->resetPuppet(); //Otherwise the layout might not reposition the item