diff options
author | Marco Bubke <marco.bubke@nokia.com> | 2012-08-22 15:54:33 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@nokia.com> | 2012-08-22 16:04:36 +0200 |
commit | fc212ce735bfb3a726bd5ecbf80c37cbc536a9bf (patch) | |
tree | c74764e737da2ea50cc1fc5e653e20623a5f832d /src/plugins/qmldesigner/components | |
parent | 6a0e01cbcfc7ae9368f24adb0488b4ed84c76740 (diff) | |
download | qt-creator-fc212ce735bfb3a726bd5ecbf80c37cbc536a9bf.tar.gz |
QmlDesigner.FormEditor: Remove Anchor mode
Change-Id: I03935715e51777efffea533310a9d775cb676dca
Reviewed-by: Alessandro Portale <alessandro.portale@nokia.com>
Diffstat (limited to 'src/plugins/qmldesigner/components')
26 files changed, 13 insertions, 2596 deletions
diff --git a/src/plugins/qmldesigner/components/formeditor/anchor.png b/src/plugins/qmldesigner/components/formeditor/anchor.png Binary files differdeleted file mode 100644 index fa59038318..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchor.png +++ /dev/null diff --git a/src/plugins/qmldesigner/components/formeditor/anchorcontroller.cpp b/src/plugins/qmldesigner/components/formeditor/anchorcontroller.cpp deleted file mode 100644 index d9bc4558d4..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchorcontroller.cpp +++ /dev/null @@ -1,538 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -#include "anchorcontroller.h" - -#include "formeditoritem.h" -#include "layeritem.h" -#include "formeditorscene.h" -#include "anchorhandleitem.h" -#include <QDebug> -#include <cmath> -namespace QmlDesigner { - -AnchorControllerData::AnchorControllerData(LayerItem *layerItem, FormEditorItem *formEditorItem) - : layerItem(layerItem), - formEditorItem(formEditorItem), - topItem(0), - leftItem(0), - rightItem(0), - bottomItem(0) -{ -} - -AnchorControllerData::AnchorControllerData(const AnchorControllerData &other) - : layerItem(other.layerItem), - formEditorItem(other.formEditorItem), - topItem(other.topItem), - leftItem(other.leftItem), - rightItem(other.rightItem), - bottomItem(other.bottomItem) -{ -} - -AnchorControllerData::~AnchorControllerData() -{ - if (layerItem) { - layerItem->scene()->removeItem(topItem); - layerItem->scene()->removeItem(leftItem); - layerItem->scene()->removeItem(rightItem); - layerItem->scene()->removeItem(bottomItem); - } -} - - -AnchorController::AnchorController() - : m_data(new AnchorControllerData(0, 0)) -{ - -} - -AnchorController::AnchorController(const QSharedPointer<AnchorControllerData> &data) - : m_data(data) -{ - -} - -AnchorController::AnchorController(LayerItem *layerItem, FormEditorItem *formEditorItem) - : m_data(new AnchorControllerData(layerItem, formEditorItem)) -{ - m_data->topItem = new AnchorHandleItem(layerItem, *this); - m_data->topItem->setZValue(400); - m_data->topItem->setToolTip(m_data->topItem->toolTipString()); - - m_data->leftItem = new AnchorHandleItem(layerItem, *this); - m_data->leftItem->setZValue(400); - m_data->leftItem->setToolTip(m_data->leftItem->toolTipString()); - - m_data->rightItem = new AnchorHandleItem(layerItem, *this); - m_data->rightItem->setZValue(400); - m_data->rightItem->setToolTip(m_data->rightItem->toolTipString()); - - m_data->bottomItem = new AnchorHandleItem(layerItem, *this); - m_data->bottomItem->setZValue(400); - m_data->bottomItem->setToolTip(m_data->bottomItem->toolTipString()); - - m_data->sceneTransform = formEditorItem->sceneTransform(); - - updatePosition(); -} - - -bool AnchorController::isValid() const -{ - return m_data->formEditorItem != 0; -} - -void AnchorController::show() -{ - m_data->topItem->show(); - m_data->leftItem->show(); - m_data->rightItem->show(); - m_data->bottomItem->show(); -} - - - -void AnchorController::hide() -{ - m_data->topItem->hide(); - m_data->leftItem->hide(); - m_data->rightItem->hide(); - m_data->bottomItem->hide(); -} - - -static QPointF topCenter(const QRectF &rect) -{ - return QPointF(rect.center().x(), rect.top()); -} - -static QPointF leftCenter(const QRectF &rect) -{ - return QPointF(rect.left(), rect.center().y()); -} - -static QPointF rightCenter(const QRectF &rect) -{ - return QPointF(rect.right(), rect.center().y()); -} - -static QPointF bottomCenter(const QRectF &rect) -{ - return QPointF(rect.center().x(), rect.bottom()); -} - -static QPainterPath curveToPath(const QPointF &firstPoint, - const QPointF &secondPoint, - const QPointF &thirdPoint, - const QPointF &fourthPoint) -{ - QPainterPath path; - path.moveTo(firstPoint); - path.cubicTo(secondPoint, thirdPoint, fourthPoint); - - return path; -} - -static QPointF anchorPoint(const QRectF &boundingRect, AnchorLine::Type anchorLine, double baseOffset, double innerOffset = 0.0) -{ - switch(anchorLine) { - case AnchorLine::Top : return topCenter(boundingRect) + QPointF(baseOffset, innerOffset); - case AnchorLine::Bottom : return bottomCenter(boundingRect) - QPointF(baseOffset, innerOffset); - case AnchorLine::Left : return leftCenter(boundingRect) + QPointF(innerOffset, baseOffset); - case AnchorLine::Right : return rightCenter(boundingRect) - QPointF(innerOffset, baseOffset); - default: return QPointF(); - } - - return QPointF(); -} - - -static QPainterPath createArrowPath(QPointF arrowCenter, double arrowDegrees) -{ - QRectF arrowRect(0.0, 0.0, 16., 16.); - arrowRect.moveCenter(arrowCenter); - QPainterPath arrowPath; - - - arrowPath.moveTo(arrowCenter); - - arrowPath.arcTo(arrowRect, arrowDegrees + 180 - 20, 40.); - - return arrowPath; -} - -AnchorHandlePathData AnchorController::createPainterPathForAnchor(const QRectF &boundingRect, - AnchorLine::Type anchorLine, - const QPointF &targetPoint) const -{ - - - QPointF firstPointInLayerSpace(m_data->sceneTransform.map(anchorPoint(boundingRect, anchorLine, 0.0, 5.0))); - - QPointF topLeftBoundingBoxInLayerSpace(m_data->sceneTransform.map(boundingRect.topLeft())); - QPointF bottomLeftBoundingBoxInLayerSpace(m_data->sceneTransform.map(boundingRect.bottomLeft())); - QPointF topRightBoundingBoxInLayerSpace(m_data->sceneTransform.map(boundingRect.topRight())); - QPointF bottomRightBoundingBoxInLayerSpace(m_data->sceneTransform.map(boundingRect.bottomRight())); - - AnchorLine::Type secondAnchorLine(AnchorLine::Invalid); - - QPointF secondPointInLayerSpace(targetPoint); - if (targetPoint.isNull()) { - AnchorLine targetAnchorLine(m_data->formEditorItem->qmlItemNode().anchors().instanceAnchor(anchorLine)); - secondAnchorLine = targetAnchorLine.type(); - FormEditorItem *targetItem = m_data->formEditorItem->scene()->itemForQmlItemNode(targetAnchorLine.qmlItemNode());; - bool secondItemIsParent = m_data->formEditorItem->parentItem() == targetItem; - - if (secondItemIsParent) - secondPointInLayerSpace = (targetItem->mapToItem(m_data->layerItem.data(), - anchorPoint(targetItem->qmlItemNode().instanceBoundingRect(), targetAnchorLine.type(), 0.0))); - else - - secondPointInLayerSpace = (targetItem->mapToItem(m_data->layerItem.data(), - anchorPoint(targetItem->qmlItemNode().instanceBoundingRect(), targetAnchorLine.type(), 0.0))); - } - - QPointF firstControlPointInLayerSpace = (3. * firstPointInLayerSpace + 3 * secondPointInLayerSpace) / 6.; - QPointF secondControlPointInLayerSpace = (3 * firstPointInLayerSpace + 3. * secondPointInLayerSpace) / 6.; - - bool showAnchorLine(true); - switch (anchorLine) { - case AnchorLine::Top : - case AnchorLine::Bottom : - firstControlPointInLayerSpace.rx() = firstPointInLayerSpace.x(); - if (qAbs(secondPointInLayerSpace.y() - firstPointInLayerSpace.y()) < 18.0) - showAnchorLine = false; - if (qAbs(secondControlPointInLayerSpace.y() - secondPointInLayerSpace.y()) < 20.0 && - qAbs(secondControlPointInLayerSpace.x() - secondPointInLayerSpace.x()) > 20.0) { - firstControlPointInLayerSpace.ry() = firstPointInLayerSpace.y() + ((firstControlPointInLayerSpace.y() - firstPointInLayerSpace.y() > 0) ? 20 : -20); - } - break; - case AnchorLine::Left : - case AnchorLine::Right : - firstControlPointInLayerSpace.ry() = firstPointInLayerSpace.y(); - if (qAbs(secondPointInLayerSpace.x() - firstPointInLayerSpace.x()) < 18.0) - showAnchorLine = false; - if (qAbs(secondControlPointInLayerSpace.x() - secondPointInLayerSpace.x()) < 20.0 && - qAbs(secondControlPointInLayerSpace.y() - secondPointInLayerSpace.y()) > 20.0) { - firstControlPointInLayerSpace.rx() = firstPointInLayerSpace.x() + ((firstControlPointInLayerSpace.x() - firstPointInLayerSpace.x() > 0) ? 20 : -20); - } - break; - default: break; - } - - switch(secondAnchorLine) { - case AnchorLine::Top : - case AnchorLine::Bottom : - secondControlPointInLayerSpace.rx() = secondPointInLayerSpace.x(); - if (qAbs(secondControlPointInLayerSpace.y() - secondPointInLayerSpace.y()) < 20.0 && - qAbs(secondControlPointInLayerSpace.x() - secondPointInLayerSpace.x()) > 20.0) { - secondControlPointInLayerSpace.ry() = secondPointInLayerSpace.y() + ((secondControlPointInLayerSpace.y() - secondPointInLayerSpace.y() < 0) ? 20 : -20); - } - break; - case AnchorLine::Left : - case AnchorLine::Right : - secondControlPointInLayerSpace.ry() = secondPointInLayerSpace.y(); - if (qAbs(secondControlPointInLayerSpace.x() - secondPointInLayerSpace.x()) < 20.0 && - qAbs(secondControlPointInLayerSpace.y() - secondPointInLayerSpace.y()) > 20.0) { - secondControlPointInLayerSpace.rx() = secondPointInLayerSpace.x() + ((secondControlPointInLayerSpace.x() - secondPointInLayerSpace.x() < 0) ? 20 : -20); - } - break; - default: break; - } - - QPainterPath anchorLinePath; - anchorLinePath.setFillRule(Qt::WindingFill); - - QRectF baseRect(0.0, 0.0, 5., 5.); - baseRect.moveCenter(firstPointInLayerSpace); - QPainterPath basePath; - basePath.addRoundedRect(baseRect, 6., 6.); - anchorLinePath = anchorLinePath.united(basePath); - - QRectF baseLineRect; - switch (anchorLine) { - case AnchorLine::Left : { - baseLineRect = QRectF(topLeftBoundingBoxInLayerSpace, bottomLeftBoundingBoxInLayerSpace); - baseLineRect.setWidth(3); - } - break; - case AnchorLine::Top : { - baseLineRect = QRectF(topLeftBoundingBoxInLayerSpace, topRightBoundingBoxInLayerSpace); - baseLineRect.setHeight(3); - } - break; - case AnchorLine::Right : { - baseLineRect = QRectF(topRightBoundingBoxInLayerSpace, bottomRightBoundingBoxInLayerSpace); - baseLineRect.adjust(-3, 0, 0, 0); - } - break; - case AnchorLine::Bottom : { - baseLineRect = QRectF(bottomLeftBoundingBoxInLayerSpace, bottomRightBoundingBoxInLayerSpace); - baseLineRect.adjust(0, -3, 0, 0); - } - break; - default: break; - } - - if (!baseLineRect.isEmpty()) { - - QPainterPath baseLinePath; - baseLinePath.addRoundedRect(baseLineRect, 1., 1.); - anchorLinePath = anchorLinePath.united(baseLinePath); - } - - QPainterPath arrowPath; - arrowPath.setFillRule(Qt::WindingFill); - - - - if (showAnchorLine) { - QPainterPath curvePath(curveToPath(firstPointInLayerSpace, - firstControlPointInLayerSpace, - secondControlPointInLayerSpace, - secondPointInLayerSpace)); - - double arrowDegrees = curvePath.angleAtPercent(curvePath.percentAtLength(curvePath.length() - 2.5)); - - - - QPainterPathStroker arrowPathStroker; - arrowPathStroker.setWidth(2.0); - arrowPathStroker.setCapStyle(Qt::RoundCap); - - arrowPath = arrowPath.united(arrowPathStroker.createStroke(curvePath)); - - - - - - QRectF arrowCutRect(0.0, 0.0, 8., 8.); - arrowCutRect.moveCenter(secondPointInLayerSpace); - QPainterPath arrowCutPath; - arrowCutPath.addRect(arrowCutRect); - arrowPath = arrowPath.subtracted(arrowCutPath); - - arrowPath = arrowPath.united(createArrowPath(secondPointInLayerSpace, arrowDegrees)); - } - - AnchorHandlePathData pathData; - pathData.arrowPath = arrowPath; - pathData.sourceAnchorLinePath = anchorLinePath; - pathData.beginArrowPoint = firstPointInLayerSpace; - pathData.endArrowPoint = secondPointInLayerSpace; - - pathData.targetAnchorLinePath = createTargetAnchorLinePath(anchorLine); - pathData.targetNamePath = createTargetNamePathPath(anchorLine); - - return pathData; -} - -QPainterPath AnchorController::createTargetNamePathPath(AnchorLine::Type anchorLine) const -{ - QPainterPath path; - QmlAnchors anchors(formEditorItem()->qmlItemNode().anchors()); - if (anchors.instanceHasAnchor(anchorLine)) { - AnchorLine targetAnchorLine(anchors.instanceAnchor(anchorLine)); - - FormEditorItem *targetItem = formEditorItem()->scene()->itemForQmlItemNode(targetAnchorLine.qmlItemNode()); - QRectF boundingRect(targetItem->qmlItemNode().instanceBoundingRect()); - - QTransform sceneTransform(targetItem->qmlItemNode().instanceSceneTransform()); - - QPointF centerBoundingBoxInLayerSpace(sceneTransform.map(boundingRect.center())); - - QFont font; - font.setPixelSize(24); - QString nameString(QString("%1 (%2)").arg(targetAnchorLine.qmlItemNode().simplifiedTypeName()).arg(targetAnchorLine.qmlItemNode().id())); - path.addText(0., -4., font, nameString); - //path.translate(centerBoundingBoxInLayerSpace - path.qmlItemNode().instanceBoundingRect().center()); - - } - - return path; -} - -QPainterPath AnchorController::createTargetAnchorLinePath(AnchorLine::Type anchorLine) const -{ - QPainterPath path; - QmlAnchors anchors(formEditorItem()->qmlItemNode().anchors()); - if (anchors.instanceHasAnchor(anchorLine)) { - AnchorLine targetAnchorLine(anchors.instanceAnchor(anchorLine)); - - FormEditorItem *targetItem = formEditorItem()->scene()->itemForQmlItemNode(targetAnchorLine.qmlItemNode()); - QRectF boundingRect(targetItem->qmlItemNode().instanceBoundingRect()); - - QTransform sceneTransform(targetItem->qmlItemNode().instanceSceneTransform()); - - QPointF topLeftBoundingBoxInLayerSpace(sceneTransform.map(boundingRect.topLeft())); - QPointF bottomLeftBoundingBoxInLayerSpace(sceneTransform.map(boundingRect.bottomLeft())); - QPointF topRightBoundingBoxInLayerSpace(sceneTransform.map(boundingRect.topRight())); - QPointF bottomRightBoundingBoxInLayerSpace(sceneTransform.map(boundingRect.bottomRight())); - - - switch(targetAnchorLine.type()) { - case AnchorLine::Top : { - path.moveTo(topLeftBoundingBoxInLayerSpace); - path.lineTo(topRightBoundingBoxInLayerSpace); - } - break; - case AnchorLine::Bottom : { - path.moveTo(bottomLeftBoundingBoxInLayerSpace); - path.lineTo(bottomRightBoundingBoxInLayerSpace); - } - break; - case AnchorLine::Left : { - path.moveTo(topLeftBoundingBoxInLayerSpace); - path.lineTo(bottomLeftBoundingBoxInLayerSpace); - } - break; - case AnchorLine::Right : { - path.moveTo(topRightBoundingBoxInLayerSpace); - path.lineTo(bottomRightBoundingBoxInLayerSpace); - } - break; - default: break; - } - - QPainterPathStroker pathStroker; - pathStroker.setWidth(20.0); - pathStroker.setCapStyle(Qt::RoundCap); - path = pathStroker.createStroke(path); - - - } - - return path; -} - -void AnchorController::updatePosition() -{ - QRectF boundingRect = m_data->formEditorItem->qmlItemNode().instanceBoundingRect(); - QPointF beginPoint; - QPointF endPoint; - QmlAnchors anchors(m_data->formEditorItem->qmlItemNode().anchors()); - m_data->sceneTransform = m_data->formEditorItem->sceneTransform(); - - if (anchors.instanceHasAnchor(AnchorLine::Top)) - m_data->topItem->setHandlePath(createPainterPathForAnchor(boundingRect, AnchorLine::Top)); - else - m_data->topItem->setHandlePath(AnchorHandlePathData()); - - if (anchors.instanceHasAnchor(AnchorLine::Bottom)) - m_data->bottomItem->setHandlePath(createPainterPathForAnchor(boundingRect, AnchorLine::Bottom)); - else - m_data->bottomItem->setHandlePath(AnchorHandlePathData()); - - if (anchors.instanceHasAnchor(AnchorLine::Right)) - m_data->rightItem->setHandlePath(createPainterPathForAnchor(boundingRect, AnchorLine::Right)); - else - m_data->rightItem->setHandlePath(AnchorHandlePathData()); - - if (anchors.instanceHasAnchor(AnchorLine::Left)) - m_data->leftItem->setHandlePath(createPainterPathForAnchor(boundingRect, AnchorLine::Left)); - else - m_data->leftItem->setHandlePath(AnchorHandlePathData()); -} - - -FormEditorItem* AnchorController::formEditorItem() const -{ - return m_data->formEditorItem; -} - -QWeakPointer<AnchorControllerData> AnchorController::weakPointer() const -{ - return m_data; -} - - -bool AnchorController::isTopHandle(const AnchorHandleItem *handle) const -{ - return handle == m_data->topItem; -} - -bool AnchorController::isLeftHandle(const AnchorHandleItem *handle) const -{ - return handle == m_data->leftItem; -} - -bool AnchorController::isRightHandle(const AnchorHandleItem *handle) const -{ - return handle == m_data->rightItem; -} - -bool AnchorController::isBottomHandle(const AnchorHandleItem *handle) const -{ - return handle == m_data->bottomItem; -} - -void AnchorController::updateTargetPoint(AnchorLine::Type anchorLine, const QPointF &targetPoint) -{ - QRectF boundingRect = m_data->formEditorItem->qmlItemNode().instanceBoundingRect(); - - switch(anchorLine) { - case AnchorLine::Top : - m_data->topItem->setHandlePath(createPainterPathForAnchor(boundingRect, anchorLine, targetPoint)); break; - case AnchorLine::Bottom : - m_data->bottomItem->setHandlePath(createPainterPathForAnchor(boundingRect, anchorLine, targetPoint)); break; - case AnchorLine::Left : - m_data->leftItem->setHandlePath(createPainterPathForAnchor(boundingRect, anchorLine, targetPoint)); break; - case AnchorLine::Right : - m_data->rightItem->setHandlePath(createPainterPathForAnchor(boundingRect, anchorLine, targetPoint)); break; - default: break; - } -} - -void AnchorController::highlight(AnchorLine::Type anchorLine) -{ - switch(anchorLine) { - case AnchorLine::Top : - m_data->topItem->setHighlighted(true); break; - case AnchorLine::Bottom : - m_data->bottomItem->setHighlighted(true); break; - case AnchorLine::Left : - m_data->leftItem->setHighlighted(true); break; - case AnchorLine::Right : - m_data->rightItem->setHighlighted(true); break; - default: break; - } -} - -void AnchorController::clearHighlight() -{ - m_data->topItem->setHighlighted(false); - m_data->leftItem->setHighlighted(false); - m_data->rightItem->setHighlighted(false); - m_data->bottomItem->setHighlighted(false); -} - -} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/formeditor/anchorcontroller.h b/src/plugins/qmldesigner/components/formeditor/anchorcontroller.h deleted file mode 100644 index 45e5b365d5..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchorcontroller.h +++ /dev/null @@ -1,118 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -#ifndef ANCHORCONTROLLER_H -#define ANCHORCONTROLLER_H - -#include <QSharedPointer> -#include <QPainterPath> -#include <QPair> -#include <QTransform> -#include <qmlanchors.h> - -namespace QmlDesigner { - -struct AnchorHandlePathData -{ - QPainterPath sourceAnchorLinePath; - QPainterPath targetAnchorLinePath; - QPainterPath arrowPath; - QPainterPath targetNamePath; - QPointF beginArrowPoint; - QPointF endArrowPoint; -}; - -class FormEditorItem; -class LayerItem; -class AnchorHandleItem; - -class AnchorControllerData -{ -public: - AnchorControllerData(LayerItem *layerItem, - FormEditorItem *formEditorItem); - AnchorControllerData(const AnchorControllerData &other); - ~AnchorControllerData(); - - QWeakPointer<LayerItem> layerItem; - FormEditorItem *formEditorItem; - - AnchorHandleItem *topItem; - AnchorHandleItem *leftItem; - AnchorHandleItem *rightItem; - AnchorHandleItem *bottomItem; - - QTransform sceneTransform; -}; - - -class AnchorController -{ - public: - AnchorController(); - AnchorController(LayerItem *layerItem, FormEditorItem *formEditorItem); - AnchorController(const QSharedPointer<AnchorControllerData> &data); - - - void show(); - void hide(); - - void updatePosition(); - - bool isValid() const; - - QWeakPointer<AnchorControllerData> weakPointer() const; - - - FormEditorItem *formEditorItem() const; - - bool isTopHandle(const AnchorHandleItem *handle) const; - bool isLeftHandle(const AnchorHandleItem *handle) const; - bool isRightHandle(const AnchorHandleItem *handle) const; - bool isBottomHandle(const AnchorHandleItem *handle) const; - - void updateTargetPoint(AnchorLine::Type anchorLine, const QPointF &targetPoint); - - void clearHighlight(); - void highlight(AnchorLine::Type anchorLine); - -private: //functions - AnchorHandlePathData createPainterPathForAnchor(const QRectF &boundingRect, - AnchorLine::Type anchorLine, - const QPointF &targetPoint = QPointF()) const; - QPainterPath createTargetAnchorLinePath(AnchorLine::Type anchorLine) const; - QPainterPath createTargetNamePathPath(AnchorLine::Type anchorLine) const; -private: - QSharedPointer<AnchorControllerData> m_data; -}; - -} // namespace QmlDesigner - -#endif // ANCHORCONTROLLER_H diff --git a/src/plugins/qmldesigner/components/formeditor/anchorhandleitem.cpp b/src/plugins/qmldesigner/components/formeditor/anchorhandleitem.cpp deleted file mode 100644 index ad3c8a4ab8..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchorhandleitem.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -#include "anchorhandleitem.h" - -#include <formeditoritem.h> -#include <QPen> -#include <QPainterPathStroker> -#include <cmath> -#include <QDebug> - -namespace QmlDesigner { - -AnchorHandleItem::AnchorHandleItem(QGraphicsItem *parent, const AnchorController &anchorController) - : QGraphicsItemGroup(parent), - m_anchorControllerData(anchorController.weakPointer()), - m_sourceAnchorLinePathItem(new QGraphicsPathItem(this)), - m_arrowPathItem(new QGraphicsPathItem(this)), - m_targetAnchorLinePathItem(new QGraphicsPathItem(this)), - m_targetNamePathItem(new QGraphicsPathItem(this)) -{ - addToGroup(m_sourceAnchorLinePathItem); - addToGroup(m_arrowPathItem); - addToGroup(m_targetAnchorLinePathItem); - addToGroup(m_targetNamePathItem); - - setFlag(QGraphicsItem::ItemIsMovable, true); -} - -AnchorLine::Type AnchorHandleItem::sourceAnchorLine() const -{ - if (isTopHandle()) - return AnchorLine::Top; - if (isBottomHandle()) - return AnchorLine::Bottom; - if (isLeftHandle()) - return AnchorLine::Left; - if (isRightHandle()) - return AnchorLine::Right; - - return AnchorLine::Invalid; -} - -AnchorLine AnchorHandleItem::targetAnchorLine() const -{ - QmlAnchors anchors(anchorController().formEditorItem()->qmlItemNode().anchors()); - - if (isTopHandle()) - return anchors.instanceAnchor(AnchorLine::Top); - if (isBottomHandle()) - return anchors.instanceAnchor(AnchorLine::Bottom); - if (isLeftHandle()) - return anchors.instanceAnchor(AnchorLine::Left); - if (isRightHandle()) - return anchors.instanceAnchor(AnchorLine::Right); - - return AnchorLine(); -} - -static QString anchorLineToString(AnchorLine::Type anchorLineType) -{ - switch(anchorLineType) { - case AnchorLine::Top: return "Top"; - case AnchorLine::Bottom: return "Bottom"; - case AnchorLine::Left: return "Left"; - case AnchorLine::Right: return "Right"; - default: break; - } - - return QString(); - -} - -QString AnchorHandleItem::toolTipString() const -{ - QString templateString("<p>Anchor Handle</p><p>%1</p><p>%2</p>"); - QmlItemNode fromNode(anchorController().formEditorItem()->qmlItemNode()); - QString fromString(QString("%3: %1(%2)").arg(fromNode.simplifiedTypeName(), fromNode.id(), anchorLineToString(sourceAnchorLine()))); - - AnchorLine toAnchorLine(targetAnchorLine()); - QmlItemNode toNode(toAnchorLine.qmlItemNode()); - QString toString; - if (toNode.isValid()) - toString = QString("%3: %1(%2)").arg(toNode.simplifiedTypeName(), toNode.id(), anchorLineToString(toAnchorLine.type())); - - return templateString.arg(fromString).arg(toString); -} - -void AnchorHandleItem::setHandlePath(const AnchorHandlePathData &pathData) -{ - m_beginArrowPoint = pathData.beginArrowPoint; - m_endArrowPoint = pathData.endArrowPoint; - m_arrowPathItem->setPath(pathData.arrowPath); - m_sourceAnchorLinePathItem->setPath(pathData.sourceAnchorLinePath); - m_targetAnchorLinePathItem->setPath(pathData.targetAnchorLinePath); - m_targetNamePathItem->setPath(pathData.targetNamePath); - - setHighlighted(false); -} - -AnchorController AnchorHandleItem::anchorController() const -{ - Q_ASSERT(!m_anchorControllerData.isNull()); - return AnchorController(m_anchorControllerData.toStrongRef()); -} - -AnchorHandleItem* AnchorHandleItem::fromGraphicsItem(QGraphicsItem *item) -{ - return qgraphicsitem_cast<AnchorHandleItem*>(item); -} - -bool AnchorHandleItem::isTopHandle() const -{ - return anchorController().isTopHandle(this); -} - -bool AnchorHandleItem::isLeftHandle() const -{ - return anchorController().isLeftHandle(this); -} - -bool AnchorHandleItem::isRightHandle() const -{ - return anchorController().isRightHandle(this); -} - -bool AnchorHandleItem::isBottomHandle() const -{ - return anchorController().isBottomHandle(this); -} - -AnchorLine::Type AnchorHandleItem::anchorType() const -{ - if (isTopHandle()) - return AnchorLine::Top; - - if (isBottomHandle()) - return AnchorLine::Bottom; - - if (isLeftHandle()) - return AnchorLine::Left; - - if (isRightHandle()) - return AnchorLine::Right; - - - return AnchorLine::Invalid; -} - -void AnchorHandleItem::setHighlighted(bool highlight) -{ - QLinearGradient gradient(m_beginArrowPoint, m_endArrowPoint); - gradient.setCoordinateMode(QGradient::LogicalMode); - m_arrowPathItem->setPen(QPen(QBrush(Qt::gray), 1.0, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin)); - m_targetAnchorLinePathItem->setPen(QColor(70, 0, 0, 90)); - m_targetAnchorLinePathItem->setBrush(QColor(255, 0, 0, 50)); - m_arrowPathItem->setPen(QPen(QBrush(Qt::gray), 1.0, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin)); - m_targetNamePathItem->setPen(QColor(0, 0, 255, 90)); - m_targetNamePathItem->setBrush(QColor(0, 0, 255, 50)); - - if (highlight) { - gradient.setColorAt(0.0, QColor(0, 0, 120, 255)); - gradient.setColorAt(1.0, QColor(120, 0, 0, 255)); - m_arrowPathItem->setBrush(gradient); - m_sourceAnchorLinePathItem->setPen(QColor(0, 0, 70, 255)); - m_sourceAnchorLinePathItem->setBrush(QColor(0, 0, 70, 255)); - m_targetAnchorLinePathItem->show(); - m_targetNamePathItem->show(); - - } else { - gradient.setColorAt(0.0, QColor(0, 0, 255, 255)); - gradient.setColorAt(1.0, QColor(255, 0, 0, 255)); - m_arrowPathItem->setBrush(gradient); - m_sourceAnchorLinePathItem->setPen(QColor(0, 0, 100, 255)); - m_sourceAnchorLinePathItem->setBrush(QColor(0, 0, 100, 255)); - m_targetAnchorLinePathItem->hide(); - m_targetNamePathItem->hide(); - } -} - -QPointF AnchorHandleItem::itemSpacePosition() const -{ - return parentItem()->mapToItem(anchorController().formEditorItem(), pos()); -} - -} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/formeditor/anchorhandleitem.h b/src/plugins/qmldesigner/components/formeditor/anchorhandleitem.h deleted file mode 100644 index 22e1eae235..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchorhandleitem.h +++ /dev/null @@ -1,92 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -#ifndef ANCHORHANDLEITEM_H -#define ANCHORHANDLEITEM_H - -#include <QGraphicsItemGroup> - -#include "anchorcontroller.h" - -namespace QmlDesigner { - -class AnchorHandleItem : public QGraphicsItemGroup -{ -public: - enum - { - Type = 0xEAEC - }; - - - AnchorHandleItem(QGraphicsItem *parent, const AnchorController &anchorController); - - void setHandlePath(const AnchorHandlePathData &pathData); - - int type() const; - - AnchorController anchorController() const; - - static AnchorHandleItem* fromGraphicsItem(QGraphicsItem *item); - - - bool isTopHandle() const; - bool isLeftHandle() const; - bool isRightHandle() const; - bool isBottomHandle() const; - - QPointF itemSpacePosition() const; - - AnchorLine::Type anchorType() const; - - QString toolTipString() const; - AnchorLine targetAnchorLine() const; - AnchorLine::Type sourceAnchorLine() const; - - void setHighlighted(bool highlight); - -private: - QWeakPointer<AnchorControllerData> m_anchorControllerData; - QGraphicsPathItem *m_sourceAnchorLinePathItem; - QGraphicsPathItem *m_arrowPathItem; - QGraphicsPathItem *m_targetAnchorLinePathItem; - QGraphicsPathItem *m_targetNamePathItem; - QPointF m_beginArrowPoint; - QPointF m_endArrowPoint; -}; - -inline int AnchorHandleItem::type() const -{ - return Type; -} - -} // namespace QmlDesigner - -#endif // ANCHORHANDLEITEM_H diff --git a/src/plugins/qmldesigner/components/formeditor/anchorindicator.cpp b/src/plugins/qmldesigner/components/formeditor/anchorindicator.cpp deleted file mode 100644 index 37e81b83b6..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchorindicator.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -#include "anchorindicator.h" - -#include <QSet> - -namespace QmlDesigner { - -AnchorIndicator::AnchorIndicator(LayerItem *layerItem) - : m_layerItem(layerItem) -{ - Q_ASSERT(layerItem); -} - -AnchorIndicator::~AnchorIndicator() -{ - m_itemControllerHash.clear(); -} - -void AnchorIndicator::show() -{ - QHashIterator<FormEditorItem*, AnchorController> itemControllerIterator(m_itemControllerHash); - while (itemControllerIterator.hasNext()) { - AnchorController controller = itemControllerIterator.next().value(); - controller.show(); - } -} - - -void AnchorIndicator::hide() -{ - QHashIterator<FormEditorItem*, AnchorController> itemControllerIterator(m_itemControllerHash); - while (itemControllerIterator.hasNext()) { - AnchorController controller = itemControllerIterator.next().value(); - controller.hide(); - } -} - -void AnchorIndicator::clear() -{ - m_itemControllerHash.clear(); -} - -void AnchorIndicator::setItems(const QList<FormEditorItem*> &itemList) -{ - clear(); - - foreach (FormEditorItem *item, itemList) { - AnchorController controller(m_layerItem, item); - m_itemControllerHash.insert(item, controller); - } - - updateItems(itemList); -} - -void AnchorIndicator::updateItems(const QList<FormEditorItem*> &itemList) -{ - foreach (FormEditorItem *item, itemList) { - if (m_itemControllerHash.contains(item)) { - AnchorController controller(m_itemControllerHash.value(item)); - controller.updatePosition(); - } - } -} - -void AnchorIndicator::updateTargetPoint(FormEditorItem *item, AnchorLine::Type anchorLine, const QPointF &targetPoint) -{ - AnchorController controller(m_itemControllerHash.value(item)); - controller.updateTargetPoint(anchorLine, targetPoint); -} - -void AnchorIndicator::clearHighlight() -{ - QHashIterator<FormEditorItem*, AnchorController> itemControllerIterator(m_itemControllerHash); - while (itemControllerIterator.hasNext()) { - AnchorController controller = itemControllerIterator.next().value(); - controller.clearHighlight(); - } -} - -void AnchorIndicator::highlight(FormEditorItem *item, AnchorLine::Type anchorLine) -{ - if (m_itemControllerHash.contains(item)) { - AnchorController controller(m_itemControllerHash.value(item)); - controller.highlight(anchorLine); - } -} - -} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/formeditor/anchorindicator.h b/src/plugins/qmldesigner/components/formeditor/anchorindicator.h deleted file mode 100644 index bb27eb7bb8..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchorindicator.h +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -#ifndef ANCHORINDICATOR_H -#define ANCHORINDICATOR_H - -#include "anchorcontroller.h" -#include <QList> -#include <QHash> - -namespace QmlDesigner { - -class AnchorIndicator -{ -public: - AnchorIndicator(LayerItem *layerItem); - ~AnchorIndicator(); - - void show(); - void hide(); - void clear(); - - void setItems(const QList<FormEditorItem*> &itemList); - - void updateItems(const QList<FormEditorItem*> &itemList); - void updateTargetPoint(FormEditorItem *item, AnchorLine::Type anchorLine, const QPointF &targetPoint); - - void clearHighlight(); - void highlight(FormEditorItem *item, AnchorLine::Type anchorLine); - -private: - QHash<FormEditorItem*, AnchorController> m_itemControllerHash; - LayerItem *m_layerItem; -}; - -} // namespace QmlDesigner - -#endif // ANCHORINDICATOR_H diff --git a/src/plugins/qmldesigner/components/formeditor/anchorlinecontroller.cpp b/src/plugins/qmldesigner/components/formeditor/anchorlinecontroller.cpp deleted file mode 100644 index f18e32ed24..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchorlinecontroller.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -#include "anchorlinecontroller.h" - -#include "formeditoritem.h" -#include "layeritem.h" -#include <QGraphicsScene> - -#include "anchorlinehandleitem.h" - -namespace QmlDesigner { - - -AnchorLineControllerData::AnchorLineControllerData(LayerItem *layerItem, FormEditorItem *formEditorItem) - : layerItem(layerItem), - formEditorItem(formEditorItem), - topItem(0), - leftItem(0), - rightItem(0), - bottomItem(0) -{ -} - -AnchorLineControllerData::AnchorLineControllerData(const AnchorLineControllerData &other) - : layerItem(other.layerItem), - formEditorItem(other.formEditorItem), - topItem(other.topItem), - leftItem(other.leftItem), - rightItem(other.rightItem), - bottomItem(other.bottomItem) -{} - -AnchorLineControllerData::~AnchorLineControllerData() -{ - if (layerItem) { - layerItem->scene()->removeItem(topItem); - layerItem->scene()->removeItem(leftItem); - layerItem->scene()->removeItem(rightItem); - layerItem->scene()->removeItem(bottomItem); - } -} - - -AnchorLineController::AnchorLineController() - : m_data(new AnchorLineControllerData(0, 0)) -{ - -} - -AnchorLineController::AnchorLineController(const QSharedPointer<AnchorLineControllerData> &data) - : m_data(data) -{ - -} - -AnchorLineController::AnchorLineController(LayerItem *layerItem, FormEditorItem *formEditorItem) - : m_data(new AnchorLineControllerData(layerItem, formEditorItem)) -{ - m_data->topItem = new AnchorLineHandleItem(layerItem, *this); - m_data->topItem->setZValue(300); - - m_data->leftItem = new AnchorLineHandleItem(layerItem, *this); - m_data->leftItem->setZValue(300); - - m_data->rightItem = new AnchorLineHandleItem(layerItem, *this); - m_data->rightItem->setZValue(300); - - m_data->bottomItem = new AnchorLineHandleItem(layerItem, *this); - m_data->bottomItem->setZValue(300); - - updatePosition(); -} - - -bool AnchorLineController::isValid() const -{ - return m_data->formEditorItem != 0; -} - -void AnchorLineController::show(AnchorLine::Type anchorLineMask) -{ - if (anchorLineMask & AnchorLine::Top) - m_data->topItem->show(); - else - m_data->topItem->hide(); - - if (anchorLineMask & AnchorLine::Left) - m_data->leftItem->show(); - else - m_data->leftItem->hide(); - - if (anchorLineMask & AnchorLine::Right) - m_data->rightItem->show(); - else - m_data->rightItem->hide(); - - if (anchorLineMask & AnchorLine::Bottom) - m_data->bottomItem->show(); - else - m_data->bottomItem->hide(); -} - -void AnchorLineController::hide() -{ - m_data->topItem->hide(); - m_data->leftItem->hide(); - m_data->rightItem->hide(); - m_data->bottomItem->hide(); -} - -static QPainterPath rectToPath(const QRectF &rect) -{ - QPainterPath path; - path.addRoundedRect(rect, 4, 4); - - return path; -} - -void AnchorLineController::updatePosition() -{ - QRectF boundingRect = m_data->formEditorItem->qmlItemNode().instanceBoundingRect(); - - QRectF topBoundingRect(boundingRect); - QRectF leftBoundingRect(boundingRect); - QRectF bottomBoundingRect(boundingRect); - QRectF rightBoundingRect(boundingRect); - - - if (formEditorItem()->isContainer()) { - topBoundingRect.setBottom(boundingRect.top() + 6); - topBoundingRect.adjust(7, -5, -7, 0); - - leftBoundingRect.setRight(boundingRect.left() + 6); - leftBoundingRect.adjust(-5, 7, 0, -7); - - bottomBoundingRect.setTop(boundingRect.bottom() - 6); - bottomBoundingRect.adjust(7, 0, -7, 5); - - rightBoundingRect.setLeft(boundingRect.right() - 6); - rightBoundingRect.adjust(0, 7, 5, -7); - - } else { - double height = qMin(boundingRect.height() / 4., 10.0); - double width = qMin(boundingRect.width() / 4., 10.0); - - topBoundingRect.setHeight(height); - topBoundingRect.adjust(width, -4, -width, -1); - - leftBoundingRect.setWidth(width); - leftBoundingRect.adjust(-4, height, -1, -height); - - bottomBoundingRect.setTop(boundingRect.bottom() - height); - bottomBoundingRect.adjust(width, 1, -width, 4); - - rightBoundingRect.setLeft(boundingRect.right() - width); - rightBoundingRect.adjust(1, height, 4, -height); - } - - m_data->topItem->setHandlePath(m_data->formEditorItem->mapToItem(m_data->layerItem.data(), - rectToPath(topBoundingRect))); - m_data->leftItem->setHandlePath(m_data->formEditorItem->mapToItem(m_data->layerItem.data(), - rectToPath(leftBoundingRect))); - m_data->bottomItem->setHandlePath(m_data->formEditorItem->mapToItem(m_data->layerItem.data(), - rectToPath(bottomBoundingRect))); - m_data->rightItem->setHandlePath(m_data->formEditorItem->mapToItem(m_data->layerItem.data(), - rectToPath(rightBoundingRect))); -} - - -FormEditorItem* AnchorLineController::formEditorItem() const -{ - return m_data->formEditorItem; -} - -QWeakPointer<AnchorLineControllerData> AnchorLineController::weakPointer() const -{ - return m_data; -} - - -bool AnchorLineController::isTopHandle(const AnchorLineHandleItem *handle) const -{ - return handle == m_data->topItem; -} - -bool AnchorLineController::isLeftHandle(const AnchorLineHandleItem *handle) const -{ - return handle == m_data->leftItem; -} - -bool AnchorLineController::isRightHandle(const AnchorLineHandleItem *handle) const -{ - return handle == m_data->rightItem; -} - -bool AnchorLineController::isBottomHandle(const AnchorLineHandleItem *handle) const -{ - return handle == m_data->bottomItem; -} - -void AnchorLineController::clearHighlight() -{ - m_data->topItem->setHiglighted(false); - m_data->leftItem->setHiglighted(false); - m_data->rightItem->setHiglighted(false); - m_data->bottomItem->setHiglighted(false); -} - -} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/formeditor/anchorlinecontroller.h b/src/plugins/qmldesigner/components/formeditor/anchorlinecontroller.h deleted file mode 100644 index b8374ee27e..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchorlinecontroller.h +++ /dev/null @@ -1,94 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -#ifndef ANCHORLINECONTROLLER_H -#define ANCHORLINECONTROLLER_H - -#include <QWeakPointer> -#include <QSharedPointer> -#include <qmlanchors.h> - -namespace QmlDesigner { - -class FormEditorItem; -class LayerItem; -class AnchorLineHandleItem; - -class AnchorLineControllerData -{ -public: - AnchorLineControllerData(LayerItem *layerItem, - FormEditorItem *formEditorItem); - AnchorLineControllerData(const AnchorLineControllerData &other); - ~AnchorLineControllerData(); - - QWeakPointer<LayerItem> layerItem; - FormEditorItem *formEditorItem; - - AnchorLineHandleItem *topItem; - AnchorLineHandleItem *leftItem; - AnchorLineHandleItem *rightItem; - AnchorLineHandleItem *bottomItem; -}; - - -class AnchorLineController -{ - public: - AnchorLineController(); - AnchorLineController(LayerItem *layerItem, FormEditorItem *formEditorItem); - AnchorLineController(const QSharedPointer<AnchorLineControllerData> &data); - - void show(AnchorLine::Type anchorLineMask); - void hide(); - - void updatePosition(); - - bool isValid() const; - - QWeakPointer<AnchorLineControllerData> weakPointer() const; - - - FormEditorItem *formEditorItem() const; - - bool isTopHandle(const AnchorLineHandleItem *handle) const; - bool isLeftHandle(const AnchorLineHandleItem *handle) const; - bool isRightHandle(const AnchorLineHandleItem *handle) const; - bool isBottomHandle(const AnchorLineHandleItem *handle) const; - - void clearHighlight(); - -private: - QSharedPointer<AnchorLineControllerData> m_data; -}; - -} // namespace QmlDesigner - -#endif // ANCHORLINECONTROLLER_H diff --git a/src/plugins/qmldesigner/components/formeditor/anchorlinehandleitem.cpp b/src/plugins/qmldesigner/components/formeditor/anchorlinehandleitem.cpp deleted file mode 100644 index d0c20f0cb0..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchorlinehandleitem.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -#include "anchorlinehandleitem.h" - -#include <formeditoritem.h> -#include <QPen> -#include <cmath> - -namespace QmlDesigner { - -AnchorLineHandleItem::AnchorLineHandleItem(QGraphicsItem *parent, const AnchorLineController &anchorLineController) - : QGraphicsPathItem(parent), - m_anchorLineControllerData(anchorLineController.weakPointer()) -{ - setFlag(QGraphicsItem::ItemIsMovable, true); - setHiglighted(false); -} - -void AnchorLineHandleItem::setHandlePath(const QPainterPath & path) -{ - setPath(path); - update(); -} - -QRectF AnchorLineHandleItem::boundingRect() const -{ - return QGraphicsPathItem::boundingRect(); -} - -QPainterPath AnchorLineHandleItem::shape() const -{ - return QGraphicsPathItem::shape(); -} - -AnchorLineController AnchorLineHandleItem::anchorLineController() const -{ - Q_ASSERT(!m_anchorLineControllerData.isNull()); - return AnchorLineController(m_anchorLineControllerData.toStrongRef()); -} - -AnchorLine::Type AnchorLineHandleItem::anchorLine() const -{ - if (isTopHandle()) - return AnchorLine::Top; - - if (isLeftHandle()) - return AnchorLine::Left; - - if (isRightHandle()) - return AnchorLine::Right; - - if (isBottomHandle()) - return AnchorLine::Bottom; - - return AnchorLine::Invalid; -} - -AnchorLineHandleItem* AnchorLineHandleItem::fromGraphicsItem(QGraphicsItem *item) -{ - return qgraphicsitem_cast<AnchorLineHandleItem*>(item); -} - -bool AnchorLineHandleItem::isTopHandle() const -{ - return anchorLineController().isTopHandle(this); -} - -bool AnchorLineHandleItem::isLeftHandle() const -{ - return anchorLineController().isLeftHandle(this); -} - -bool AnchorLineHandleItem::isRightHandle() const -{ - return anchorLineController().isRightHandle(this); -} - -bool AnchorLineHandleItem::isBottomHandle() const -{ - return anchorLineController().isBottomHandle(this); -} - -AnchorLine::Type AnchorLineHandleItem::anchorLineType() const -{ - if (isTopHandle()) - return AnchorLine::Top; - - if (isBottomHandle()) - return AnchorLine::Bottom; - - if (isLeftHandle()) - return AnchorLine::Left; - - if (isRightHandle()) - return AnchorLine::Right; - - - return AnchorLine::Invalid; -} - -QPointF AnchorLineHandleItem::itemSpacePosition() const -{ - return parentItem()->mapToItem(anchorLineController().formEditorItem(), pos()); -} - -void AnchorLineHandleItem::setHiglighted(bool highlight) -{ - if (highlight) { - QPen pen; - pen.setColor(QColor(108, 141, 221)); - setPen(pen); - setBrush(QColor(108, 141, 221, 140)); - } else { - QPen pen; - pen.setColor(QColor(108, 141, 221)); - setPen(pen); - setBrush(QColor(108, 141, 221, 60)); - } -} - -} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/formeditor/anchorlinehandleitem.h b/src/plugins/qmldesigner/components/formeditor/anchorlinehandleitem.h deleted file mode 100644 index f9ac67639d..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchorlinehandleitem.h +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -#ifndef ANCHORLINEHANDLEITEM_H -#define ANCHORLINEHANDLEITEM_H - -#include <QGraphicsPathItem> - -#include "anchorlinecontroller.h" - -namespace QmlDesigner { - -class AnchorLineHandleItem : public QGraphicsPathItem -{ -public: - enum - { - Type = 0xEAEB - }; - - - AnchorLineHandleItem(QGraphicsItem *parent, const AnchorLineController &AnchorLineController); - - void setHandlePath(const QPainterPath & path); - - int type() const; - QRectF boundingRect() const; - QPainterPath shape() const; - - AnchorLineController anchorLineController() const; - AnchorLine::Type anchorLine() const; - - - static AnchorLineHandleItem* fromGraphicsItem(QGraphicsItem *item); - - - bool isTopHandle() const; - bool isLeftHandle() const; - bool isRightHandle() const; - bool isBottomHandle() const; - - QPointF itemSpacePosition() const; - - AnchorLine::Type anchorLineType() const; - - void setHiglighted(bool highlight); - - -private: - QWeakPointer<AnchorLineControllerData> m_anchorLineControllerData; -}; - -inline int AnchorLineHandleItem::type() const -{ - return Type; -} - -} // namespace QmlDesigner - -#endif // ANCHORLINEHANDLEITEM_H diff --git a/src/plugins/qmldesigner/components/formeditor/anchorlineindicator.cpp b/src/plugins/qmldesigner/components/formeditor/anchorlineindicator.cpp deleted file mode 100644 index 82b059808f..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchorlineindicator.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -#include "anchorlineindicator.h" - -#include <QSet> - -namespace QmlDesigner { - -AnchorLineIndicator::AnchorLineIndicator(LayerItem *layerItem) - : m_layerItem(layerItem) -{ - Q_ASSERT(layerItem); -} - -AnchorLineIndicator::~AnchorLineIndicator() -{ - m_itemControllerHash.clear(); -} - -void AnchorLineIndicator::show(AnchorLine::Type anchorLineMask) -{ - QHashIterator<FormEditorItem*, AnchorLineController> itemControllerIterator(m_itemControllerHash); - while (itemControllerIterator.hasNext()) { - AnchorLineController controller = itemControllerIterator.next().value(); - controller.show(anchorLineMask); - } -} - -void AnchorLineIndicator::hide() -{ - QHashIterator<FormEditorItem*, AnchorLineController> itemControllerIterator(m_itemControllerHash); - while (itemControllerIterator.hasNext()) { - AnchorLineController controller = itemControllerIterator.next().value(); - controller.hide(); - } -} - -void AnchorLineIndicator::clear() -{ - m_itemControllerHash.clear(); -} - -void AnchorLineIndicator::setItem(FormEditorItem* item) -{ - if (!item) - return; - - QList<FormEditorItem*> itemList; - itemList.append(item); - - setItems(itemList); -} - -static bool equalLists(const QList<FormEditorItem*> &firstList, const QList<FormEditorItem*> &secondList) -{ - return firstList.toSet() == secondList.toSet(); -} - -void AnchorLineIndicator::setItems(const QList<FormEditorItem*> &itemList) -{ - if (equalLists(itemList, m_itemControllerHash.keys())) - return; - - clear(); - - foreach (FormEditorItem *item, itemList) { - AnchorLineController controller(m_layerItem, item); - m_itemControllerHash.insert(item, controller); - } - - show(AnchorLine::AllMask); -} - -void AnchorLineIndicator::updateItems(const QList<FormEditorItem*> &itemList) -{ - foreach (FormEditorItem *item, itemList) { - if (m_itemControllerHash.contains(item)) { - AnchorLineController controller(m_itemControllerHash.value(item)); - controller.updatePosition(); - } - } -} - -void AnchorLineIndicator::update() -{ - foreach (FormEditorItem *item, m_itemControllerHash.keys()) { - if (m_itemControllerHash.contains(item)) { - AnchorLineController controller(m_itemControllerHash.value(item)); - controller.updatePosition(); - } - } -} - -void AnchorLineIndicator::clearHighlight() -{ - foreach (FormEditorItem *item, m_itemControllerHash.keys()) { - if (m_itemControllerHash.contains(item)) { - AnchorLineController controller(m_itemControllerHash.value(item)); - controller.clearHighlight(); - } - } -} - -} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/formeditor/anchorlineindicator.h b/src/plugins/qmldesigner/components/formeditor/anchorlineindicator.h deleted file mode 100644 index cc7b537a5d..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchorlineindicator.h +++ /dev/null @@ -1,70 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -#ifndef ANCHORLINEINDICATOR_H -#define ANCHORLINEINDICATOR_H - -#include "layeritem.h" -#include "anchorlinecontroller.h" -#include <QHash> - -namespace QmlDesigner { - -class FormEditorItem; - -class AnchorLineIndicator -{ -public: - AnchorLineIndicator(LayerItem *layerItem); - ~AnchorLineIndicator(); - - void show(AnchorLine::Type anchorLineMask); - - void hide(); - - void clear(); - - void update(); - - void setItems(const QList<FormEditorItem*> &itemList); - void setItem(FormEditorItem* item); - void updateItems(const QList<FormEditorItem*> &itemList); - - void clearHighlight(); - -private: - QHash<FormEditorItem*, AnchorLineController> m_itemControllerHash; - - LayerItem *m_layerItem; -}; - -} // namespace QmlDesigner - -#endif // ANCHORLINEINDICATOR_H diff --git a/src/plugins/qmldesigner/components/formeditor/anchormanipulator.cpp b/src/plugins/qmldesigner/components/formeditor/anchormanipulator.cpp deleted file mode 100644 index c6f095563c..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchormanipulator.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -#include "anchormanipulator.h" - -#include "formeditoritem.h" -#include "formeditorscene.h" -#include "formeditorview.h" -#include <model.h> -#include <rewritertransaction.h> - -namespace QmlDesigner { - -AnchorManipulator::AnchorManipulator(FormEditorView *view) - : m_beginFormEditorItem(0), - m_beginAnchorLine(AnchorLine::Invalid), - m_view(view) -{ -} - -AnchorManipulator::~AnchorManipulator() -{ - clear(); -} - -void AnchorManipulator::begin(FormEditorItem *beginItem, AnchorLine::Type anchorLine) -{ - m_beginFormEditorItem = beginItem; - m_beginAnchorLine = anchorLine; -} - -static double offset(const QPointF &topLeft, const QPointF &bottomRight, AnchorLine::Type anchorLine) -{ - switch(anchorLine) { - case AnchorLine::Top : return topLeft.y(); - case AnchorLine::Left : return topLeft.x(); - case AnchorLine::Bottom : return bottomRight.y(); - case AnchorLine::Right : return bottomRight.x(); - default: break; - } - - return 0.0; -} - -void AnchorManipulator::setMargin(FormEditorItem *endItem, AnchorLine::Type endAnchorLine) -{ - QPointF beginItemTopLeft(m_beginFormEditorItem->mapToParent(m_beginFormEditorItem->qmlItemNode().instanceBoundingRect().topLeft())); - QPointF endItemTopLeft(m_beginFormEditorItem->parentItem()->mapFromItem(endItem, endItem->qmlItemNode().instanceBoundingRect().topLeft())); - - QPointF beginItemBottomRight(m_beginFormEditorItem->mapToParent(m_beginFormEditorItem->qmlItemNode().instanceBoundingRect().bottomRight())); - QPointF endItemBottomRight(m_beginFormEditorItem->parentItem()->mapFromItem(endItem, endItem->qmlItemNode().instanceBoundingRect().bottomRight())); - - double anchorOffset = 0.0; - if (m_beginAnchorLine & (AnchorLine::Bottom | AnchorLine::Right)) { - anchorOffset = offset(endItemTopLeft, endItemBottomRight, endAnchorLine) - - offset(beginItemTopLeft, beginItemBottomRight, m_beginAnchorLine); - } else { - anchorOffset = offset(beginItemTopLeft, beginItemBottomRight, m_beginAnchorLine) - - offset(endItemTopLeft, endItemBottomRight, endAnchorLine); - } - - m_beginFormEditorItem->qmlItemNode().anchors().setMargin(m_beginAnchorLine, anchorOffset); -} -void AnchorManipulator::addAnchor(FormEditorItem *endItem, AnchorLine::Type endAnchorLine) -{ - RewriterTransaction m_rewriterTransaction = m_view->beginRewriterTransaction(); - setMargin(endItem, endAnchorLine); - - m_beginFormEditorItem->qmlItemNode().anchors().setAnchor(m_beginAnchorLine, - endItem->qmlItemNode(), - endAnchorLine); -} - -void AnchorManipulator::removeAnchor() -{ - RewriterTransaction transaction = m_view->beginRewriterTransaction(); - QmlAnchors anchors(m_beginFormEditorItem->qmlItemNode().anchors()); - if (anchors.instanceHasAnchor(m_beginAnchorLine)) { - anchors.removeAnchor(m_beginAnchorLine); - anchors.removeMargin(m_beginAnchorLine); - } -} - -void AnchorManipulator::clear() -{ - m_beginFormEditorItem = 0; - m_beginAnchorLine = AnchorLine::Invalid; -} - -bool AnchorManipulator::isActive() const -{ - return m_beginFormEditorItem && m_beginAnchorLine != AnchorLine::Invalid; -} - -AnchorLine::Type AnchorManipulator::beginAnchorLine() const -{ - return m_beginAnchorLine; -} - -bool AnchorManipulator::beginAnchorLineIsHorizontal() const -{ - return beginAnchorLine() & AnchorLine::HorizontalMask; -} -bool AnchorManipulator::beginAnchorLineIsVertical() const -{ - return beginAnchorLine() & AnchorLine::HorizontalMask; -} - -FormEditorItem *AnchorManipulator::beginFormEditorItem() const -{ - return m_beginFormEditorItem; -} - -} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/formeditor/anchormanipulator.h b/src/plugins/qmldesigner/components/formeditor/anchormanipulator.h deleted file mode 100644 index a8dc936ea2..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchormanipulator.h +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -#ifndef ANCHORMANIPULATOR_H -#define ANCHORMANIPULATOR_H - -#include <qmlanchors.h> - -namespace QmlDesigner { - -class FormEditorItem; -class FormEditorView; - -class AnchorManipulator -{ -public: - AnchorManipulator(FormEditorView *view); - ~AnchorManipulator(); - void begin(FormEditorItem *beginItem, AnchorLine::Type anchorLine); - void addAnchor(FormEditorItem *endItem, AnchorLine::Type anchorLine); - void removeAnchor(); - - void clear(); - - bool isActive() const; - - bool beginAnchorLineIsHorizontal() const; - bool beginAnchorLineIsVertical() const; - - AnchorLine::Type beginAnchorLine() const; - - FormEditorItem *beginFormEditorItem() const; - -private: // functions - void setMargin(FormEditorItem *endItem, AnchorLine::Type endAnchorLine); - -private: // variables - FormEditorItem *m_beginFormEditorItem; - AnchorLine::Type m_beginAnchorLine; - QWeakPointer<FormEditorView> m_view; -}; - -} // namespace QmlDesigner - -#endif // ANCHORMANIPULATOR_H diff --git a/src/plugins/qmldesigner/components/formeditor/anchortool.cpp b/src/plugins/qmldesigner/components/formeditor/anchortool.cpp deleted file mode 100644 index 6c8dee353a..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchortool.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -#include "anchortool.h" - -#include "formeditorscene.h" -#include "formeditorview.h" -#include <qmlitemnode.h> -#include <qmlanchors.h> -#include "anchorlinehandleitem.h" - -#include <QGraphicsSceneMouseEvent> - -#include <QDebug> - -namespace QmlDesigner { - -AnchorTool::AnchorTool(FormEditorView* editorView) - : AbstractFormEditorTool(editorView), - m_anchorLineIndicator(editorView->scene()->manipulatorLayerItem()), - m_anchorIndicator(editorView->scene()->manipulatorLayerItem()), - m_anchorManipulator(editorView), - m_lastAnchorLineHandleItem(0) -{ - m_hoverTimeLine.setDuration(200); - connect(&m_hoverTimeLine, SIGNAL(finished()), SLOT(checkIfStillHovering())); -} - -AnchorTool::~AnchorTool() -{ - -} - -void AnchorTool::mousePressEvent(const QList<QGraphicsItem*> &itemList, - QGraphicsSceneMouseEvent *) -{ - AnchorLineHandleItem *anchorLineHandleItem = topAnchorLineHandleItem(itemList); - if (anchorLineHandleItem) { - m_anchorManipulator.begin(anchorLineHandleItem->anchorLineController().formEditorItem(), - anchorLineHandleItem->anchorLineType()); - } - - m_anchorLineIndicator.clear(); - -} - -bool areAchorable(FormEditorItem *firstItem, FormEditorItem *secondItem) -{ - return firstItem->qmlItemNode().anchors().canAnchor(secondItem->qmlItemNode()); -} - -void AnchorTool::mouseMoveEvent(const QList<QGraphicsItem*> &itemList, - QGraphicsSceneMouseEvent *event) -{ - if (m_anchorManipulator.isActive()) { - FormEditorItem *targetItem = 0; - AnchorLineHandleItem *anchorLineHandleItem = topAnchorLineHandleItem(itemList); - if (anchorLineHandleItem && areAchorable(m_anchorManipulator.beginFormEditorItem(), anchorLineHandleItem->anchorLineController().formEditorItem())) { - targetItem = anchorLineHandleItem->anchorLineController().formEditorItem(); - } else { - FormEditorItem *topFormEditItem = topFormEditorItemWithRootItem(itemList); - if (topFormEditItem && areAchorable(m_anchorManipulator.beginFormEditorItem(), topFormEditItem)) { - targetItem = topFormEditItem; - } else { - m_anchorLineIndicator.hide(); - m_anchorIndicator.updateTargetPoint(m_anchorManipulator.beginFormEditorItem(), m_anchorManipulator.beginAnchorLine(), event->scenePos()); - } - } - - if (targetItem) { - targetItem->qmlItemNode().selectNode(); - m_anchorLineIndicator.setItem(targetItem); - m_anchorLineIndicator.show(m_anchorManipulator.beginFormEditorItem()->qmlItemNode().anchors().possibleAnchorLines(m_anchorManipulator.beginAnchorLine(), targetItem->qmlItemNode())); - m_anchorIndicator.updateTargetPoint(m_anchorManipulator.beginFormEditorItem(), m_anchorManipulator.beginAnchorLine(), event->scenePos()); - targetItem->qmlItemNode().selectNode(); - } - } - -} - -void AnchorTool::mouseReleaseEvent(const QList<QGraphicsItem*> &itemList, - QGraphicsSceneMouseEvent *) -{ - if (m_anchorManipulator.isActive()) { - AnchorLineHandleItem *anchorLineHandleItem = topAnchorLineHandleItem(itemList); - if (anchorLineHandleItem) { - m_anchorManipulator.addAnchor(anchorLineHandleItem->anchorLineController().formEditorItem(), - anchorLineHandleItem->anchorLineType()); - } else { - m_anchorManipulator.removeAnchor(); - } - - - } - - FormEditorItem *topFormEditItem = topFormEditorItem(itemList); - if (topFormEditItem) - topFormEditItem->qmlItemNode().selectNode(); - - m_anchorManipulator.clear(); - m_anchorLineIndicator.clear(); -} - -void AnchorTool::mouseDoubleClickEvent(const QList<QGraphicsItem*> & /*itemList*/, - QGraphicsSceneMouseEvent * /*event*/) -{ -} - -void AnchorTool::hoverMoveEvent(const QList<QGraphicsItem*> &itemList, - QGraphicsSceneMouseEvent *event) -{ - m_anchorLineIndicator.clearHighlight(); - m_anchorIndicator.clearHighlight(); - m_lastMousePosition = event->scenePos(); - FormEditorItem *topFormEditItem = 0; - AnchorLineHandleItem *anchorLineHandleItem = topAnchorLineHandleItem(itemList); - - if (anchorLineHandleItem) { - anchorLineHandleItem->setHiglighted(true); - m_anchorIndicator.highlight(anchorLineHandleItem->anchorLineController().formEditorItem(), - anchorLineHandleItem->anchorLineType()); - topFormEditItem = anchorLineHandleItem->anchorLineController().formEditorItem(); - if (m_hoverTimeLine.state() == QTimeLine::NotRunning) { - m_lastAnchorLineHandleItem = anchorLineHandleItem; - m_hoverTimeLine.start(); - } - } else { - topFormEditItem = topFormEditorItem(itemList); - } - - if (topFormEditItem) { - m_anchorLineIndicator.setItem(topFormEditItem); - m_anchorLineIndicator.show(AnchorLine::AllMask); - topFormEditItem->qmlItemNode().selectNode(); - } else { - - m_anchorLineIndicator.clear(); - } -} - -void AnchorTool::checkIfStillHovering() -{ - AnchorLineHandleItem *anchorLineHandleItem = topAnchorLineHandleItem(scene()->items(m_lastMousePosition)); - - if (anchorLineHandleItem && anchorLineHandleItem == m_lastAnchorLineHandleItem) { - FormEditorItem *sourceFormEditItem = anchorLineHandleItem->anchorLineController().formEditorItem(); - QmlAnchors anchors(sourceFormEditItem->qmlItemNode().anchors()); - if (anchors.instanceHasAnchor(anchorLineHandleItem->anchorLine())) { - QmlItemNode targetNode(anchors.instanceAnchor(anchorLineHandleItem->anchorLine()).qmlItemNode()); - FormEditorItem *targetFormEditorItem = scene()->itemForQmlItemNode(targetNode); - targetFormEditorItem->showAttention(); - } - } -} - -void AnchorTool::keyPressEvent(QKeyEvent *) -{ -} - -void AnchorTool::keyReleaseEvent(QKeyEvent *) -{ -} - -void AnchorTool::dragLeaveEvent(QGraphicsSceneDragDropEvent *) -{ - -} - -void AnchorTool::dragMoveEvent(QGraphicsSceneDragDropEvent *) -{ - -} - -void AnchorTool::itemsAboutToRemoved(const QList<FormEditorItem*> &removedItems) -{ - QList<FormEditorItem*> newItemList = items().toSet().subtract(removedItems.toSet()).toList(); - setItems(newItemList); - m_anchorIndicator.setItems(newItemList); - m_anchorLineIndicator.clear(); -} - -void AnchorTool::selectedItemsChanged(const QList<FormEditorItem*> &/*itemList*/) -{ - m_anchorIndicator.setItems(view()->scene()->allFormEditorItems()); - m_anchorIndicator.show(); -} - -void AnchorTool::clear() -{ - m_anchorLineIndicator.clear(); - m_anchorIndicator.clear(); -} - -void AnchorTool::formEditorItemsChanged(const QList<FormEditorItem*> &) -{ - m_anchorLineIndicator.updateItems(view()->scene()->allFormEditorItems()); - m_anchorIndicator.updateItems(view()->scene()->allFormEditorItems()); -} - -void AnchorTool::instancesCompleted(const QList<FormEditorItem*> &/*itemList*/) -{ -} - -void AnchorTool::instancesParentChanged(const QList<FormEditorItem *> &/*itemList*/) -{ -} - -AnchorLineHandleItem* AnchorTool::topAnchorLineHandleItem(const QList<QGraphicsItem*> & itemList) -{ - foreach (QGraphicsItem *item, itemList) { - AnchorLineHandleItem *anchorLineItem = AnchorLineHandleItem::fromGraphicsItem(item); - if (anchorLineItem) - return anchorLineItem; - } - - return 0; -} -} diff --git a/src/plugins/qmldesigner/components/formeditor/anchortool.h b/src/plugins/qmldesigner/components/formeditor/anchortool.h deleted file mode 100644 index fcf83f7436..0000000000 --- a/src/plugins/qmldesigner/components/formeditor/anchortool.h +++ /dev/null @@ -1,96 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -#ifndef ANCHORTOOL_H -#define ANCHORTOOL_H - -#include <QTimeLine> - -#include "abstractformeditortool.h" - -#include "anchorlineindicator.h" -#include "anchorindicator.h" -#include "anchormanipulator.h" - -namespace QmlDesigner { - -class AnchorLineHandleItem; - -class AnchorTool : public QObject, public AbstractFormEditorTool -{ - Q_OBJECT -public: - AnchorTool(FormEditorView* editorView); - ~AnchorTool(); - - void mousePressEvent(const QList<QGraphicsItem*> &itemList, - QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(const QList<QGraphicsItem*> &itemList, - QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(const QList<QGraphicsItem*> &itemList, - QGraphicsSceneMouseEvent *event); - void mouseDoubleClickEvent(const QList<QGraphicsItem*> &itemList, - QGraphicsSceneMouseEvent *event); - void hoverMoveEvent(const QList<QGraphicsItem*> &itemList, - QGraphicsSceneMouseEvent *event); - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *keyEvent); - - void dragLeaveEvent(QGraphicsSceneDragDropEvent * event); - void dragMoveEvent(QGraphicsSceneDragDropEvent * event); - - void itemsAboutToRemoved(const QList<FormEditorItem*> &itemList); - - void selectedItemsChanged(const QList<FormEditorItem*> &itemList); - - void clear(); - - void formEditorItemsChanged(const QList<FormEditorItem*> &itemList); - - void instancesCompleted(const QList<FormEditorItem*> &itemList); - void instancesParentChanged(const QList<FormEditorItem *> &itemList); - - - static AnchorLineHandleItem* topAnchorLineHandleItem(const QList<QGraphicsItem*> & itemList); - -private slots: - void checkIfStillHovering(); - -private: //variables - AnchorLineIndicator m_anchorLineIndicator; - AnchorIndicator m_anchorIndicator; - AnchorManipulator m_anchorManipulator; - QTimeLine m_hoverTimeLine; - QPointF m_lastMousePosition; - AnchorLineHandleItem *m_lastAnchorLineHandleItem; -}; - -} -#endif // ANCHORTOOL_H diff --git a/src/plugins/qmldesigner/components/formeditor/formeditor.pri b/src/plugins/qmldesigner/components/formeditor/formeditor.pri index e3182d109a..f353e868ee 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditor.pri +++ b/src/plugins/qmldesigner/components/formeditor/formeditor.pri @@ -27,14 +27,6 @@ SOURCES += formeditoritem.cpp \ scaleitem.cpp \ resizecontroller.cpp \ resizehandleitem.cpp \ - anchortool.cpp \ - anchorlineindicator.cpp \ - anchorlinecontroller.cpp \ - anchorlinehandleitem.cpp \ - anchormanipulator.cpp \ - anchorindicator.cpp \ - anchorcontroller.cpp \ - anchorhandleitem.cpp \ dragtool.cpp \ toolbox.cpp \ zoomaction.cpp \ @@ -66,14 +58,6 @@ HEADERS += formeditorscene.h \ scaleitem.h \ resizecontroller.h \ resizehandleitem.h \ - anchortool.h \ - anchorlineindicator.h \ - anchorlinecontroller.h \ - anchorlinehandleitem.h \ - anchormanipulator.h \ - anchorindicator.h \ - anchorcontroller.h \ - anchorhandleitem.h \ dragtool.h \ toolbox.h \ zoomaction.h \ diff --git a/src/plugins/qmldesigner/components/formeditor/formeditor.qrc b/src/plugins/qmldesigner/components/formeditor/formeditor.qrc index 6086ac240c..9c67a2c5b5 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditor.qrc +++ b/src/plugins/qmldesigner/components/formeditor/formeditor.qrc @@ -3,14 +3,13 @@ <file>resize_handle.png</file> </qresource> <qresource prefix="/icon/tool"> - <file>anchor.png</file> <file>transform.png</file> </qresource> <qresource prefix="/icon/layout"> <file>snapping.png</file> <file>no_snapping.png</file> <file>snapping_and_anchoring.png</file> - <file>boundingrect.png</file> + <file>boundingrect.png</file> </qresource> <qresource prefix="/icon/selection"> <file>selectonlycontentitems.png</file> diff --git a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp index 8a2a29b43b..3655895e6f 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp @@ -244,28 +244,18 @@ void FormEditorItem::paintBoundingRect(QPainter *painter) const pen.setJoinStyle(Qt::MiterJoin); pen.setStyle(Qt::DotLine); - switch(scene()->paintMode()) { - case FormEditorScene::AnchorMode: { - pen.setColor(Qt::black); - pen.setWidth(m_borderWidth); - } - break; - case FormEditorScene::NormalMode: { - QColor frameColor("#AAAAAA"); - - if (scene()->showBoundingRects()) { - if (m_highlightBoundingRect) - pen.setColor(frameColor); - else - pen.setColor(frameColor.darker(150)); - } else { - if (m_highlightBoundingRect) - pen.setColor(frameColor); - else - pen.setColor(Qt::transparent); - } - } - break; + QColor frameColor("#AAAAAA"); + + if (scene()->showBoundingRects()) { + if (m_highlightBoundingRect) + pen.setColor(frameColor); + else + pen.setColor(frameColor.darker(150)); + } else { + if (m_highlightBoundingRect) + pen.setColor(frameColor); + else + pen.setColor(Qt::transparent); } painter->setPen(pen); diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp index eaf16f6ef6..2f2ce94d2e 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp @@ -61,7 +61,6 @@ namespace QmlDesigner { FormEditorScene::FormEditorScene(FormEditorWidget *view, FormEditorView *editorView) : QGraphicsScene(), m_editorView(editorView), - m_paintMode(NormalMode), m_showBoundingRects(true) { setupScene(); @@ -391,16 +390,6 @@ FormEditorItem* FormEditorScene::rootFormEditorItem() const return 0; } -FormEditorScene::PaintMode FormEditorScene::paintMode() const -{ - return m_paintMode; -} - -void FormEditorScene::setPaintMode(PaintMode paintMode) -{ - m_paintMode = paintMode; -} - void FormEditorScene::clearFormEditorItems() { QList<QGraphicsItem*> itemList(items()); diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorscene.h b/src/plugins/qmldesigner/components/formeditor/formeditorscene.h index f319455df3..86aa1efe60 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorscene.h +++ b/src/plugins/qmldesigner/components/formeditor/formeditorscene.h @@ -57,11 +57,6 @@ class FormEditorScene : public QGraphicsScene friend class QmlDesigner::FormEditorView; public: - enum PaintMode { - NormalMode, - AnchorMode - }; - FormEditorScene(FormEditorWidget *widget, FormEditorView *editorView); ~FormEditorScene(); FormEditorItem *addFormEditorItem(const QmlItemNode &qmlItemNode); @@ -95,9 +90,6 @@ public: void reparentItem(const QmlItemNode &node, const QmlItemNode &newParent); - PaintMode paintMode() const; - void setPaintMode(PaintMode paintMode); - void clearFormEditorItems(); void highlightBoundingRect(FormEditorItem *formEditorItem); @@ -136,7 +128,6 @@ private: QWeakPointer<LayerItem> m_formLayerItem; QWeakPointer<LayerItem> m_manipulatorLayerItem; ModelNode m_dragNode; - PaintMode m_paintMode; bool m_showBoundingRects; }; diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp index 34a722753e..376af2b922 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp @@ -31,7 +31,6 @@ #include "selectiontool.h" #include "movetool.h" #include "resizetool.h" -#include "anchortool.h" #include "dragtool.h" #include "formeditorview.h" #include "formeditorwidget.h" @@ -66,7 +65,6 @@ FormEditorView::FormEditorView(QObject *parent) m_moveTool(new MoveTool(this)), m_selectionTool(new SelectionTool(this)), m_resizeTool(new ResizeTool(this)), - m_anchorTool(new AnchorTool(this)), m_dragTool(new DragTool(this)), m_currentTool(m_selectionTool), m_transactionCounter(0) @@ -90,8 +88,6 @@ FormEditorView::~FormEditorView() m_moveTool = 0; delete m_resizeTool; m_resizeTool = 0; - delete m_anchorTool; - m_anchorTool = 0; delete m_dragTool; m_dragTool = 0; @@ -174,7 +170,6 @@ void FormEditorView::modelAboutToBeDetached(Model *model) m_selectionTool->clear(); m_moveTool->clear(); m_resizeTool->clear(); - m_anchorTool->clear(); m_dragTool->clear(); m_scene->clearFormEditorItems(); m_formEditorWidget->updateActions(); @@ -296,13 +291,6 @@ void FormEditorView::selectedNodesChanged(const QList<ModelNode> &selectedNodeLi QmlModelView::selectedNodesChanged(selectedNodeList, lastSelectedNodeList); m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedNodeList))); - if (scene()->paintMode() == FormEditorScene::AnchorMode) { - foreach (FormEditorItem *item, m_scene->itemsForQmlItemNodes(toQmlItemNodeList(selectedNodeList))) - item->update(); - - foreach (FormEditorItem *item, m_scene->itemsForQmlItemNodes(toQmlItemNodeList(lastSelectedNodeList))) - item->update(); - } m_scene->update(); } @@ -329,7 +317,6 @@ bool FormEditorView::changeToMoveTool() if (!isMoveToolAvailable()) return false; - scene()->setPaintMode(FormEditorScene::NormalMode); m_scene->updateAllFormEditorItems(); m_currentTool->clear(); m_currentTool = m_moveTool; @@ -343,7 +330,6 @@ void FormEditorView::changeToDragTool() if (m_currentTool == m_dragTool) return; - scene()->setPaintMode(FormEditorScene::NormalMode); m_scene->updateAllFormEditorItems(); m_currentTool->clear(); m_currentTool = m_dragTool; @@ -360,7 +346,6 @@ bool FormEditorView::changeToMoveTool(const QPointF &beginPoint) if (!isMoveToolAvailable()) return false; - scene()->setPaintMode(FormEditorScene::NormalMode); m_scene->updateAllFormEditorItems(); m_currentTool->clear(); m_currentTool = m_moveTool; @@ -375,7 +360,6 @@ void FormEditorView::changeToSelectionTool() if (m_currentTool == m_selectionTool) return; - scene()->setPaintMode(FormEditorScene::NormalMode); m_scene->updateAllFormEditorItems(); m_currentTool->clear(); m_currentTool = m_selectionTool; @@ -388,7 +372,6 @@ void FormEditorView::changeToSelectionTool(QGraphicsSceneMouseEvent *event) if (m_currentTool == m_selectionTool) return; - scene()->setPaintMode(FormEditorScene::NormalMode); m_scene->updateAllFormEditorItems(); m_currentTool->clear(); m_currentTool = m_selectionTool; @@ -403,7 +386,6 @@ void FormEditorView::changeToResizeTool() if (m_currentTool == m_resizeTool) return; - scene()->setPaintMode(FormEditorScene::NormalMode); m_scene->updateAllFormEditorItems(); m_currentTool->clear(); m_currentTool = m_resizeTool; @@ -411,19 +393,6 @@ void FormEditorView::changeToResizeTool() m_currentTool->setItems(scene()->itemsForQmlItemNodes(selectedQmlItemNodes())); } -void FormEditorView::changeToAnchorTool() -{ - if (m_currentTool == m_anchorTool) - return; - - scene()->setPaintMode(FormEditorScene::AnchorMode); - m_scene->updateAllFormEditorItems(); - m_currentTool->clear(); - m_currentTool = m_anchorTool; - m_currentTool->clear(); - m_currentTool->setItems(scene()->itemsForQmlItemNodes(selectedQmlItemNodes())); -} - void FormEditorView::changeToTransformTools() { if (m_currentTool == m_moveTool || @@ -619,17 +588,6 @@ void FormEditorView::actualStateChanged(const ModelNode &node) QmlModelView::actualStateChanged(node); QmlModelState newQmlModelState(node); - - m_formEditorWidget->anchorToolAction()->setEnabled(newQmlModelState.isBaseState()); - - if (!newQmlModelState.isBaseState() && currentTool() == m_anchorTool) { - changeToTransformTools(); - m_formEditorWidget->transformToolAction()->setChecked(true); - } - -// FormEditorItem *item = m_scene->itemForQmlItemNode(fxObjectNode); -// -// m_currentTool->formEditorItemsChanged(itemList); } Utils::CrumblePath *FormEditorView::crumblePath() const @@ -650,7 +608,6 @@ void FormEditorView::delayedReset() m_selectionTool->clear(); m_moveTool->clear(); m_resizeTool->clear(); - m_anchorTool->clear(); m_dragTool->clear(); m_scene->clearFormEditorItems(); if (rootQmlObjectNode().toQmlItemNode().isValid()) diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.h b/src/plugins/qmldesigner/components/formeditor/formeditorview.h index 95c4719928..3830760190 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorview.h +++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.h @@ -53,7 +53,6 @@ class AbstractFormEditorTool; class MoveTool; class SelectionTool; class ResizeTool; -class AnchorTool; class DragTool; class ItemLibraryEntry; class QmlItemNode; @@ -97,7 +96,6 @@ public: void changeToSelectionTool(); void changeToSelectionTool(QGraphicsSceneMouseEvent *event); void changeToResizeTool(); - void changeToAnchorTool(); void changeToTransformTools(); void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex); @@ -143,7 +141,6 @@ private: //variables MoveTool *m_moveTool; SelectionTool *m_selectionTool; ResizeTool *m_resizeTool; - AnchorTool *m_anchorTool; DragTool *m_dragTool; AbstractFormEditorTool *m_currentTool; int m_transactionCounter; diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp index a9292eeb79..085e671512 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp @@ -74,15 +74,6 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view) m_transformToolAction->setIcon(QPixmap(":/icon/tool/transform.png")); connect(m_transformToolAction.data(), SIGNAL(triggered(bool)), SLOT(changeTransformTool(bool))); - m_anchorToolAction = m_toolActionGroup->addAction("Anchor Tool (Press Key W)"); - m_anchorToolAction->setShortcut(Qt::Key_W); - m_anchorToolAction->setShortcutContext(Qt::WidgetWithChildrenShortcut); - m_anchorToolAction->setCheckable(true); - m_anchorToolAction->setIcon(QPixmap(":/icon/tool/anchor.png")); - connect(m_anchorToolAction.data(), SIGNAL(triggered(bool)), SLOT(changeAnchorTool(bool))); - -// addActions(m_toolActionGroup->actions()); -// upperActions.append(m_toolActionGroup->actions()); QActionGroup *layoutActionGroup = new QActionGroup(this); layoutActionGroup->setExclusive(false); @@ -205,12 +196,6 @@ void FormEditorWidget::resetNodeInstanceView() m_formEditorView->emitCustomNotification(QLatin1String("reset QmlPuppet")); } -void FormEditorWidget::changeAnchorTool(bool checked) -{ - if (checked && m_formEditorView->currentState().isBaseState()) - m_formEditorView->changeToAnchorTool(); -} - void FormEditorWidget::wheelEvent(QWheelEvent *event) { if (event->modifiers().testFlag(Qt::ControlModifier)) { @@ -267,11 +252,6 @@ ZoomAction *FormEditorWidget::zoomAction() const return m_zoomAction.data(); } -QAction *FormEditorWidget::anchorToolAction() const -{ - return m_anchorToolAction.data(); -} - QAction *FormEditorWidget::transformToolAction() const { return m_transformToolAction.data(); diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.h b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.h index 4fa01f38da..84b4946280 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.h +++ b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.h @@ -55,7 +55,6 @@ public: FormEditorWidget(FormEditorView *view); ZoomAction *zoomAction() const; - QAction *anchorToolAction() const; QAction *transformToolAction() const; QAction *showBoundingRectAction() const; QAction *selectOnlyContentItemsAction() const; @@ -80,14 +79,12 @@ public: void setFocus(); - protected: void wheelEvent(QWheelEvent *event); QActionGroup *toolActionGroup() const; private slots: void changeTransformTool(bool checked); - void changeAnchorTool(bool checked); void setZoomLevel(double zoomLevel); void changeRootItemWidth(const QString &widthText); void changeRootItemHeight(const QString &heightText); @@ -98,7 +95,6 @@ private: QWeakPointer<FormEditorGraphicsView> m_graphicsView; QWeakPointer<ZoomAction> m_zoomAction; QWeakPointer<ToolBox> m_toolBox; - QWeakPointer<QAction> m_anchorToolAction; QWeakPointer<QAction> m_transformToolAction; QWeakPointer<QActionGroup> m_toolActionGroup; QWeakPointer<QAction> m_snappingAction; |