Commit 25a6a811 authored by Marco Bubke's avatar Marco Bubke
Browse files

QmlDesigner: Move containerFormEditorItem in AbstractFormEditorTool



Change-Id: I700ebd16d709eea7b3afb4a3c6089af7d4c87bf6
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent 6bac9341
......@@ -264,6 +264,33 @@ Snapper::Snapping AbstractFormEditorTool::generateUseSnapping(Qt::KeyboardModifi
return useSnapping;
}
static bool isNotAncestorOfItemInList(FormEditorItem *formEditorItem, const QList<FormEditorItem*> &itemList)
{
foreach (FormEditorItem *item, itemList) {
if (item
&& item->qmlItemNode().isValid()
&& item->qmlItemNode().isAncestorOf(formEditorItem->qmlItemNode()))
return false;
}
return true;
}
FormEditorItem *AbstractFormEditorTool::containerFormEditorItem(const QList<QGraphicsItem *> &itemUnderMouseList, const QList<FormEditorItem *> &selectedItemList) const
{
foreach (QGraphicsItem* item, itemUnderMouseList) {
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
if (formEditorItem
&& !selectedItemList.contains(formEditorItem)
&& isNotAncestorOfItemInList(formEditorItem, selectedItemList)
&& formEditorItem->isContainer())
return formEditorItem;
}
return 0;
}
void AbstractFormEditorTool::clear()
{
m_itemList.clear();
......
......@@ -99,6 +99,7 @@ protected:
virtual void selectedItemsChanged(const QList<FormEditorItem*> &itemList) = 0;
virtual void showContextMenu(QGraphicsSceneMouseEvent *event);
Snapper::Snapping generateUseSnapping(Qt::KeyboardModifiers keyboardModifier) const;
FormEditorItem *containerFormEditorItem(const QList<QGraphicsItem*> &itemUnderMouseList, const QList<FormEditorItem*> &selectedItemList) const;
FormEditorView *view() const;
void setView(FormEditorView *view);
......
......@@ -319,35 +319,7 @@ void MoveTool::beginWithPoint(const QPointF &beginPoint)
m_moveManipulator.begin(beginPoint);
}
static bool isNotAncestorOfItemInList(FormEditorItem *formEditorItem, const QList<FormEditorItem*> &itemList)
{
foreach (FormEditorItem *item, itemList) {
if (item
&& item->qmlItemNode().isValid()
&& item->qmlItemNode().isAncestorOf(formEditorItem->qmlItemNode()))
return false;
}
return true;
}
FormEditorItem* MoveTool::containerFormEditorItem(const QList<QGraphicsItem*> &itemUnderMouseList,
const QList<FormEditorItem*> &selectedItemList)
{
Q_ASSERT(!selectedItemList.isEmpty());
foreach (QGraphicsItem* item, itemUnderMouseList) {
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
if (formEditorItem
&& !selectedItemList.contains(formEditorItem)
&& isNotAncestorOfItemInList(formEditorItem, selectedItemList)
&& formEditorItem->isContainer())
return formEditorItem;
}
return 0;
}
QList<FormEditorItem*> movalbeItems(const QList<FormEditorItem*> &itemList)
{
......
......@@ -79,8 +79,6 @@ protected:
static QList<FormEditorItem*> movingItems(const QList<FormEditorItem*> &selectedItemList);
static FormEditorItem* containerFormEditorItem(const QList<QGraphicsItem*> &itemUnderMouseList,
const QList<FormEditorItem*> &selectedItemList);
static bool isAncestorOfAllItems(FormEditorItem* maybeAncestorItem,
const QList<FormEditorItem*> &itemList);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment