diff options
author | Marco Bubke <marco.bubke@digia.com> | 2013-09-23 14:19:38 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@digia.com> | 2013-09-24 13:00:12 +0200 |
commit | d3d3ae70de7a53c73a5538ccf945faf922347755 (patch) | |
tree | 64fbe0dc79e848c55651f48c172332a6f75303df /src/plugins/qmldesigner/components/formeditor/anchorindicator.cpp | |
parent | 4acee577bd46f6cc5029e7ec189340efc1beea25 (diff) |
QmlDesigner: No anchor indicators for root items
Task-number: QTCREATORBUG-10183
Change-Id: I4be06625a59ece3a99e9ebeb0adf0dbd5eff2c5b
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
Diffstat (limited to 'src/plugins/qmldesigner/components/formeditor/anchorindicator.cpp')
-rw-r--r-- | src/plugins/qmldesigner/components/formeditor/anchorindicator.cpp | 110 |
1 files changed, 57 insertions, 53 deletions
diff --git a/src/plugins/qmldesigner/components/formeditor/anchorindicator.cpp b/src/plugins/qmldesigner/components/formeditor/anchorindicator.cpp index e11f117eaa..91ad8bdf67 100644 --- a/src/plugins/qmldesigner/components/formeditor/anchorindicator.cpp +++ b/src/plugins/qmldesigner/components/formeditor/anchorindicator.cpp @@ -95,75 +95,79 @@ void AnchorIndicator::setItems(const QList<FormEditorItem *> &itemList) if (itemList.count() == 1) { m_formEditorItem = itemList.first(); QmlItemNode sourceQmlItemNode = m_formEditorItem->qmlItemNode(); - QmlAnchors qmlAnchors = sourceQmlItemNode.anchors(); - - if (qmlAnchors.modelHasAnchor(AnchorLine::Top)) { - m_indicatorTopShape = new AnchorIndicatorGraphicsItem(m_layerItem.data()); - m_indicatorTopShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Top), - qmlAnchors.modelAnchor(AnchorLine::Top)); - } - - if (qmlAnchors.modelHasAnchor(AnchorLine::Bottom)) { - m_indicatorBottomShape = new AnchorIndicatorGraphicsItem(m_layerItem.data()); - m_indicatorBottomShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Bottom), - qmlAnchors.modelAnchor(AnchorLine::Bottom)); - } - - if (qmlAnchors.modelHasAnchor(AnchorLine::Left)) { - m_indicatorLeftShape = new AnchorIndicatorGraphicsItem(m_layerItem.data()); - m_indicatorLeftShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Left), - qmlAnchors.modelAnchor(AnchorLine::Left)); - } - - if (qmlAnchors.modelHasAnchor(AnchorLine::Right)) { - m_indicatorRightShape = new AnchorIndicatorGraphicsItem(m_layerItem.data()); - m_indicatorRightShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Right), - qmlAnchors.modelAnchor(AnchorLine::Right)); - } - } -} - -void AnchorIndicator::updateItems(const QList<FormEditorItem *> &itemList) -{ - foreach (FormEditorItem *formEditorItem, itemList) { - if (formEditorItem == m_formEditorItem) { - QmlItemNode sourceQmlItemNode = m_formEditorItem->qmlItemNode(); - QmlAnchors qmlAnchors = formEditorItem->qmlItemNode().anchors(); + if (!sourceQmlItemNode.modelNode().isRootNode()) { + QmlAnchors qmlAnchors = sourceQmlItemNode.anchors(); if (qmlAnchors.modelHasAnchor(AnchorLine::Top)) { - if (m_indicatorTopShape.isNull()) - m_indicatorTopShape = new AnchorIndicatorGraphicsItem(m_layerItem.data()); + m_indicatorTopShape = new AnchorIndicatorGraphicsItem(m_layerItem.data()); m_indicatorTopShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Top), - qmlAnchors.modelAnchor(AnchorLine::Top)); - } else { - delete m_indicatorTopShape; + qmlAnchors.modelAnchor(AnchorLine::Top)); } if (qmlAnchors.modelHasAnchor(AnchorLine::Bottom)) { - if (m_indicatorBottomShape.isNull()) - m_indicatorBottomShape = new AnchorIndicatorGraphicsItem(m_layerItem.data()); + m_indicatorBottomShape = new AnchorIndicatorGraphicsItem(m_layerItem.data()); m_indicatorBottomShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Bottom), - qmlAnchors.modelAnchor(AnchorLine::Bottom)); - } else { - delete m_indicatorBottomShape; + qmlAnchors.modelAnchor(AnchorLine::Bottom)); } if (qmlAnchors.modelHasAnchor(AnchorLine::Left)) { - if (m_indicatorLeftShape.isNull()) - m_indicatorLeftShape = new AnchorIndicatorGraphicsItem(m_layerItem.data()); + m_indicatorLeftShape = new AnchorIndicatorGraphicsItem(m_layerItem.data()); m_indicatorLeftShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Left), - qmlAnchors.modelAnchor(AnchorLine::Left)); - } else { - delete m_indicatorLeftShape; + qmlAnchors.modelAnchor(AnchorLine::Left)); } if (qmlAnchors.modelHasAnchor(AnchorLine::Right)) { - if (m_indicatorRightShape.isNull()) - m_indicatorRightShape = new AnchorIndicatorGraphicsItem(m_layerItem.data()); + m_indicatorRightShape = new AnchorIndicatorGraphicsItem(m_layerItem.data()); m_indicatorRightShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Right), qmlAnchors.modelAnchor(AnchorLine::Right)); - } else { - delete m_indicatorRightShape; + } + } + } +} + +void AnchorIndicator::updateItems(const QList<FormEditorItem *> &itemList) +{ + foreach (FormEditorItem *formEditorItem, itemList) { + if (formEditorItem == m_formEditorItem) { + QmlItemNode sourceQmlItemNode = m_formEditorItem->qmlItemNode(); + if (!sourceQmlItemNode.modelNode().isRootNode()) { + QmlAnchors qmlAnchors = formEditorItem->qmlItemNode().anchors(); + + if (qmlAnchors.modelHasAnchor(AnchorLine::Top)) { + if (m_indicatorTopShape.isNull()) + m_indicatorTopShape = new AnchorIndicatorGraphicsItem(m_layerItem.data()); + m_indicatorTopShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Top), + qmlAnchors.modelAnchor(AnchorLine::Top)); + } else { + delete m_indicatorTopShape; + } + + if (qmlAnchors.modelHasAnchor(AnchorLine::Bottom)) { + if (m_indicatorBottomShape.isNull()) + m_indicatorBottomShape = new AnchorIndicatorGraphicsItem(m_layerItem.data()); + m_indicatorBottomShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Bottom), + qmlAnchors.modelAnchor(AnchorLine::Bottom)); + } else { + delete m_indicatorBottomShape; + } + + if (qmlAnchors.modelHasAnchor(AnchorLine::Left)) { + if (m_indicatorLeftShape.isNull()) + m_indicatorLeftShape = new AnchorIndicatorGraphicsItem(m_layerItem.data()); + m_indicatorLeftShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Left), + qmlAnchors.modelAnchor(AnchorLine::Left)); + } else { + delete m_indicatorLeftShape; + } + + if (qmlAnchors.modelHasAnchor(AnchorLine::Right)) { + if (m_indicatorRightShape.isNull()) + m_indicatorRightShape = new AnchorIndicatorGraphicsItem(m_layerItem.data()); + m_indicatorRightShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Right), + qmlAnchors.modelAnchor(AnchorLine::Right)); + } else { + delete m_indicatorRightShape; + } } return; |