forked from qt-creator/qt-creator
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:
committed by
Tim Jenssen
parent
ab7e7417d1
commit
61f3bb8cfe
@@ -96,9 +96,17 @@ void DragTool::createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry,
|
|||||||
MetaInfo metaInfo = MetaInfo::global();
|
MetaInfo metaInfo = MetaInfo::global();
|
||||||
|
|
||||||
FormEditorItem *parentItem = scene()->itemForQmlItemNode(parentNode);
|
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;
|
QList<QmlItemNode> nodeList;
|
||||||
nodeList.append(m_dragNode);
|
nodeList.append(m_dragNode);
|
||||||
@@ -223,8 +231,9 @@ void DragTool::dropEvent(const QList<QGraphicsItem *> &/*itemList*/, QGraphicsSc
|
|||||||
end(generateUseSnapping(event->modifiers()));
|
end(generateUseSnapping(event->modifiers()));
|
||||||
|
|
||||||
if (m_dragNode.isValid()) {
|
if (m_dragNode.isValid()) {
|
||||||
if (m_dragNode.instanceParentItem().isValid()
|
if ((m_dragNode.instanceParentItem().isValid()
|
||||||
&& m_dragNode.instanceParent().modelNode().metaInfo().isLayoutable()) {
|
&& m_dragNode.instanceParent().modelNode().metaInfo().isLayoutable())
|
||||||
|
|| m_dragNode.isFlowItem()) {
|
||||||
m_dragNode.removeProperty("x");
|
m_dragNode.removeProperty("x");
|
||||||
m_dragNode.removeProperty("y");
|
m_dragNode.removeProperty("y");
|
||||||
view()->resetPuppet(); //Otherwise the layout might not reposition the item
|
view()->resetPuppet(); //Otherwise the layout might not reposition the item
|
||||||
|
|||||||
Reference in New Issue
Block a user