1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
36 #include "abstractformeditortool.h"
37 #include "movemanipulator.h"
38 #include "selectionindicator.h"
39 #include "resizeindicator.h"
43 #include <QScopedPointer>
46 namespace QmlDesigner {
52 class TimerHandler : public QObject
57 TimerHandler(DragTool *tool) : QObject(), m_dragTool(tool) {}
59 void clearMoveDelay();
66 class DragTool : public AbstractFormEditorTool
69 DragTool(FormEditorView* editorView);
72 void mousePressEvent(const QList<QGraphicsItem*> &itemList,
73 QGraphicsSceneMouseEvent *event);
74 void mouseMoveEvent(const QList<QGraphicsItem*> &itemList,
75 QGraphicsSceneMouseEvent *event);
76 void mouseReleaseEvent(const QList<QGraphicsItem*> &itemList,
77 QGraphicsSceneMouseEvent *event);
78 void mouseDoubleClickEvent(const QList<QGraphicsItem*> &itemList,
79 QGraphicsSceneMouseEvent *event);
80 void hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
81 QGraphicsSceneMouseEvent *event);
83 void keyPressEvent(QKeyEvent *event);
84 void keyReleaseEvent(QKeyEvent *keyEvent);
86 void itemsAboutToRemoved(const QList<FormEditorItem*> &itemList);
88 void selectedItemsChanged(const QList<FormEditorItem*> &itemList);
90 void updateMoveManipulator();
92 void beginWithPoint(const QPointF &beginPoint);
95 virtual void dropEvent(QGraphicsSceneDragDropEvent * event);
96 virtual void dragEnterEvent(QGraphicsSceneDragDropEvent * event);
97 virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent * event);
98 virtual void dragMoveEvent(QGraphicsSceneDragDropEvent * event);
100 //void beginWithPoint(const QPointF &beginPoint);
104 void formEditorItemsChanged(const QList<FormEditorItem*> &itemList);
106 void instancesCompleted(const QList<FormEditorItem*> &itemList);
108 void clearMoveDelay();
115 void createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, QmlItemNode parentNode, QPointF scenePos);
116 void createQmlItemNodeFromImage(const QString &imageName, QmlItemNode parentNode, QPointF scenePos);
117 FormEditorItem* calculateContainer(const QPointF &point, FormEditorItem * currentItem = 0);
119 void begin(QPointF scenePos);
120 void end(QPointF scenePos);
121 void move(QPointF scenePos);
123 MoveManipulator m_moveManipulator;
124 SelectionIndicator m_selectionIndicator;
125 QWeakPointer<FormEditorItem> m_movingItem;
126 RewriterTransaction m_rewriterTransaction;
127 QmlItemNode m_dragNode;
128 QScopedPointer<Internal::TimerHandler> m_timerHandler;
130 QPointF m_startPoint;