diff --git a/share/qtcreator/qmljsdebugger/editor/movemanipulator.cpp b/share/qtcreator/qmljsdebugger/editor/movemanipulator.cpp deleted file mode 100644 index a9182fad1856dcac7bbc65cbdfbee4cbaf949708..0000000000000000000000000000000000000000 --- a/share/qtcreator/qmljsdebugger/editor/movemanipulator.cpp +++ /dev/null @@ -1,360 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "movemanipulator.h" -#include "qdeclarativedesignview.h" -//#include "layeritem.h" - -#include <QPointF> -#include <QtDebug> -#include <QColor> -#include <QPen> -#include <QApplication> - -#include <limits> - -namespace QmlViewer { - -MoveManipulator::MoveManipulator(/*LayerItem *layerItem, */QDeclarativeDesignView *view) - : //m_layerItem(layerItem), - m_view(view), - m_isActive(false) -{ -} - -MoveManipulator::~MoveManipulator() -{ - deleteSnapLines(); -} - -QPointF MoveManipulator::beginPoint() const -{ - return m_beginPoint; -} - -QList<QGraphicsItem*> MoveManipulator::itemList() const -{ - return m_itemList; -} - -void MoveManipulator::setItem(QGraphicsItem* item) -{ - QList<QGraphicsItem*> itemList; - itemList.append(item); - - setItems(itemList); -} - -void MoveManipulator::setItems(const QList<QGraphicsItem*> &itemList) -{ - m_itemList = itemList; - - foreach (QGraphicsItem* item, m_itemList) { - //QPointF positionInParentSpace = m_snapper.containerQGraphicsItem()->mapFromScene(m_beginPositionInSceneSpaceHash.value(item)); - //m_beginItemRectHash[item].translate(positionInParentSpace - m_beginPositionHash.value(item)); - qDebug() << item << item->pos(); - m_beginPositionHash.insert(item, item->pos()); - } - -// if (!m_itemList.isEmpty()) { -// if (m_itemList.first()->parentItem()) -// m_snapper.setContainerQGraphicsItem(m_itemList.first()->parentItem()); -// else -// m_snapper.setContainerQGraphicsItem(m_itemList.first()); -// m_snapper.setTransformtionSpaceQGraphicsItem(m_snapper.containerQGraphicsItem()); -// } -} - -void MoveManipulator::updateHashes() -{ -// foreach (QGraphicsItem* item, m_itemList) -// m_beginItemRectHash[item] = item->mapRectToParent(item->qmlItemNode().instanceBoundingRect()); - -// foreach (QGraphicsItem* item, m_itemList) { -// QPointF positionInParentSpace = m_snapper.containerQGraphicsItem()->mapFromScene(m_beginPositionInSceneSpaceHash.value(item)); -// m_beginItemRectHash[item].translate(positionInParentSpace - m_beginPositionHash.value(item)); -// m_beginPositionHash.insert(item, positionInParentSpace); -// } -} - -bool MoveManipulator::itemsCanReparented() const -{ - return true; -} - -void MoveManipulator::begin(const QPointF &beginPoint) -{ - m_isActive = true; - - //m_snapper.updateSnappingLines(m_itemList); - - -// foreach (QGraphicsItem* item, m_itemList) -// m_beginItemRectHash.insert(item, m_snapper.containerQGraphicsItem()->mapRectFromItem(item, item->qmlItemNode().instanceBoundingRect())); - -// foreach (QGraphicsItem* item, m_itemList) { -// QPointF positionInParentSpace(item->qmlItemNode().instancePosition()); -// QPointF positionInScenesSpace = m_snapper.containerQGraphicsItem()->mapToScene(positionInParentSpace); -// m_beginPositionInSceneSpaceHash.insert(item, positionInScenesSpace); -// } - -// foreach (QGraphicsItem* item, m_itemList) { -// QPointF positionInParentSpace = m_snapper.containerQGraphicsItem()->mapFromScene(m_beginPositionInSceneSpaceHash.value(item)); -// m_beginPositionHash.insert(item, positionInParentSpace); - -// QmlAnchors anchors(item->qmlItemNode().anchors()); -// m_beginTopMarginHash.insert(item, anchors.instanceMargin(AnchorLine::Top)); -// m_beginLeftMarginHash.insert(item, anchors.instanceMargin(AnchorLine::Left)); -// m_beginRightMarginHash.insert(item, anchors.instanceMargin(AnchorLine::Right)); -// m_beginBottomMarginHash.insert(item, anchors.instanceMargin(AnchorLine::Bottom)); -// m_beginHorizontalCenterHash.insert(item, anchors.instanceMargin(AnchorLine::HorizontalCenter)); -// m_beginVerticalCenterHash.insert(item, anchors.instanceMargin(AnchorLine::VerticalCenter)); -// } - - m_beginPoint = beginPoint; - -} - -//QPointF MoveManipulator::findSnappingOffset(const QList<QRectF> &boundingRectList) -//{ -// QPointF offset; - -// QMap<double, double> verticalOffsetMap; -// foreach (const QRectF &boundingRect, boundingRectList) { -// double verticalOffset = m_snapper.snappedVerticalOffset(boundingRect); -// if (verticalOffset < std::numeric_limits<double>::max()) -// verticalOffsetMap.insert(qAbs(verticalOffset), verticalOffset); -// } - - -// if (!verticalOffsetMap.isEmpty()) -// offset.rx() = verticalOffsetMap.begin().value(); - - - -// QMap<double, double> horizontalOffsetMap; -// foreach (const QRectF &boundingRect, boundingRectList) { -// double horizontalOffset = m_snapper.snappedHorizontalOffset(boundingRect); -// if (horizontalOffset < std::numeric_limits<double>::max()) -// horizontalOffsetMap.insert(qAbs(horizontalOffset), horizontalOffset); -// } - - -// if (!horizontalOffsetMap.isEmpty()) -// offset.ry() = horizontalOffsetMap.begin().value(); - -// return offset; -//} - -//void MoveManipulator::generateSnappingLines(const QList<QRectF> &boundingRectList) -//{ -// m_graphicsLineList = m_snapper.generateSnappingLines(boundingRectList, -// m_layerItem.data(), -// m_snapper.transformtionSpaceQGraphicsItem()->sceneTransform()); -//} - -QList<QRectF> MoveManipulator::translatedBoundingRects(const QList<QRectF> &boundingRectList, const QPointF& offsetVector) -{ - QList<QRectF> translatedBoundingRectList; - foreach (const QRectF &boundingRect, boundingRectList) - translatedBoundingRectList.append(boundingRect.translated(offsetVector)); - - return translatedBoundingRectList; -} - - - -/* - /brief updates the position of the items. -*/ -void MoveManipulator::update(const QPointF& updatePoint, Snapping /*useSnapping*/, State /*stateToBeManipulated*/) -{ - //deleteSnapLines(); //Since they position is changed and the item is moved the snapping lines are - //are obsolete. The new updated snapping lines (color and visibility) will be - //calculated in snapPoint() called in moveNode() later - - if (m_itemList.isEmpty()) { - return; - } else { - //QPointF updatePointInContainerSpace(m_snapper.containerQGraphicsItem()->mapFromScene(updatePoint)); - //QPointF beginPointInContainerSpace(m_snapper.containerQGraphicsItem()->mapFromScene(m_beginPoint)); - - QPointF offsetVector(updatePoint - m_beginPoint); - -// if (useSnapping == UseSnapping || useSnapping == UseSnappingAndAnchoring) { -// offsetVector -= findSnappingOffset(translatedBoundingRects(m_beginItemRectHash.values(), offsetVector)); -// //generateSnappingLines(translatedBoundingRects(m_beginItemRectHash.values(), offsetVector)); -// } - - foreach (QGraphicsItem* item, m_itemList) { - //qDebug() << "offset:" << m_beginPositionHash.value(item) << offsetVector; - QPointF positionInContainerSpace(m_beginPositionHash.value(item) + offsetVector); - - // don't support anchors for base state because it is not needed by the droptool -// if (stateToBeManipulated == UseActualState) { -// QmlAnchors anchors(item->qmlItemNode().anchors()); - -// if (anchors.instanceHasAnchor(AnchorLine::Top)) { -// anchors.setMargin(AnchorLine::Top, m_beginTopMarginHash.value(item) + offsetVector.y()); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::Left)) { -// anchors.setMargin(AnchorLine::Left, m_beginLeftMarginHash.value(item) + offsetVector.x()); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::Bottom)) { -// anchors.setMargin(AnchorLine::Bottom, m_beginBottomMarginHash.value(item) - offsetVector.y()); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::Right)) { -// anchors.setMargin(AnchorLine::Right, m_beginRightMarginHash.value(item) - offsetVector.x()); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter)) { -// anchors.setMargin(AnchorLine::HorizontalCenter, m_beginHorizontalCenterHash.value(item) + offsetVector.x()); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter)) { -// anchors.setMargin(AnchorLine::VerticalCenter, m_beginVerticalCenterHash.value(item) + offsetVector.y()); -// } - -// item->setPos(positionInContainerSpace); -// } else { -// item->qmlItemNode().modelNode().variantProperty("x").setValue(qRound(positionInContainerSpace.x())); -// item->qmlItemNode().modelNode().variantProperty("y").setValue(qRound(positionInContainerSpace.y())); -// } - item->setPos(positionInContainerSpace); - } - } -} - -void MoveManipulator::clear() -{ - deleteSnapLines(); - m_beginItemRectHash.clear(); - m_beginPositionHash.clear(); - m_beginPositionInSceneSpaceHash.clear(); - m_itemList.clear(); - - m_beginTopMarginHash.clear(); - m_beginLeftMarginHash.clear(); - m_beginRightMarginHash.clear(); - m_beginBottomMarginHash.clear(); - m_beginHorizontalCenterHash.clear(); - m_beginVerticalCenterHash.clear(); -} - -void MoveManipulator::reparentTo(QGraphicsItem *newParent) -{ - deleteSnapLines(); - - if (!newParent) - return; - - if (!itemsCanReparented()) - return; - -// foreach (QGraphicsItem* item, m_itemList) { -// QmlItemNode parent(newParent->qmlItemNode()); -// if (parent.isValid()) { -// item->qmlItemNode().setParentProperty(parent.nodeAbstractProperty("data")); -// } -// } - -// m_snapper.setContainerQGraphicsItem(newParent); -// m_snapper.setTransformtionSpaceQGraphicsItem(m_snapper.containerQGraphicsItem()); -// m_snapper.updateSnappingLines(m_itemList); - - updateHashes(); -} - - -void MoveManipulator::end(const QPointF &/*endPoint*/) -{ - m_isActive = false; - deleteSnapLines(); - - clear(); -} - -void MoveManipulator::moveBy(double deltaX, double deltaY) -{ - foreach (QGraphicsItem* item, m_itemList) { -// QmlAnchors anchors(item->qmlItemNode().anchors()); - -// if (anchors.instanceHasAnchor(AnchorLine::Top)) { -// anchors.setMargin(AnchorLine::Top, anchors.instanceMargin(AnchorLine::Top) + deltaY); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::Left)) { -// anchors.setMargin(AnchorLine::Left, anchors.instanceMargin(AnchorLine::Left) + deltaX); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::Bottom)) { -// anchors.setMargin(AnchorLine::Bottom, anchors.instanceMargin(AnchorLine::Bottom) - deltaY); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::Right)) { -// anchors.setMargin(AnchorLine::Right, anchors.instanceMargin(AnchorLine::Right) - deltaX); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter)) { -// anchors.setMargin(AnchorLine::HorizontalCenter, anchors.instanceMargin(AnchorLine::HorizontalCenter) + deltaX); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter)) { -// anchors.setMargin(AnchorLine::VerticalCenter, anchors.instanceMargin(AnchorLine::VerticalCenter) + deltaY); -// } - - item->moveBy(deltaX, deltaY); - } -} - -void MoveManipulator::setOpacityForAllElements(qreal opacity) -{ - foreach (QGraphicsItem* item, m_itemList) - item->setOpacity(opacity); -} - -void MoveManipulator::deleteSnapLines() -{ -// if (m_layerItem) { -// foreach (QGraphicsItem *item, m_graphicsLineList) -// m_layerItem->scene()->removeItem(item); -// } -// m_graphicsLineList.clear(); -// m_view->scene()->update(); -} - -bool MoveManipulator::isActive() const -{ - return m_isActive; -} - -} diff --git a/share/qtcreator/qmljsdebugger/editor/movemanipulator.h b/share/qtcreator/qmljsdebugger/editor/movemanipulator.h deleted file mode 100644 index f09a743624969b705f10bdd9f92deb473a699e71..0000000000000000000000000000000000000000 --- a/share/qtcreator/qmljsdebugger/editor/movemanipulator.h +++ /dev/null @@ -1,116 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef MOVEMANIPULATOR_H -#define MOVEMANIPULATOR_H - -#include <QWeakPointer> -#include <QGraphicsItem> -#include <QGraphicsLineItem> -#include <QHash> -#include <QPointF> -#include <QRectF> - -//#include "snapper.h" -//#include "formeditorview.h" - -namespace QmlViewer { - -class QDeclarativeDesignView; - -class MoveManipulator -{ -public: - enum Snapping { - UseSnapping, - UseSnappingAndAnchoring, - NoSnapping - }; - - enum State { - UseActualState, - UseBaseState - }; - - MoveManipulator(/*LayerItem *layerItem, */QDeclarativeDesignView *view); - ~MoveManipulator(); - QList<QGraphicsItem*> itemList() const; - void setItems(const QList<QGraphicsItem*> &itemList); - void setItem(QGraphicsItem* item); - - void begin(const QPointF& beginPoint); - void update(const QPointF& updatePoint, Snapping useSnapping, State stateToBeManipulated = UseActualState); - void reparentTo(QGraphicsItem *newParent); - void end(const QPointF& endPoint); - - void moveBy(double deltaX, double deltaY); - - QPointF beginPoint() const; - - void clear(); - - bool isActive() const; - -protected: - void setOpacityForAllElements(qreal opacity); - - //QPointF findSnappingOffset(const QList<QRectF> &boundingRectList); - void deleteSnapLines(); - - QList<QRectF> translatedBoundingRects(const QList<QRectF> &boundingRectList, const QPointF& offset); - QPointF calculateBoundingRectMovementOffset(const QPointF& updatePoint); - QRectF boundingRect(QGraphicsItem* item, const QPointF& updatePoint); - - //void generateSnappingLines(const QList<QRectF> &boundingRectList); - void updateHashes(); - - bool itemsCanReparented() const; - -private: - //Snapper m_snapper; - //QWeakPointer<LayerItem> m_layerItem; - QWeakPointer<QDeclarativeDesignView> m_view; - QList<QGraphicsItem*> m_itemList; - QHash<QGraphicsItem*, QRectF> m_beginItemRectHash; - QHash<QGraphicsItem*, QPointF> m_beginPositionHash; - QHash<QGraphicsItem*, QPointF> m_beginPositionInSceneSpaceHash; - QPointF m_beginPoint; - QHash<QGraphicsItem*, double> m_beginTopMarginHash; - QHash<QGraphicsItem*, double> m_beginLeftMarginHash; - QHash<QGraphicsItem*, double> m_beginRightMarginHash; - QHash<QGraphicsItem*, double> m_beginBottomMarginHash; - QHash<QGraphicsItem*, double> m_beginHorizontalCenterHash; - QHash<QGraphicsItem*, double> m_beginVerticalCenterHash; - QList<QGraphicsItem*> m_graphicsLineList; - bool m_isActive; -}; - -} - -#endif // MOVEMANIPULATOR_H diff --git a/share/qtcreator/qmljsdebugger/editor/movetool.cpp b/share/qtcreator/qmljsdebugger/editor/movetool.cpp deleted file mode 100644 index 20377c10ddb70d5125dfe001790bc1919ccd25ae..0000000000000000000000000000000000000000 --- a/share/qtcreator/qmljsdebugger/editor/movetool.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "movetool.h" - -#include "resizehandleitem.h" -#include "qdeclarativedesignview.h" - -#include <QApplication> -#include <QWheelEvent> -#include <QAction> -#include <QMouseEvent> -#include <QtDebug> - -namespace QmlViewer { - -MoveTool::MoveTool(QDeclarativeDesignView *editorView) - : AbstractFormEditorTool(editorView), - m_moving(false), - m_moveManipulator(editorView), - m_selectionIndicator(editorView->manipulatorLayer()), - m_resizeIndicator(editorView->manipulatorLayer()) -{ - -} - - -MoveTool::~MoveTool() -{ - -} - -void MoveTool::clear() -{ - view()->clearHighlightBoundingRect(); - view()->setCursor(Qt::SizeAllCursor); - m_moveManipulator.clear(); - m_movingItems.clear(); - m_resizeIndicator.clear(); - m_selectionIndicator.clear(); -} - -void MoveTool::mousePressEvent(QMouseEvent *event) -{ - QList<QGraphicsItem*> itemList = view()->selectableItems(event->pos()); - - if (event->buttons() & Qt::LeftButton) { - m_moving = true; - - if (itemList.isEmpty()) { - view()->changeTool(Constants::SelectionToolMode); - return; - } - - m_movingItems = movingItems(items()); - if (m_movingItems.isEmpty()) - return; - - m_moveManipulator.setItems(m_movingItems); - - m_moveManipulator.begin(event->pos()); - } else if (event->buttons() & Qt::RightButton) { - view()->changeTool(Constants::SelectionToolMode); - } - -} - -void MoveTool::mouseMoveEvent(QMouseEvent *event) -{ - if (m_movingItems.isEmpty()) - return; - - if (event->buttons() & Qt::LeftButton) { - - m_selectionIndicator.hide(); - m_resizeIndicator.hide(); - -// QGraphicsItem *containerItem = containerQGraphicsItem(itemList, m_movingItems); -// if (containerItem -// && view()->currentState().isBaseState()) { -// if (containerItem != m_movingItems.first()->parentItem() -// && event->modifiers().testFlag(Qt::ShiftModifier)) { -// m_moveManipulator.reparentTo(containerItem); -// } -// } -// bool shouldSnapping = view()->widget()->snappingAction()->isChecked(); -// bool shouldSnappingAndAnchoring = view()->widget()->snappingAndAnchoringAction()->isChecked(); -// MoveManipulator::Snapping useSnapping = MoveManipulator::NoSnapping; -// if (event->modifiers().testFlag(Qt::ControlModifier) != (shouldSnapping || shouldSnappingAndAnchoring)) { -// if (shouldSnappingAndAnchoring) -// useSnapping = MoveManipulator::UseSnappingAndAnchoring; -// else -// useSnapping = MoveManipulator::UseSnapping; -// } - - m_moveManipulator.update(event->pos(), MoveManipulator::NoSnapping); - } -} - -void MoveTool::mouseReleaseEvent(QMouseEvent *event) -{ - if (m_movingItems.isEmpty()) - return; - - if (m_moving) { - QLineF moveVector(event->pos(), m_moveManipulator.beginPoint()); - if (moveVector.length() < QApplication::startDragDistance()) - { - QPointF beginPoint(m_moveManipulator.beginPoint()); - - m_moveManipulator.end(beginPoint); - - m_selectionIndicator.show(); - m_resizeIndicator.show(); - m_movingItems.clear(); - view()->changeTool(Constants::SelectionToolMode, - Constants::UseCursorPos); - } else { - m_moveManipulator.end(event->pos()); - - m_selectionIndicator.show(); - m_resizeIndicator.show(); - m_movingItems.clear(); - } - qDebug() << "releasing"; - view()->changeTool(Constants::ResizeToolMode); - } - - m_moving = false; - - qDebug() << "released"; -} - - -void MoveTool::hoverMoveEvent(QMouseEvent *event) -{ - QList<QGraphicsItem*> itemList = view()->items(event->pos()); - - if (itemList.isEmpty()) { - view()->changeTool(Constants::SelectionToolMode); - return; - } - - ResizeHandleItem* resizeHandle = ResizeHandleItem::fromGraphicsItem(itemList.first()); - if (resizeHandle) { - view()->changeTool(Constants::ResizeToolMode); - return; - } - - QList<QGraphicsItem*> selectableItemList = view()->selectableItems(event->pos()); - if (!topSelectedItemIsMovable(selectableItemList)) { - view()->changeTool(Constants::SelectionToolMode); - return; - } -} - -void MoveTool::keyPressEvent(QKeyEvent *event) -{ - switch(event->key()) { - case Qt::Key_Shift: - case Qt::Key_Alt: - case Qt::Key_Control: - case Qt::Key_AltGr: - event->setAccepted(false); - return; - } - - double moveStep = 1.0; - - if (event->modifiers().testFlag(Qt::ShiftModifier)) - moveStep = 10.0; - - if (!event->isAutoRepeat()) { - QList<QGraphicsItem*> movableItems(movingItems(items())); - if (movableItems.isEmpty()) - return; - - m_moveManipulator.setItems(movableItems); - m_selectionIndicator.hide(); - m_resizeIndicator.hide(); - } - - switch(event->key()) { - case Qt::Key_Left: m_moveManipulator.moveBy(-moveStep, 0.0); break; - case Qt::Key_Right: m_moveManipulator.moveBy(moveStep, 0.0); break; - case Qt::Key_Up: m_moveManipulator.moveBy(0.0, -moveStep); break; - case Qt::Key_Down: m_moveManipulator.moveBy(0.0, moveStep); break; - } - - -} - -void MoveTool::keyReleaseEvent(QKeyEvent *keyEvent) -{ - switch(keyEvent->key()) { - case Qt::Key_Shift: - case Qt::Key_Alt: - case Qt::Key_Control: - case Qt::Key_AltGr: - keyEvent->setAccepted(false); - return; - } - - if (!keyEvent->isAutoRepeat()) { - m_moveManipulator.clear(); - m_selectionIndicator.show(); - m_resizeIndicator.show(); - } -} - -void MoveTool::wheelEvent(QWheelEvent */*event*/) -{ - -} - -void MoveTool::mouseDoubleClickEvent(QMouseEvent * /*event*/) -{ - -} - -void MoveTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &removedItemList) -{ - foreach (QGraphicsItem* removedItem, removedItemList) - m_movingItems.removeOne(removedItem); -} - -void MoveTool::selectedItemsChanged(const QList<QGraphicsItem*> &itemList) -{ - m_selectionIndicator.setItems(toGraphicsObjectList(itemList)); - m_resizeIndicator.setItems(toGraphicsObjectList(itemList)); - updateMoveManipulator(); -} - -bool MoveTool::haveSameParent(const QList<QGraphicsItem*> &itemList) -{ - if (itemList.isEmpty()) - return false; - - QGraphicsItem *firstParent = itemList.first()->parentItem(); - foreach (QGraphicsItem* item, itemList) - { - if (firstParent != item->parentItem()) - return false; - } - - return true; -} - -bool MoveTool::isAncestorOfAllItems(QGraphicsItem* maybeAncestorItem, - const QList<QGraphicsItem*> &itemList) -{ - foreach (QGraphicsItem* item, itemList) - { - if (!maybeAncestorItem->isAncestorOf(item) && item != maybeAncestorItem) - return false; - } - - return true; -} - - -QGraphicsItem* MoveTool::ancestorIfOtherItemsAreChild(const QList<QGraphicsItem*> &itemList) -{ - if (itemList.isEmpty()) - return 0; - - - foreach (QGraphicsItem* item, itemList) - { - if (isAncestorOfAllItems(item, itemList)) - return item; - } - - return 0; -} - -void MoveTool::updateMoveManipulator() -{ - if (m_moveManipulator.isActive()) - return; -} - -void MoveTool::beginWithPoint(const QPointF &beginPoint) -{ - m_movingItems = movingItems(items()); - if (m_movingItems.isEmpty()) - return; - - m_moving = true; - m_moveManipulator.setItems(m_movingItems); - m_moveManipulator.begin(beginPoint); -} - -//static bool isNotAncestorOfItemInList(QGraphicsItem *graphicsItem, const QList<QGraphicsItem*> &itemList) -//{ -// foreach (QGraphicsItem *item, itemList) { -// if (item->qmlItemNode().isAncestorOf(graphicsItem->qmlItemNode())) -// return false; -// } - -// return true; -//} - -//QGraphicsItem* MoveTool::containerQGraphicsItem(const QList<QGraphicsItem*> &itemUnderMouseList, -// const QList<QGraphicsItem*> &selectedItemList) -//{ -// Q_ASSERT(!selectedItemList.isEmpty()); - -// foreach (QGraphicsItem* item, itemUnderMouseList) { -// QGraphicsItem *QGraphicsItem = QGraphicsItem::fromQGraphicsItem(item); -// if (QGraphicsItem -// && !selectedItemList.contains(QGraphicsItem) -// && isNotAncestorOfItemInList(QGraphicsItem, selectedItemList)) -// return QGraphicsItem; - -// } - -// return 0; -//} - - -QList<QGraphicsItem*> MoveTool::movingItems(const QList<QGraphicsItem*> &selectedItemList) -{ - QGraphicsItem* ancestorItem = ancestorIfOtherItemsAreChild(selectedItemList); - -// if (ancestorItem != 0 && ancestorItem->qmlItemNode().isRootNode()) { -// view()->changeTool(QDeclarativeDesignView::SelectionToolMode); -// return QList<QGraphicsItem*>(); -// } - - if (ancestorItem != 0 && ancestorItem->parentItem() != 0) { - QList<QGraphicsItem*> ancestorItemList; - ancestorItemList.append(ancestorItem); - return ancestorItemList; - } - - if (!haveSameParent(selectedItemList)) { - view()->changeTool(Constants::SelectionToolMode); - return QList<QGraphicsItem*>(); - } - - return selectedItemList; -} - -void MoveTool::graphicsObjectsChanged(const QList<QGraphicsObject*> &itemList) -{ - m_selectionIndicator.updateItems(itemList); - m_resizeIndicator.updateItems(itemList); -} - -} diff --git a/share/qtcreator/qmljsdebugger/editor/movetool.h b/share/qtcreator/qmljsdebugger/editor/movetool.h deleted file mode 100644 index 7514cf686646b193957def6b71e43f09e55d6add..0000000000000000000000000000000000000000 --- a/share/qtcreator/qmljsdebugger/editor/movetool.h +++ /dev/null @@ -1,91 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef MOVETOOL_H -#define MOVETOOL_H - -#include "abstractformeditortool.h" -#include "movemanipulator.h" -#include "resizeindicator.h" -#include "selectionindicator.h" -#include <QHash> - -namespace QmlViewer { - -class MoveTool : public AbstractFormEditorTool -{ -public: - MoveTool(QDeclarativeDesignView* editorView); - ~MoveTool(); - - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); - void hoverMoveEvent(QMouseEvent *event); - - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *keyEvent); - void wheelEvent(QWheelEvent *event); - - void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList); - - void selectedItemsChanged(const QList<QGraphicsItem*> &itemList); - - void updateMoveManipulator(); - - void beginWithPoint(const QPointF &beginPoint); - - void clear(); - - void graphicsObjectsChanged(const QList<QGraphicsObject*> &itemList); - -protected: - static bool haveSameParent(const QList<QGraphicsItem*> &itemList); - - QList<QGraphicsItem*> movingItems(const QList<QGraphicsItem*> &selectedItemList); - - static QGraphicsItem* containerFormEditorItem(const QList<QGraphicsItem*> &itemUnderMouseList, - const QList<QGraphicsItem*> &selectedItemList); - - static bool isAncestorOfAllItems(QGraphicsItem* maybeAncestorItem, - const QList<QGraphicsItem*> &itemList); - static QGraphicsItem* ancestorIfOtherItemsAreChild(const QList<QGraphicsItem*> &itemList); - -private: - bool m_moving; - MoveManipulator m_moveManipulator; - SelectionIndicator m_selectionIndicator; - ResizeIndicator m_resizeIndicator; - QList<QGraphicsItem*> m_movingItems; -}; - -} - -#endif // MOVETOOL_H diff --git a/share/qtcreator/qmljsdebugger/editor/resize_handle.png b/share/qtcreator/qmljsdebugger/editor/resize_handle.png deleted file mode 100644 index 2934f25b7436ea36065f0ef5c249db9e87b04906..0000000000000000000000000000000000000000 Binary files a/share/qtcreator/qmljsdebugger/editor/resize_handle.png and /dev/null differ diff --git a/share/qtcreator/qmljsdebugger/editor/resizecontroller.cpp b/share/qtcreator/qmljsdebugger/editor/resizecontroller.cpp deleted file mode 100644 index 27e5daf9176c14565b36e745d95dad5966268770..0000000000000000000000000000000000000000 --- a/share/qtcreator/qmljsdebugger/editor/resizecontroller.cpp +++ /dev/null @@ -1,293 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "resizecontroller.h" -#include "layeritem.h" - -#include <resizehandleitem.h> -#include <QCursor> -#include <QGraphicsScene> -#include <QGraphicsItem> - -#include <QDebug> - -namespace QmlViewer { - -ResizeControllerData::ResizeControllerData(LayerItem *layerItem, QGraphicsObject *formEditorItem) - : - layerItem(layerItem), - formEditorItem(formEditorItem), - topLeftItem(0), - topRightItem(0), - bottomLeftItem(0), - bottomRightItem(0), - topItem(0), - leftItem(0), - rightItem(0), - bottomItem(0) -{ - -} - -ResizeControllerData::~ResizeControllerData() -{ - clear(); -} - -void ResizeControllerData::clear() -{ - if (!formEditorItem.isNull() && topLeftItem) { - formEditorItem.data()->scene()->removeItem(topLeftItem); - formEditorItem.data()->scene()->removeItem(topRightItem); - formEditorItem.data()->scene()->removeItem(bottomLeftItem); - formEditorItem.data()->scene()->removeItem(bottomRightItem); - formEditorItem.data()->scene()->removeItem(topItem); - formEditorItem.data()->scene()->removeItem(leftItem); - formEditorItem.data()->scene()->removeItem(rightItem); - formEditorItem.data()->scene()->removeItem(bottomItem); - formEditorItem.clear(); - layerItem.clear(); - topLeftItem = 0; - topRightItem = 0; - bottomLeftItem = 0; - bottomRightItem = 0; - topItem = 0; - leftItem = 0; - rightItem = 0; - bottomItem = 0; - } -} - -ResizeController::ResizeController() - : m_data(new ResizeControllerData(0, 0)) -{ - -} - -ResizeController::~ResizeController() -{ - delete m_data; - m_data = 0; -} - -void ResizeController::setItem(LayerItem *layerItem, QGraphicsObject *item) -{ - createFor(layerItem, item); -} - -ResizeController::ResizeController(LayerItem *layerItem, QGraphicsObject *formEditorItem) : - m_data(new ResizeControllerData(layerItem, formEditorItem)) -{ - createFor(layerItem, formEditorItem); -} - -void ResizeController::createFor(LayerItem *layerItem, QGraphicsObject *formEditorItem) -{ - if (m_data) - m_data->clear(); - else - m_data = new ResizeControllerData(layerItem, formEditorItem); - - m_data->formEditorItem = formEditorItem; - m_data->layerItem = layerItem; - - m_data->topLeftItem = new ResizeHandleItem(layerItem, this); - m_data->topLeftItem->setZValue(3020); - m_data->topLeftItem->setCustomCursor(Qt::SizeFDiagCursor); - - m_data->topRightItem = new ResizeHandleItem(layerItem, this); - m_data->topRightItem->setZValue(3010); - m_data->topRightItem->setCustomCursor(Qt::SizeBDiagCursor); - - m_data->bottomLeftItem = new ResizeHandleItem(layerItem, this); - m_data->bottomLeftItem->setZValue(3010); - m_data->bottomLeftItem->setCustomCursor(Qt::SizeBDiagCursor); - - m_data->bottomRightItem = new ResizeHandleItem(layerItem, this); - m_data->bottomRightItem->setZValue(3050); - m_data->bottomRightItem->setCustomCursor(Qt::SizeFDiagCursor); - - m_data->topItem = new ResizeHandleItem(layerItem, this); - m_data->topItem->setZValue(3000); - m_data->topItem->setCustomCursor(Qt::SizeVerCursor); - - m_data->leftItem = new ResizeHandleItem(layerItem, this); - m_data->leftItem->setZValue(3000); - m_data->leftItem->setCustomCursor(Qt::SizeHorCursor); - - m_data->rightItem = new ResizeHandleItem(layerItem, this); - m_data->rightItem->setZValue(3000); - m_data->rightItem->setCustomCursor(Qt::SizeHorCursor); - - m_data->bottomItem = new ResizeHandleItem(layerItem, this); - m_data->bottomItem->setZValue(3000); - m_data->bottomItem->setCustomCursor(Qt::SizeVerCursor); - - updatePosition(); -} - -bool ResizeController::isValid() const -{ - return !m_data->formEditorItem.isNull(); -} - -void ResizeController::show() -{ - updatePosition(); - - m_data->topLeftItem->show(); - m_data->topRightItem->show(); - m_data->bottomLeftItem->show(); - m_data->bottomRightItem->show(); - m_data->topItem->show(); - m_data->leftItem->show(); - m_data->rightItem->show(); - m_data->bottomItem->show(); -} -void ResizeController::hide() -{ - m_data->topLeftItem->hide(); - m_data->topRightItem->hide(); - m_data->bottomLeftItem->hide(); - m_data->bottomRightItem->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()); -} - - -void ResizeController::updatePosition() -{ - QGraphicsItem *formEditorItem = m_data->formEditorItem.data(); - QRectF boundingRect =formEditorItem->boundingRect(); - QPointF topLeftPointInLayerSpace(m_data->formEditorItem->mapToItem(m_data->layerItem.data(), - boundingRect.topLeft())); - QPointF topRightPointInLayerSpace(m_data->formEditorItem->mapToItem(m_data->layerItem.data(), - boundingRect.topRight())); - QPointF bottomLeftPointInLayerSpace(m_data->formEditorItem->mapToItem(m_data->layerItem.data(), - boundingRect.bottomLeft())); - QPointF bottomRightPointInLayerSpace(m_data->formEditorItem->mapToItem(m_data->layerItem.data(), - boundingRect.bottomRight())); - - QPointF topPointInLayerSpace(m_data->formEditorItem->mapToItem(m_data->layerItem.data(), - topCenter(boundingRect))); - QPointF leftPointInLayerSpace(m_data->formEditorItem->mapToItem(m_data->layerItem.data(), - leftCenter(boundingRect))); - - QPointF rightPointInLayerSpace(m_data->formEditorItem->mapToItem(m_data->layerItem.data(), - rightCenter(boundingRect))); - QPointF bottomPointInLayerSpace(m_data->formEditorItem->mapToItem(m_data->layerItem.data(), - bottomCenter(boundingRect))); - - - m_data->topRightItem->setHandlePosition(topRightPointInLayerSpace, boundingRect.topRight()); - m_data->topLeftItem->setHandlePosition(topLeftPointInLayerSpace, boundingRect.topLeft()); - m_data->bottomLeftItem->setHandlePosition(bottomLeftPointInLayerSpace, boundingRect.bottomLeft()); - m_data->bottomRightItem->setHandlePosition(bottomRightPointInLayerSpace, boundingRect.bottomRight()); - m_data->topItem->setHandlePosition(topPointInLayerSpace, topCenter(boundingRect)); - m_data->leftItem->setHandlePosition(leftPointInLayerSpace, leftCenter(boundingRect)); - m_data->rightItem->setHandlePosition(rightPointInLayerSpace, rightCenter(boundingRect)); - m_data->bottomItem->setHandlePosition(bottomPointInLayerSpace, bottomCenter(boundingRect)); - -} - - -QGraphicsObject* ResizeController::formEditorItem() const -{ - return m_data->formEditorItem.data(); -} - -ResizeControllerData *ResizeController::data() const -{ - return m_data; -} - -bool ResizeController::isTopLeftHandle(const ResizeHandleItem *handle) const -{ - return handle == m_data->topLeftItem; -} - -bool ResizeController::isTopRightHandle(const ResizeHandleItem *handle) const -{ - return handle == m_data->topRightItem; -} - -bool ResizeController::isBottomLeftHandle(const ResizeHandleItem *handle) const -{ - return handle == m_data->bottomLeftItem; -} - -bool ResizeController::isBottomRightHandle(const ResizeHandleItem *handle) const -{ - return handle == m_data->bottomRightItem; -} - -bool ResizeController::isTopHandle(const ResizeHandleItem *handle) const -{ - return handle == m_data->topItem; -} - -bool ResizeController::isLeftHandle(const ResizeHandleItem *handle) const -{ - return handle == m_data->leftItem; -} - -bool ResizeController::isRightHandle(const ResizeHandleItem *handle) const -{ - return handle == m_data->rightItem; -} - -bool ResizeController::isBottomHandle(const ResizeHandleItem *handle) const -{ - return handle == m_data->bottomItem; -} - -} diff --git a/share/qtcreator/qmljsdebugger/editor/resizecontroller.h b/share/qtcreator/qmljsdebugger/editor/resizecontroller.h deleted file mode 100644 index 6b21419570990dc83fd859887f37aa917ad0bb85..0000000000000000000000000000000000000000 --- a/share/qtcreator/qmljsdebugger/editor/resizecontroller.h +++ /dev/null @@ -1,106 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef RESIZECONTROLLER_H -#define RESIZECONTROLLER_H - -#include <QWeakPointer> -#include <QSharedPointer> -#include <QGraphicsItem> -#include <QGraphicsObject> - -namespace QmlViewer { - -class LayerItem; -class ResizeHandleItem; - -class ResizeControllerData -{ -public: - ResizeControllerData(LayerItem *layerItem, - QGraphicsObject *formEditorItem); - //ResizeControllerData(const ResizeControllerData &other); - ~ResizeControllerData(); - void clear(); - - QWeakPointer<LayerItem> layerItem; - QWeakPointer<QGraphicsObject> formEditorItem; - ResizeHandleItem *topLeftItem; - ResizeHandleItem *topRightItem; - ResizeHandleItem *bottomLeftItem; - ResizeHandleItem *bottomRightItem; - ResizeHandleItem *topItem; - ResizeHandleItem *leftItem; - ResizeHandleItem *rightItem; - ResizeHandleItem *bottomItem; -}; - - - - -class ResizeController -{ -public: - friend class ResizeHandleItem; - - ResizeController(); - ~ResizeController(); - ResizeController(LayerItem *layerItem, QGraphicsObject *formEditorItem); - - void show(); - void hide(); - void setItem(LayerItem *layerItem, QGraphicsObject *item); - - void updatePosition(); - - bool isValid() const; - - QGraphicsObject *formEditorItem() const; - - bool isTopLeftHandle(const ResizeHandleItem *handle) const; - bool isTopRightHandle(const ResizeHandleItem *handle) const; - bool isBottomLeftHandle(const ResizeHandleItem *handle) const; - bool isBottomRightHandle(const ResizeHandleItem *handle) const; - - bool isTopHandle(const ResizeHandleItem *handle) const; - bool isLeftHandle(const ResizeHandleItem *handle) const; - bool isRightHandle(const ResizeHandleItem *handle) const; - bool isBottomHandle(const ResizeHandleItem *handle) const; - -private: // functions - void createFor(LayerItem *layerItem, QGraphicsObject *formEditorItem); - ResizeControllerData *data() const; - -private: // variables - ResizeControllerData *m_data; -}; - -} - -#endif // RESIZECONTROLLER_H diff --git a/share/qtcreator/qmljsdebugger/editor/resizehandleitem.cpp b/share/qtcreator/qmljsdebugger/editor/resizehandleitem.cpp deleted file mode 100644 index 88d50b4650c13848076f819fbb46b98764b80e7c..0000000000000000000000000000000000000000 --- a/share/qtcreator/qmljsdebugger/editor/resizehandleitem.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "resizehandleitem.h" - -#include <QCursor> - -namespace QmlViewer { - -ResizeHandleItem::ResizeHandleItem(QGraphicsItem *parent, ResizeController *resizeController) - : QGraphicsPixmapItem(QPixmap(":/editor/handle/resize_handle.png"), parent), - m_resizeController(resizeController) -{ - setShapeMode(QGraphicsPixmapItem::BoundingRectShape); - setOffset(-pixmap().rect().center()); - setFlag(QGraphicsItem::ItemIsMovable, true); - setFlag(QGraphicsItem::ItemIgnoresTransformations, true); -} - -void ResizeHandleItem::setHandlePosition(const QPointF & globalPosition, const QPointF & itemSpacePosition) -{ - m_itemSpacePosition = itemSpacePosition; - setPos(globalPosition); -} - -QRectF ResizeHandleItem::boundingRect() const -{ - return QGraphicsPixmapItem::boundingRect().adjusted(-1, -1, 1, 1); -} - -QPainterPath ResizeHandleItem::shape() const -{ - return QGraphicsItem::shape(); -} - -ResizeController * ResizeHandleItem::resizeController() const -{ - return m_resizeController; -} - -ResizeHandleItem* ResizeHandleItem::fromGraphicsItem(QGraphicsItem *item) -{ - return qgraphicsitem_cast<ResizeHandleItem*>(item); -} - -bool ResizeHandleItem::isTopLeftHandle() const -{ - return resizeController()->isTopLeftHandle(this); -} - -bool ResizeHandleItem::isTopRightHandle() const -{ - return resizeController()->isTopRightHandle(this); -} - -bool ResizeHandleItem::isBottomLeftHandle() const -{ - return resizeController()->isBottomLeftHandle(this); -} - -bool ResizeHandleItem::isBottomRightHandle() const -{ - return resizeController()->isBottomRightHandle(this); -} - -bool ResizeHandleItem::isTopHandle() const -{ - return resizeController()->isTopHandle(this); -} - -bool ResizeHandleItem::isLeftHandle() const -{ - return resizeController()->isLeftHandle(this); -} - -bool ResizeHandleItem::isRightHandle() const -{ - return resizeController()->isRightHandle(this); -} - -bool ResizeHandleItem::isBottomHandle() const -{ - return resizeController()->isBottomHandle(this); -} - -QPointF ResizeHandleItem::itemSpacePosition() const -{ - return m_itemSpacePosition; -} - -QCursor ResizeHandleItem::customCursor() const -{ - return m_customCursor; -} -void ResizeHandleItem::setCustomCursor(const QCursor &cursor) -{ - m_customCursor = cursor; -} - -} diff --git a/share/qtcreator/qmljsdebugger/editor/resizehandleitem.h b/share/qtcreator/qmljsdebugger/editor/resizehandleitem.h deleted file mode 100644 index d036590d210a5e03c87378b21dd43123c5a67c28..0000000000000000000000000000000000000000 --- a/share/qtcreator/qmljsdebugger/editor/resizehandleitem.h +++ /dev/null @@ -1,95 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef RESIZEHANDLEITEM_H -#define RESIZEHANDLEITEM_H - -#include <QGraphicsPixmapItem> -#include <QCursor> - -#include "resizecontroller.h" - -namespace QmlViewer { - -class ResizeHandleItem : public QGraphicsPixmapItem -{ -public: - enum - { - Type = 0xEAEA - }; - - - ResizeHandleItem(QGraphicsItem *parent, ResizeController *resizeController); - - void setHandlePosition(const QPointF & globalPosition, const QPointF & itemSpacePosition); - - int type() const; - QRectF boundingRect() const; - QPainterPath shape() const; - -<<<<<<< HEAD:src/tools/qml/qmlobserver/editor/resizehandleitem.h - ResizeController * resizeController() const; -======= - virtual bool initialize(const QStringList &arguments, QString *errorString); - virtual void extensionsInitialized(); - virtual ShutdownFlag aboutToShutdown(); ->>>>>>> 9eba87bd92aa2de00e2c191119bc9a9e015e1de5:src/plugins/qmlinspector/qmlinspectorplugin.h - - static ResizeHandleItem* fromGraphicsItem(QGraphicsItem *item); - - bool isTopLeftHandle() const; - bool isTopRightHandle() const; - bool isBottomLeftHandle() const; - bool isBottomRightHandle() const; - - bool isTopHandle() const; - bool isLeftHandle() const; - bool isRightHandle() const; - bool isBottomHandle() const; - - QPointF itemSpacePosition() const; - QCursor customCursor() const; - void setCustomCursor(const QCursor &cursor); - -private: - ResizeController *m_resizeController; - QPointF m_itemSpacePosition; - QCursor m_customCursor; - -}; - -inline int ResizeHandleItem::type() const -{ - return Type; -} - -} - -#endif // RESIZEHANDLEITEM_H diff --git a/share/qtcreator/qmljsdebugger/editor/resizeindicator.cpp b/share/qtcreator/qmljsdebugger/editor/resizeindicator.cpp deleted file mode 100644 index 62a7eb29cffc69b640a7d81ec9e1ca9d859f6b52..0000000000000000000000000000000000000000 --- a/share/qtcreator/qmljsdebugger/editor/resizeindicator.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "resizeindicator.h" -#include "layeritem.h" - -#include <QGraphicsObject> - -namespace QmlViewer { - -ResizeIndicator::ResizeIndicator(LayerItem *layerItem) - : m_layerItem(layerItem) -{ - -} - -ResizeIndicator::~ResizeIndicator() -{ - m_itemControllerHash.clear(); -} - -void ResizeIndicator::show() -{ - QHashIterator<QGraphicsObject*, ResizeController*> itemControllerIterator(m_itemControllerHash); - while (itemControllerIterator.hasNext()) { - ResizeController *controller = itemControllerIterator.next().value(); - controller->show(); - } -} -void ResizeIndicator::hide() -{ - QHashIterator<QGraphicsObject*, ResizeController*> itemControllerIterator(m_itemControllerHash); - while (itemControllerIterator.hasNext()) { - ResizeController *controller = itemControllerIterator.next().value(); - controller->hide(); - } -} - -void ResizeIndicator::clear() -{ - QHashIterator<QGraphicsObject*, ResizeController*> itemControllerIterator(m_itemControllerHash); - while(itemControllerIterator.hasNext()) { - itemControllerIterator.next(); - delete itemControllerIterator.value(); - } - m_itemControllerHash.clear(); -} - -void ResizeIndicator::setItems(const QList<QGraphicsObject*> &itemList) -{ - clear(); - - foreach (QGraphicsObject* item, itemList) { - ResizeController *controller = new ResizeController(m_layerItem.data(), item); - m_itemControllerHash.insert(item, controller); - } -} - -void ResizeIndicator::updateItems(const QList<QGraphicsObject*> &/*itemList*/) -{ -// foreach (QDeclarativeItem* item, itemList) { -// if (m_itemControllerHash.contains(item)) { -// ResizeController *controller = new ResizeController(m_itemControllerHash.value(item)); -// controller.updatePosition(); -// } -// } -} - -} diff --git a/share/qtcreator/qmljsdebugger/editor/resizeindicator.h b/share/qtcreator/qmljsdebugger/editor/resizeindicator.h deleted file mode 100644 index 360dba72b7b6299a3a71cb4b132f67ba373715f7..0000000000000000000000000000000000000000 --- a/share/qtcreator/qmljsdebugger/editor/resizeindicator.h +++ /dev/null @@ -1,82 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef RESIZEINDICATOR_H -#define RESIZEINDICATOR_H - -#include <QHash> -#include <QPair> -#include <QGraphicsObject> -#include <QDeclarativeItem> -#include <QWeakPointer> - -#include "resizecontroller.h" - -QT_FORWARD_DECLARE_CLASS(QGraphicsRectItem); - -namespace QmlViewer { - -class LayerItem; - -class ResizeIndicator -{ -public: - enum Orientation { - Top = 1, - Right = 2, - Bottom = 4, - Left = 8 - }; - - ResizeIndicator(LayerItem *layerItem); - ~ResizeIndicator(); - - void show(); - void hide(); - - void clear(); - - void setItems(const QList<QGraphicsObject*> &itemList); - void updateItems(const QList<QGraphicsObject*> &itemList); - -// -// QPair<FormEditorItem*,Orientation> pick(QGraphicsRectItem* pickedItem) const; -// -// void show(); -// void hide(); - -private: - QWeakPointer<LayerItem> m_layerItem; - QHash<QGraphicsObject*, ResizeController*> m_itemControllerHash; - -}; - -} - -#endif // SCALEINDICATOR_H diff --git a/share/qtcreator/qmljsdebugger/editor/resizemanipulator.cpp b/share/qtcreator/qmljsdebugger/editor/resizemanipulator.cpp deleted file mode 100644 index 329404244d65fceb094fa5780c848189c7a47a56..0000000000000000000000000000000000000000 --- a/share/qtcreator/qmljsdebugger/editor/resizemanipulator.cpp +++ /dev/null @@ -1,529 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "resizemanipulator.h" -#include "resizehandleitem.h" - -#include "mathutils.h" - -#include <QtDebug> -#include <QDeclarativeItem> -#include <QApplication> -#include <limits> - -namespace QmlViewer { - -ResizeManipulator::ResizeManipulator(LayerItem *layer, QDeclarativeView *view) - : m_view(view), - m_resizeController(0), - m_beginTopMargin(0.0), - m_beginLeftMargin(0.0), - m_beginRightMargin(0.0), - m_beginBottomMargin(0.0), - m_resizeHandle(0), - m_layerItem(layer) -{ -} - -ResizeManipulator::~ResizeManipulator() -{ - deleteSnapLines(); -} - -void ResizeManipulator::setHandle(ResizeHandleItem *resizeHandle) -{ - Q_ASSERT(resizeHandle); - m_view->setCursor(resizeHandle->customCursor()); - m_resizeHandle = resizeHandle; - m_resizeController = resizeHandle->resizeController(); - //m_snapper.setContainerFormEditorItem(m_resizeController.formEditorItem()->parentItem()); - //m_snapper.setTransformtionSpaceFormEditorItem(m_resizeController.formEditorItem()); - Q_ASSERT(m_resizeController->isValid()); -} - -void ResizeManipulator::removeHandle() -{ - m_resizeController = 0; - m_resizeHandle = 0; -} - -void ResizeManipulator::begin(const QPointF &/*beginPoint*/) -{ - - if (m_resizeController->isValid()) { - m_beginBoundingRect = m_resizeController->formEditorItem()->boundingRect(); - m_beginToSceneTransform = m_resizeController->formEditorItem()->sceneTransform(); - m_beginFromSceneTransform = m_beginToSceneTransform.inverted(); - - if (m_resizeController->formEditorItem()->parentItem()) { - m_beginToParentTransform = m_resizeController->formEditorItem()->itemTransform(m_resizeController->formEditorItem()->parentItem()); - } else { - m_beginToParentTransform = QTransform(); - } - - //m_snapper.updateSnappingLines(m_resizeController.formEditorItem()); - m_beginBottomRightPoint = m_beginToParentTransform.map(m_resizeController->formEditorItem()->boundingRect().bottomRight()); - - //QmlAnchors anchors(m_resizeController.formEditorItem()->qmlItemNode().anchors()); - m_beginTopMargin = 0;//anchors.instanceMargin(AnchorLine::Top); - m_beginLeftMargin = 0;//anchors.instanceMargin(AnchorLine::Left); - m_beginRightMargin = 0;//anchors.instanceMargin(AnchorLine::Right); - m_beginBottomMargin = 0;//anchors.instanceMargin(AnchorLine::Bottom); - } -} - -//static QSizeF mapSizeToParent(const QSizeF &size, QGraphicsItem *item) -//{ -// QPointF sizeAsPoint(size.width(), size.height()); -// sizeAsPoint = item->mapToParent(sizeAsPoint); -// return QSizeF(sizeAsPoint.x(), sizeAsPoint.y()); -//} - -void ResizeManipulator::update(const QPointF& updatePoint, Snapping useSnapping) -{ - if (!m_resizeHandle || !m_resizeController) - return; - - const double minimumWidth = 15.0; - const double minimumHeight = 15.0; - - deleteSnapLines(); - - bool snap = useSnapping == UseSnapping || useSnapping == UseSnappingAndAnchoring; - - if (m_resizeController->isValid()) { - - QDeclarativeItem *formEditorItem = qobject_cast<QDeclarativeItem*>(m_resizeController->formEditorItem()); - - if (!formEditorItem) - return; - - //FormEditorItem *containerItem = m_snapper.containerFormEditorItem(); - -// if (!containerItem) -// return; -// QPointF updatePointInLocalSpace = QPointF(0,0); -// if (formEditorItem->parentItem()) { -// updatePointInLocalSpace = formEditorItem->parentItem()->mapFromScene(updatePoint); -// } else { -// updatePointInLocalSpace = updatePoint; //= m_beginFromSceneTransform.map(updatePoint); -// } - - QPointF updatePointInLocalSpace = m_beginFromSceneTransform.map(updatePoint); - //QmlAnchors anchors(formEditorItem->qmlItemNode().anchors()); - - QRectF boundingRect(m_beginBoundingRect); - if (m_resizeHandle->isBottomRightHandle()) { - boundingRect.setBottomRight(updatePointInLocalSpace); - - if (snap) { -// double rightOffset = m_snapper.snapRightOffset(boundingRect); -// if (rightOffset < std::numeric_limits<double>::max()) -// updatePointInLocalSpace.rx() -= rightOffset; - -// double bottomOffset = m_snapper.snapBottomOffset(boundingRect); -// if (bottomOffset < std::numeric_limits<double>::max()) -// updatePointInLocalSpace.ry() -= bottomOffset; - } - boundingRect.setBottomRight(updatePointInLocalSpace); - -// if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter)) { -// boundingRect.setLeft(boundingRect.left() - (updatePointInLocalSpace.x() - m_beginBoundingRect.right())); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter)) { -// boundingRect.setTop(boundingRect.top() - (updatePointInLocalSpace.y() - m_beginBoundingRect.bottom())); -// } - - - if (boundingRect.width() < minimumWidth) - boundingRect.setWidth(minimumWidth); - if (boundingRect.height() < minimumHeight) - boundingRect.setHeight(minimumHeight); - - formEditorItem->setSize(boundingRect.size()); - -// if (anchors.instanceHasAnchor(AnchorLine::Bottom)) { -// anchors.setMargin(AnchorLine::Bottom, -// m_beginBottomMargin - (m_beginToParentTransform.map(boundingRect.bottomRight()) - m_beginBottomRightPoint).y()); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::Right)) { -// anchors.setMargin(AnchorLine::Right, -// m_beginRightMargin - (m_beginToParentTransform.map(boundingRect.bottomRight()) - m_beginBottomRightPoint).x()); -// } - } else if (m_resizeHandle->isTopLeftHandle()) { - boundingRect.setTopLeft(updatePointInLocalSpace); - - if (snap) { -// double leftOffset = m_snapper.snapLeftOffset(boundingRect); -// if (leftOffset < std::numeric_limits<double>::max()) -// updatePointInLocalSpace.rx() -= leftOffset; - -// double topOffset = m_snapper.snapTopOffset(boundingRect); -// if (topOffset < std::numeric_limits<double>::max()) -// updatePointInLocalSpace.ry() -= topOffset; - } - //boundingRect.setTopLeft(updatePointInLocalSpace); - -// if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter)) { -// boundingRect.setRight(boundingRect.right() - (updatePointInLocalSpace.x() - m_beginBoundingRect.left())); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter)) { -// boundingRect.setBottom(boundingRect.bottom() - (updatePointInLocalSpace.y() - m_beginBoundingRect.top())); -// } - - - if (boundingRect.width() < minimumWidth) - boundingRect.setLeft(boundingRect.left() - minimumWidth + boundingRect.width()); - if (boundingRect.height() < minimumHeight) - boundingRect.setTop(boundingRect.top() - minimumHeight + boundingRect.height()); - - formEditorItem->setSize(boundingRect.size()); - formEditorItem->setPos(m_beginToParentTransform.map(boundingRect.topLeft())); - - -// if (anchors.instanceHasAnchor(AnchorLine::Top)) { -// anchors.setMargin(AnchorLine::Top, -// m_beginTopMargin + (-m_beginToParentTransform.map(m_beginBoundingRect.topLeft()).y() + m_beginToParentTransform.map(boundingRect.topLeft()).y())); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::Left)) { -// anchors.setMargin(AnchorLine::Left, -// m_beginLeftMargin + (-m_beginToParentTransform.map(m_beginBoundingRect.topLeft()).x() + m_beginToParentTransform.map(boundingRect.topLeft()).x())); -// } - - } else if (m_resizeHandle->isTopRightHandle()) { - boundingRect.setTopRight(updatePointInLocalSpace); - - if (snap) { -// double rightOffset = m_snapper.snapRightOffset(boundingRect); -// if (rightOffset < std::numeric_limits<double>::max()) -// updatePointInLocalSpace.rx() -= rightOffset; - -// double topOffset = m_snapper.snapTopOffset(boundingRect); -// if (topOffset < std::numeric_limits<double>::max()) -// updatePointInLocalSpace.ry() -= topOffset; - } - boundingRect.setTopRight(updatePointInLocalSpace); - -// if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter)) { -// boundingRect.setLeft(boundingRect.left() - (updatePointInLocalSpace.x() - m_beginBoundingRect.right())); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter)) { -// boundingRect.setBottom(boundingRect.bottom() - (updatePointInLocalSpace.y() - m_beginBoundingRect.top())); -// } - - if (boundingRect.height() < minimumHeight) - boundingRect.setTop(boundingRect.top() - minimumHeight + boundingRect.height()); - if (boundingRect.width() < minimumWidth) - boundingRect.setWidth(minimumWidth); - - formEditorItem->setSize(boundingRect.size()); - - // was: setPositionWithBorder - formEditorItem->setPos(m_beginToParentTransform.map(boundingRect.topLeft())); - -// if (anchors.instanceHasAnchor(AnchorLine::Top)) { -// anchors.setMargin(AnchorLine::Top, -// m_beginTopMargin + (-m_beginToParentTransform.map(m_beginBoundingRect.topLeft()).y() + m_beginToParentTransform.map(boundingRect.topLeft()).y())); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::Right)) { -// anchors.setMargin(AnchorLine::Right, -// m_beginRightMargin - (m_beginToParentTransform.map(boundingRect.bottomRight()) - m_beginBottomRightPoint).x()); -// } - } else if (m_resizeHandle->isBottomLeftHandle()) { - boundingRect.setBottomLeft(updatePointInLocalSpace); - - if (snap) { -// double leftOffset = m_snapper.snapLeftOffset(boundingRect); -// if (leftOffset < std::numeric_limits<double>::max()) -// updatePointInLocalSpace.rx() -= leftOffset; - -// double bottomOffset = m_snapper.snapBottomOffset(boundingRect); -// if (bottomOffset < std::numeric_limits<double>::max()) -// updatePointInLocalSpace.ry() -= bottomOffset; - } - - boundingRect.setBottomLeft(updatePointInLocalSpace); - -// if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter)) { -// boundingRect.setRight(boundingRect.right() - (updatePointInLocalSpace.x() - m_beginBoundingRect.left())); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter)) { -// boundingRect.setTop(boundingRect.top() - (updatePointInLocalSpace.y() - m_beginBoundingRect.bottom())); -// } - - if (boundingRect.height() < minimumHeight) - boundingRect.setHeight(minimumHeight); - if (boundingRect.width() < minimumWidth) - boundingRect.setLeft(boundingRect.left() - minimumWidth + boundingRect.width()); - - formEditorItem->setSize(boundingRect.size()); - formEditorItem->setPos(m_beginToParentTransform.map(boundingRect.topLeft())); - -// if (anchors.instanceHasAnchor(AnchorLine::Left)) { -// anchors.setMargin(AnchorLine::Left, -// m_beginLeftMargin + (-m_beginToParentTransform.map(m_beginBoundingRect.topLeft()).x() + m_beginToParentTransform.map(boundingRect.topLeft()).x())); -// } - -// if (anchors.instanceHasAnchor(AnchorLine::Bottom)) { -// anchors.setMargin(AnchorLine::Bottom, -// m_beginBottomMargin - (m_beginToParentTransform.map(boundingRect.bottomRight()) - m_beginBottomRightPoint).y()); -// } - } else if (m_resizeHandle->isBottomHandle()) { - boundingRect.setBottom(updatePointInLocalSpace.y()); - - if (snap) { -// double bottomOffset = m_snapper.snapBottomOffset(boundingRect); -// if (bottomOffset < std::numeric_limits<double>::max()) -// updatePointInLocalSpace.ry() -= bottomOffset; - } - - boundingRect.setBottom(updatePointInLocalSpace.y()); - -// if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter)) { -// boundingRect.setTop(boundingRect.top() - (updatePointInLocalSpace.y() - m_beginBoundingRect.bottom())); -// } - - if (boundingRect.height() < minimumHeight) - boundingRect.setHeight(minimumHeight); - - formEditorItem->setSize(boundingRect.size()); - -// if (anchors.instanceHasAnchor(AnchorLine::Bottom)) { -// anchors.setMargin(AnchorLine::Bottom, -// m_beginBottomMargin - (m_beginToParentTransform.map(boundingRect.bottomRight()) - m_beginBottomRightPoint).y()); -// } - } else if (m_resizeHandle->isTopHandle()) { - boundingRect.setTop(updatePointInLocalSpace.y()); - - if (snap) { -// double topOffset = m_snapper.snapTopOffset(boundingRect); -// if (topOffset < std::numeric_limits<double>::max()) -// updatePointInLocalSpace.ry() -= topOffset; - } - - boundingRect.setTop(updatePointInLocalSpace.y()); - -// if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter)) { -// boundingRect.setBottom(boundingRect.bottom() - (updatePointInLocalSpace.y() - m_beginBoundingRect.top())); -// } - - if (boundingRect.height() < minimumHeight) - boundingRect.setTop(boundingRect.top() - minimumHeight + boundingRect.height()); - - formEditorItem->setSize(boundingRect.size()); - formEditorItem->setPos(m_beginToParentTransform.map(boundingRect.topLeft())); - -// if (anchors.instanceHasAnchor(AnchorLine::Top)) { -// anchors.setMargin(AnchorLine::Top, -// m_beginTopMargin + (-m_beginToParentTransform.map(m_beginBoundingRect.topLeft()).y() + m_beginToParentTransform.map(boundingRect.topLeft()).y())); -// } - } else if (m_resizeHandle->isRightHandle()) { - boundingRect.setRight(updatePointInLocalSpace.x()); - - if (snap) { -// double rightOffset = m_snapper.snapRightOffset(boundingRect); -// if (rightOffset < std::numeric_limits<double>::max()) -// updatePointInLocalSpace.rx() -= rightOffset; - } - - boundingRect.setRight(updatePointInLocalSpace.x()); - -// if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter)) { -// boundingRect.setLeft(boundingRect.left() - (updatePointInLocalSpace.x() - m_beginBoundingRect.right())); -// } - - if (boundingRect.width() < minimumWidth) - boundingRect.setWidth(minimumWidth); - - formEditorItem->setSize(boundingRect.size()); - - -// if (anchors.instanceHasAnchor(AnchorLine::Right)) { -// anchors.setMargin(AnchorLine::Right, -// m_beginRightMargin - (m_beginToParentTransform.map(boundingRect.bottomRight()) - m_beginBottomRightPoint).x()); -// } - } else if (m_resizeHandle->isLeftHandle()) { - boundingRect.setLeft(updatePointInLocalSpace.x()); - - if (snap) { -// double leftOffset = m_snapper.snapLeftOffset(boundingRect); -// if (leftOffset < std::numeric_limits<double>::max()) -// updatePointInLocalSpace.rx() -= leftOffset; - } - - boundingRect.setLeft(updatePointInLocalSpace.x()); - -// if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter)) { -// boundingRect.setRight(boundingRect.right() - (updatePointInLocalSpace.x() - m_beginBoundingRect.left())); -// } - - if (boundingRect.width() < minimumWidth) - boundingRect.setLeft(boundingRect.left() - minimumWidth + boundingRect.width()); - - formEditorItem->setSize(boundingRect.size()); - formEditorItem->setPos(m_beginToParentTransform.map(boundingRect.topLeft())); - -// if (anchors.instanceHasAnchor(AnchorLine::Left)) { -// anchors.setMargin(AnchorLine::Left, -// m_beginLeftMargin + (-m_beginToParentTransform.map(m_beginBoundingRect.topLeft()).x() + m_beginToParentTransform.map(boundingRect.topLeft()).x())); -// } - } - -// if (snap) -// m_graphicsLineList = m_snapper.generateSnappingLines(boundingRect, -// m_layerItem.data(), -// m_beginToSceneTransform); - } - m_resizeController->updatePosition(); -} - -void ResizeManipulator::end() -{ - //m_rewriterTransaction.commit(); - clear(); - removeHandle(); -} - -//void ResizeManipulator::moveBy(double deltaX, double deltaY) -//{ -// if (resizeHandle()) { -// //QmlItemNode qmlItemNode(m_resizeController.formEditorItem()->qmlItemNode()); -// //QmlAnchors anchors(qmlItemNode.anchors()); - -// if (m_resizeController.isLeftHandle(resizeHandle()) -// || m_resizeController.isTopLeftHandle(resizeHandle()) -// || m_resizeController.isBottomLeftHandle(resizeHandle())) { -// qmlItemNode.setVariantProperty("x", round((qmlItemNode.instanceValue("x").toDouble() + deltaX), 4)); -// qmlItemNode.setVariantProperty("width", round(qmlItemNode.instanceValue("width").toDouble() - deltaX, 4)); - - -//// if (anchors.instanceHasAnchor(AnchorLine::Left)) { -//// anchors.setMargin(AnchorLine::Left, anchors.instanceMargin(AnchorLine::Left) + deltaX); -//// } - -//// if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter)) { -//// qmlItemNode.setVariantProperty("width", round(qmlItemNode.instanceValue("width").toDouble() - (deltaX * 2), 4)); -//// } -// } - -// if (m_resizeController.isRightHandle(resizeHandle()) -// || m_resizeController.isTopRightHandle(resizeHandle()) -// || m_resizeController.isBottomRightHandle(resizeHandle())) { -// qmlItemNode.setVariantProperty("width", round(qmlItemNode.instanceValue("width").toDouble() + deltaX, 4)); - -//// if (anchors.instanceHasAnchor(AnchorLine::Right)) { -//// anchors.setMargin(AnchorLine::Right, round(anchors.instanceMargin(AnchorLine::Right) - deltaX, 4)); -//// } - -//// if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter)) { -//// qmlItemNode.setVariantProperty("width", round(qmlItemNode.instanceValue("width").toDouble() + (deltaX * 2), 4)); -//// } -// } - - -// if (m_resizeController.isTopHandle(resizeHandle()) -// || m_resizeController.isTopLeftHandle(resizeHandle()) -// || m_resizeController.isTopRightHandle(resizeHandle())) { -// qmlItemNode.setVariantProperty("y", round(qmlItemNode.instanceValue("y").toDouble() + deltaY, 4)); -// qmlItemNode.setVariantProperty("height", round(qmlItemNode.instanceValue("height").toDouble() - deltaY, 4)); - -//// if (anchors.instanceHasAnchor(AnchorLine::Top)) { -//// anchors.setMargin(AnchorLine::Top, anchors.instanceMargin(AnchorLine::Top) + deltaY); -//// } - -//// if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter)) { -//// qmlItemNode.setVariantProperty("height", round(qmlItemNode.instanceValue("height").toDouble() - (deltaY * 2), 4)); -//// } -// } - -// if (m_resizeController.isBottomHandle(resizeHandle()) -// || m_resizeController.isBottomLeftHandle(resizeHandle()) -// || m_resizeController.isBottomRightHandle(resizeHandle())) { -// qmlItemNode.setVariantProperty("height", round(qmlItemNode.instanceValue("height").toDouble() + deltaY, 4)); - -//// if (anchors.instanceHasAnchor(AnchorLine::Bottom)) { -//// anchors.setMargin(AnchorLine::Bottom, anchors.instanceMargin(AnchorLine::Bottom) - deltaY); -//// } - -//// if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter)) { -//// qmlItemNode.setVariantProperty("height", round(qmlItemNode.instanceValue("height").toDouble() + (deltaY * 2), 4)); -//// } -// } - -// } -//} - -bool ResizeManipulator::isInvalidSize(const QSizeF & size) -{ - if (size.width() < 15 || size.height() < 15) - return true; - - return false; -} - -void ResizeManipulator::deleteSnapLines() -{ -// if (m_layerItem) { -// foreach (QGraphicsItem *item, m_graphicsLineList) -// m_layerItem->scene()->removeItem(item); -// } - - m_graphicsLineList.clear(); - m_view->scene()->update(); -} - -ResizeHandleItem *ResizeManipulator::resizeHandle() -{ - return m_resizeHandle; -} - -void ResizeManipulator::clear() -{ - //m_rewriterTransaction.commit(); - - deleteSnapLines(); - m_beginBoundingRect = QRectF(); - m_beginFromSceneTransform = QTransform(); - m_beginToSceneTransform = QTransform(); - m_beginToParentTransform = QTransform(); - m_beginTopMargin = 0.0; - m_beginLeftMargin = 0.0; - m_beginRightMargin = 0.0; - m_beginBottomMargin = 0.0; - removeHandle(); -} - -} diff --git a/share/qtcreator/qmljsdebugger/editor/resizemanipulator.h b/share/qtcreator/qmljsdebugger/editor/resizemanipulator.h deleted file mode 100644 index 87bd943be31395db7199338f10839d037c841e8f..0000000000000000000000000000000000000000 --- a/share/qtcreator/qmljsdebugger/editor/resizemanipulator.h +++ /dev/null @@ -1,93 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef RESIZEMANIPULATOR_H -#define RESIZEMANIPULATOR_H - -#include <QWeakPointer> -#include "layeritem.h" -#include "resizehandleitem.h" - -#include <QDeclarativeItem> -#include <QDeclarativeView> - -namespace QmlViewer { - -class ResizeHandleItem; -class Model; - -class ResizeManipulator -{ -public: - enum Snapping { - UseSnapping, - UseSnappingAndAnchoring, - NoSnapping - }; - - ResizeManipulator(LayerItem *layer, QDeclarativeView *view); - ~ResizeManipulator(); - - void setHandle(ResizeHandleItem *resizeHandle); - void removeHandle(); - - void begin(const QPointF& beginPoint); - void update(const QPointF& updatePoint, Snapping useSnapping); - void end(); - - void moveBy(double deltaX, double deltaY); - - void clear(); - -protected: - bool isInvalidSize(const QSizeF & size); - void deleteSnapLines(); - ResizeHandleItem *resizeHandle(); - -private: -// Snapper m_snapper; - QWeakPointer<QDeclarativeView> m_view; - QList<QGraphicsItem*> m_graphicsLineList; - ResizeController *m_resizeController; - QTransform m_beginFromSceneTransform; - QTransform m_beginToSceneTransform; - QTransform m_beginToParentTransform; - QRectF m_beginBoundingRect; - QPointF m_beginBottomRightPoint; - double m_beginTopMargin; - double m_beginLeftMargin; - double m_beginRightMargin; - double m_beginBottomMargin; - ResizeHandleItem *m_resizeHandle; - QWeakPointer<LayerItem> m_layerItem; -}; - -} - -#endif // RESIZEMANIPULATOR_H diff --git a/share/qtcreator/qmljsdebugger/editor/resizetool.cpp b/share/qtcreator/qmljsdebugger/editor/resizetool.cpp deleted file mode 100644 index d5845be6672d2d274d650d2166ab6e17f24e0fa0..0000000000000000000000000000000000000000 --- a/share/qtcreator/qmljsdebugger/editor/resizetool.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "resizetool.h" -#include "resizehandleitem.h" -#include "qdeclarativedesignview.h" - -#include <QApplication> -#include <QGraphicsSceneMouseEvent> -#include <QAction> -#include <QKeyEvent> -#include <QGraphicsObject> -#include <QWheelEvent> - -#include <QtDebug> - -namespace QmlViewer { - -ResizeTool::ResizeTool(QDeclarativeDesignView *view) - : AbstractFormEditorTool(view), - m_selectionIndicator(view->manipulatorLayer()), - m_resizeManipulator(new ResizeManipulator(view->manipulatorLayer(), view)), - m_resizeIndicator(view->manipulatorLayer()) -{ -} - - -ResizeTool::~ResizeTool() -{ - delete m_resizeManipulator; -} - -void ResizeTool::mousePressEvent(QMouseEvent *event) -{ - QList<QGraphicsItem*> itemList = view()->items(event->pos()); - - if (itemList.isEmpty()) - return; - - ResizeHandleItem *resizeHandle = ResizeHandleItem::fromGraphicsItem(itemList.first()); - - if (resizeHandle) - qDebug() << resizeHandle->resizeController(); - - if (resizeHandle - && resizeHandle->resizeController() - && resizeHandle->resizeController()->isValid()) - { - m_resizeManipulator->setHandle(resizeHandle); - m_resizeManipulator->begin(view()->mapToScene(event->pos())); - m_resizeIndicator.hide(); - } else { - view()->setCursor(Qt::ArrowCursor); - } -} - -void ResizeTool::mouseMoveEvent(QMouseEvent *event) -{ - - bool shouldSnapping = false; //view()->widget()->snappingAction()->isChecked(); - bool shouldSnappingAndAnchoring = false; //view()->widget()->snappingAndAnchoringAction()->isChecked(); - - ResizeManipulator::Snapping useSnapping = ResizeManipulator::NoSnapping; - if (event->modifiers().testFlag(Qt::ControlModifier) != (shouldSnapping || shouldSnappingAndAnchoring)) { - if (shouldSnappingAndAnchoring) - useSnapping = ResizeManipulator::UseSnappingAndAnchoring; - else - useSnapping = ResizeManipulator::UseSnapping; - } - m_resizeManipulator->update(view()->mapToScene(event->pos()), useSnapping); -} - -void ResizeTool::hoverMoveEvent(QMouseEvent *event) -{ - QList<QGraphicsItem*> itemList = view()->items(event->pos()); - - if (itemList.isEmpty()) - return; - - ResizeHandleItem* resizeHandle = ResizeHandleItem::fromGraphicsItem(itemList.first()); - if (resizeHandle && resizeHandle->resizeController()->isValid()) { - m_resizeManipulator->setHandle(resizeHandle); - } else { - qDebug() << "resize -> selection tool"; - view()->changeTool(Constants::SelectionToolMode); - return; - } -} - -void ResizeTool::mouseReleaseEvent(QMouseEvent *event) -{ - QList<QGraphicsItem*> itemList = view()->selectableItems(event->pos()); - if (itemList.isEmpty()) - return; - - view()->setCursor(Qt::ArrowCursor); - m_selectionIndicator.show(); - m_resizeIndicator.show(); - m_resizeManipulator->end(); -} - -void ResizeTool::mouseDoubleClickEvent(QMouseEvent * /*event*/) -{ -} - -void ResizeTool::keyPressEvent(QKeyEvent * event) -{ - switch(event->key()) { - case Qt::Key_Shift: - case Qt::Key_Alt: - case Qt::Key_Control: - case Qt::Key_AltGr: - event->setAccepted(false); - return; - } - - double moveStep = 1.0; - - if (event->modifiers().testFlag(Qt::ShiftModifier)) - moveStep = 10.0; - -// switch(event->key()) { -// case Qt::Key_Left: m_resizeManipulator->moveBy(-moveStep, 0.0); break; -// case Qt::Key_Right: m_resizeManipulator->moveBy(moveStep, 0.0); break; -// case Qt::Key_Up: m_resizeManipulator->moveBy(0.0, -moveStep); break; -// case Qt::Key_Down: m_resizeManipulator->moveBy(0.0, moveStep); break; -// } - -} - -void ResizeTool::keyReleaseEvent(QKeyEvent * keyEvent) -{ - switch(keyEvent->key()) { - case Qt::Key_Shift: - case Qt::Key_Alt: - case Qt::Key_Control: - case Qt::Key_AltGr: - keyEvent->setAccepted(false); - return; - } - - if (!keyEvent->isAutoRepeat()) - m_resizeManipulator->clear(); -} - -void ResizeTool::wheelEvent(QWheelEvent */*event*/) -{ - -} - -void ResizeTool::itemsAboutToRemoved(const QList<QGraphicsItem*> & /*itemList*/) -{ - -} - -void ResizeTool::selectedItemsChanged(const QList<QGraphicsItem*> & itemList) -{ - m_selectionIndicator.setItems(toGraphicsObjectList(itemList)); - - m_resizeIndicator.setItems(toGraphicsObjectList(itemList)); -} - -void ResizeTool::clear() -{ - view()->clearHighlightBoundingRect(); - view()->setCursor(Qt::ArrowCursor); - m_selectionIndicator.clear(); - m_resizeIndicator.clear(); - m_resizeManipulator->clear(); -} - -void ResizeTool::graphicsObjectsChanged(const QList<QGraphicsObject*> &itemList) -{ - m_selectionIndicator.updateItems(itemList); - m_resizeIndicator.updateItems(itemList); -} - -} diff --git a/share/qtcreator/qmljsdebugger/editor/resizetool.h b/share/qtcreator/qmljsdebugger/editor/resizetool.h deleted file mode 100644 index 250441a4e5c368dab919b1f29367634f95a30313..0000000000000000000000000000000000000000 --- a/share/qtcreator/qmljsdebugger/editor/resizetool.h +++ /dev/null @@ -1,82 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef RESIZETOOL_H -#define RESIZETOOL_H - -#include <QMouseEvent> -#include <QKeyEvent> -#include <QDeclarativeItem> - -#include "resizeindicator.h" - -#include "resizemanipulator.h" -#include "abstractformeditortool.h" -#include "selectionindicator.h" - -#include "resizeindicator.h" - -namespace QmlViewer { - -class QDeclarativeDesignView; - -class ResizeTool : public AbstractFormEditorTool -{ -public: - ResizeTool(QDeclarativeDesignView *view); - ~ResizeTool(); - - bool isActive() const; - - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); - - void hoverMoveEvent(QMouseEvent *event); - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *keyEvent); - void wheelEvent(QWheelEvent *event); - - void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList); - - void selectedItemsChanged(const QList<QGraphicsItem*> &itemList); - - void clear(); - void graphicsObjectsChanged(const QList<QGraphicsObject*> &itemList); - -private: - SelectionIndicator m_selectionIndicator; - ResizeManipulator *m_resizeManipulator; - ResizeIndicator m_resizeIndicator; -}; - -} - -#endif // RESIZETOOL_H diff --git a/share/qtcreator/qmljsdebugger/editor/snappinglinecreator.cpp b/share/qtcreator/qmljsdebugger/editor/snappinglinecreator.cpp deleted file mode 100644 index 4a0e34983769838b6dcb65cf761bab2f0355ae57..0000000000000000000000000000000000000000 --- a/share/qtcreator/qmljsdebugger/editor/snappinglinecreator.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "snappinglinecreator.h" - -#include <QGraphicsItem> -#include "formeditoritem.h" - -namespace QmlDesigner { - -SnappingLineCreator::SnappingLineCreator(FormEditorItem *formEditorItem) - : m_formEditorItem(formEditorItem), - m_topOffset(formEditorItem->formEditorView()->spacing()), - m_bottomOffset(formEditorItem->formEditorView()->spacing()), - m_leftOffset(formEditorItem->formEditorView()->spacing()), - m_rightOffset(formEditorItem->formEditorView()->spacing()), - m_topMargin(formEditorItem->formEditorView()->margins()), - m_bottomMargin(formEditorItem->formEditorView()->margins()), - m_leftMargin(formEditorItem->formEditorView()->margins()), - m_rightMargin(formEditorItem->formEditorView()->margins()) -{ - Q_ASSERT(m_formEditorItem); -} - -void SnappingLineCreator::clearLines() -{ - m_topLineMap.clear(); - m_bottomLineMap.clear(); - m_leftLineMap.clear(); - m_rightLineMap.clear(); - m_horizontalCenterLineMap.clear(); - m_verticalCenterLineMap.clear(); - - m_topOffsetMap.clear(); - m_bottomOffsetMap.clear(); - m_leftOffsetMap.clear(); - m_rightOffsetMap.clear(); - -} - -void SnappingLineCreator::addLines(const QRectF &rectInSceneSpace, FormEditorItem *item) -{ - m_topLineMap.insert(rectInSceneSpace.top(), qMakePair(rectInSceneSpace, item)); - m_bottomLineMap.insert(rectInSceneSpace.bottom(), qMakePair(rectInSceneSpace, item)); - m_leftLineMap.insert(rectInSceneSpace.left(), qMakePair(rectInSceneSpace, item)); - m_rightLineMap.insert(rectInSceneSpace.right(), qMakePair(rectInSceneSpace, item)); - QPointF centerPoint(rectInSceneSpace.center()); - m_horizontalCenterLineMap.insert(centerPoint.y(), qMakePair(rectInSceneSpace, item)); - m_verticalCenterLineMap.insert(centerPoint.x(), qMakePair(rectInSceneSpace, item)); -} - -void SnappingLineCreator::addOffsets(const QRectF &rectInSceneSpace, FormEditorItem *item) -{ - m_topOffsetMap.insert(rectInSceneSpace.top() - m_topOffset, qMakePair(rectInSceneSpace, item)); - m_bottomOffsetMap.insert(rectInSceneSpace.bottom() + m_bottomOffset, qMakePair(rectInSceneSpace, item)); - m_leftOffsetMap.insert(rectInSceneSpace.left() - m_leftOffset, qMakePair(rectInSceneSpace, item)); - m_rightOffsetMap.insert(rectInSceneSpace.right() + m_rightOffset, qMakePair(rectInSceneSpace, item)); -} - -void SnappingLineCreator::generateLines(const QList<FormEditorItem*> &exceptionList, - FormEditorItem *transformationSpaceItem) -{ - Q_ASSERT(transformationSpaceItem); - { - QRectF containerBoundingRectInTransformationSpace = m_formEditorItem->mapRectToItem(transformationSpaceItem, - m_formEditorItem->qmlItemNode().instanceBoundingRect()); - - addLines(containerBoundingRectInTransformationSpace, m_formEditorItem); - containerBoundingRectInTransformationSpace.adjust(m_leftMargin, m_topMargin, -m_rightMargin, -m_rightMargin); - addLines(containerBoundingRectInTransformationSpace, m_formEditorItem); - } - - foreach (FormEditorItem *item, m_formEditorItem->childFormEditorItems()) { - if (exceptionList.contains(item)) - continue; - QRectF boundingRectInContainerSpace; - - boundingRectInContainerSpace = item->mapRectToItem(transformationSpaceItem, item->qmlItemNode().instanceBoundingRect()); - - boundingRectInContainerSpace = boundingRectInContainerSpace.toRect(); // round to integer - - addLines(boundingRectInContainerSpace, item); - addOffsets(boundingRectInContainerSpace, item); - } -} - -void SnappingLineCreator::setMargins(double margin) -{ - m_topMargin = margin; - m_bottomMargin = margin; - m_leftMargin = margin; - m_rightMargin = margin; -} - -void SnappingLineCreator::setSpacing(double spacing) -{ - m_topOffset = spacing; - m_bottomOffset = spacing; - m_leftOffset = spacing; - m_rightOffset = spacing; -} - -void SnappingLineCreator::update(const QList<FormEditorItem*> &exceptionList, - FormEditorItem *transformationSpaceItem) -{ - clearLines(); - setMargins(m_formEditorItem->formEditorView()->margins()); - setSpacing(m_formEditorItem->formEditorView()->spacing()); - generateLines(exceptionList, transformationSpaceItem); -} - -SnapLineMap SnappingLineCreator::topLines() const -{ - return m_topLineMap; -} - -SnapLineMap SnappingLineCreator::bottomLines() const -{ - return m_bottomLineMap; -} - -SnapLineMap SnappingLineCreator::leftLines() const -{ - return m_leftLineMap; -} - -SnapLineMap SnappingLineCreator::rightLines() const -{ - return m_rightLineMap; -} - -SnapLineMap SnappingLineCreator::horizontalCenterLines() const -{ - return m_horizontalCenterLineMap; -} - -SnapLineMap SnappingLineCreator::verticalCenterLines() const -{ - return m_verticalCenterLineMap; -} - -SnapLineMap SnappingLineCreator::topOffsets() const -{ - return m_topOffsetMap; -} - -SnapLineMap SnappingLineCreator::bottomOffsets() const -{ - return m_bottomOffsetMap; -} - -SnapLineMap SnappingLineCreator::leftOffsets() const -{ - return m_leftOffsetMap; -} - -SnapLineMap SnappingLineCreator::rightOffsets() const -{ - return m_rightOffsetMap; -} - -} diff --git a/share/qtcreator/qmljsdebugger/editor/snappinglinecreator.h b/share/qtcreator/qmljsdebugger/editor/snappinglinecreator.h deleted file mode 100644 index dd4f38eeeedb77c0ebd66ff3110eb9dcb7ff60a1..0000000000000000000000000000000000000000 --- a/share/qtcreator/qmljsdebugger/editor/snappinglinecreator.h +++ /dev/null @@ -1,102 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef SNAPPINGLINECREATOR_H -#define SNAPPINGLINECREATOR_H - -#include "layeritem.h" -#include <QPair> - -namespace QmlDesigner { - -class FormEditorItem; - -typedef QMultiMap<double, QPair<QRectF, FormEditorItem*> > SnapLineMap; -typedef QMapIterator<double, QPair<QRectF, FormEditorItem*> > SnapLineMapIterator; - -class FormEditorItem; - -class SnappingLineCreator -{ -public: - SnappingLineCreator(FormEditorItem *formEditorItem); - - void update(const QList<FormEditorItem*> &exceptionList, - FormEditorItem *transformationSpaceItem); - - - SnapLineMap topLines() const; - SnapLineMap bottomLines() const; - SnapLineMap leftLines() const; - SnapLineMap rightLines() const; - SnapLineMap horizontalCenterLines() const; - SnapLineMap verticalCenterLines() const; - - SnapLineMap topOffsets() const; - SnapLineMap bottomOffsets() const; - SnapLineMap leftOffsets() const; - SnapLineMap rightOffsets() const; - - void setMargins(double margin); - void setSpacing(double spacing); - -protected: - void addLines(const QRectF &rectInSceneSpace, FormEditorItem *item); - void addOffsets(const QRectF &rectInSceneSpace, FormEditorItem *item); - - void clearLines(); - void generateLines(const QList<FormEditorItem*> &exceptionList, - FormEditorItem *transformationSpaceItem); - -private: - SnapLineMap m_topLineMap; - SnapLineMap m_bottomLineMap; - SnapLineMap m_leftLineMap; - SnapLineMap m_rightLineMap; - SnapLineMap m_horizontalCenterLineMap; - SnapLineMap m_verticalCenterLineMap; - - SnapLineMap m_topOffsetMap; - SnapLineMap m_bottomOffsetMap; - SnapLineMap m_leftOffsetMap; - SnapLineMap m_rightOffsetMap; - - FormEditorItem *m_formEditorItem; - double m_topOffset; - double m_bottomOffset; - double m_leftOffset; - double m_rightOffset; - double m_topMargin; - double m_bottomMargin; - double m_leftMargin; - double m_rightMargin; -}; - -} -#endif // SNAPPINGLINECREATOR_H