QmlDesigner: Fix shift modifer in layout case

The move tool normally does not reparent, but by pressing shift the user
can enforce reparenting. In the drag tool we prefer to reparent to layouts.
The shoft modifer disables this heuristic.


Task-number: QTCREATORBUG-18737
Change-Id: Ic8041aed537619b16b892a791c0d2bc2390af204
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2017-08-17 14:08:39 +02:00
committed by Tim Jenssen
parent 360609eb7a
commit 91cda49d7c
3 changed files with 10 additions and 4 deletions

View File

@@ -332,7 +332,7 @@ void MoveManipulator::clear()
m_beginVerticalCenterHash.clear(); m_beginVerticalCenterHash.clear();
} }
void MoveManipulator::reparentTo(FormEditorItem *newParent) void MoveManipulator::reparentTo(FormEditorItem *newParent, ReparentFlag flag)
{ {
deleteSnapLines(); deleteSnapLines();
@@ -348,7 +348,8 @@ void MoveManipulator::reparentTo(FormEditorItem *newParent)
&& newParent->qmlItemNode().modelNode().hasParentProperty()) { && newParent->qmlItemNode().modelNode().hasParentProperty()) {
ModelNode grandParent = newParent->qmlItemNode().modelNode().parentProperty().parentModelNode(); ModelNode grandParent = newParent->qmlItemNode().modelNode().parentProperty().parentModelNode();
if (grandParent.metaInfo().isLayoutable() if (grandParent.metaInfo().isLayoutable()
&& !NodeHints::fromModelNode(grandParent).isStackedContainer()) && !NodeHints::fromModelNode(grandParent).isStackedContainer()
&& flag == DoNotEnforceReparent)
newParent = m_view.data()->scene()->itemForQmlItemNode(QmlItemNode(grandParent)); newParent = m_view.data()->scene()->itemForQmlItemNode(QmlItemNode(grandParent));
} }

View File

@@ -48,6 +48,11 @@ public:
UseBaseState UseBaseState
}; };
enum ReparentFlag {
DoNotEnforceReparent,
EnforceReparent
};
MoveManipulator(LayerItem *layerItem, FormEditorView *view); MoveManipulator(LayerItem *layerItem, FormEditorView *view);
~MoveManipulator(); ~MoveManipulator();
void setItems(const QList<FormEditorItem*> &itemList); void setItems(const QList<FormEditorItem*> &itemList);
@@ -57,7 +62,7 @@ public:
void begin(const QPointF& beginPoint); void begin(const QPointF& beginPoint);
void update(const QPointF& updatePoint, Snapper::Snapping useSnapping, State stateToBeManipulated = UseCurrentState); void update(const QPointF& updatePoint, Snapper::Snapping useSnapping, State stateToBeManipulated = UseCurrentState);
void reparentTo(FormEditorItem *newParent); void reparentTo(FormEditorItem *newParent, ReparentFlag flag = DoNotEnforceReparent);
void end(); void end();
void end(Snapper::Snapping useSnapping); void end(Snapper::Snapping useSnapping);

View File

@@ -113,7 +113,7 @@ void MoveTool::mouseMoveEvent(const QList<QGraphicsItem*> &itemList,
if (m_movingItems.count() > 1 if (m_movingItems.count() > 1
|| (movingItem->qmlItemNode().canBereparentedTo(containerItem->qmlItemNode()))) || (movingItem->qmlItemNode().canBereparentedTo(containerItem->qmlItemNode())))
m_moveManipulator.reparentTo(containerItem); m_moveManipulator.reparentTo(containerItem, MoveManipulator::EnforceReparent);
} }
} }