1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
37 #include "abstractformeditortool.h"
38 #include "movemanipulator.h"
39 #include "selectionindicator.h"
40 #include "resizeindicator.h"
44 #include <QScopedPointer>
47 namespace QmlDesigner {
53 class TimerHandler : public QObject
58 TimerHandler(DragTool *tool) : QObject(), m_dragTool(tool) {}
60 void clearMoveDelay();
67 class DragTool : public AbstractFormEditorTool
70 DragTool(FormEditorView* editorView);
73 void mousePressEvent(const QList<QGraphicsItem*> &itemList,
74 QGraphicsSceneMouseEvent *event);
75 void mouseMoveEvent(const QList<QGraphicsItem*> &itemList,
76 QGraphicsSceneMouseEvent *event);
77 void mouseReleaseEvent(const QList<QGraphicsItem*> &itemList,
78 QGraphicsSceneMouseEvent *event);
79 void mouseDoubleClickEvent(const QList<QGraphicsItem*> &itemList,
80 QGraphicsSceneMouseEvent *event);
81 void hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
82 QGraphicsSceneMouseEvent *event);
84 void keyPressEvent(QKeyEvent *event);
85 void keyReleaseEvent(QKeyEvent *keyEvent);
87 void itemsAboutToRemoved(const QList<FormEditorItem*> &itemList);
89 void selectedItemsChanged(const QList<FormEditorItem*> &itemList);
91 void updateMoveManipulator();
93 void beginWithPoint(const QPointF &beginPoint);
96 virtual void dropEvent(QGraphicsSceneDragDropEvent * event);
97 virtual void dragEnterEvent(QGraphicsSceneDragDropEvent * event);
98 virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent * event);
99 virtual void dragMoveEvent(QGraphicsSceneDragDropEvent * event);
101 //void beginWithPoint(const QPointF &beginPoint);
105 void formEditorItemsChanged(const QList<FormEditorItem*> &itemList);
107 void instancesCompleted(const QList<FormEditorItem*> &itemList);
109 void clearMoveDelay();
116 void createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, QmlItemNode parentNode, QPointF scenePos);
117 void createQmlItemNodeFromImage(const QString &imageName, QmlItemNode parentNode, QPointF scenePos);
118 FormEditorItem* calculateContainer(const QPointF &point, FormEditorItem * currentItem = 0);
120 void begin(QPointF scenePos);
121 void end(QPointF scenePos);
122 void move(QPointF scenePos);
124 MoveManipulator m_moveManipulator;
125 SelectionIndicator m_selectionIndicator;
126 QWeakPointer<FormEditorItem> m_movingItem;
127 RewriterTransaction m_rewriterTransaction;
128 QmlItemNode m_dragNode;
129 QScopedPointer<Internal::TimerHandler> m_timerHandler;
131 QPointF m_startPoint;