OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qmldesigner / components / formeditor / dragtool.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
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.
18 **
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.
22 **
23 ** Other Usage
24 **
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.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef DRAGTOOL_H
34 #define DRAGTOOL_H
35
36 #include "abstractformeditortool.h"
37 #include "movemanipulator.h"
38 #include "selectionindicator.h"
39 #include "resizeindicator.h"
40
41 #include <QHash>
42 #include <QObject>
43 #include <QScopedPointer>
44
45
46 namespace QmlDesigner {
47
48 class DragTool;
49
50 namespace Internal {
51
52 class TimerHandler : public QObject
53 {
54     Q_OBJECT
55
56 public:
57     TimerHandler(DragTool *tool) : QObject(), m_dragTool(tool) {}
58 public slots:
59     void clearMoveDelay();
60
61 private:
62     DragTool *m_dragTool;
63 };
64 }
65
66 class DragTool : public AbstractFormEditorTool
67 {
68 public:
69     DragTool(FormEditorView* editorView);
70     virtual ~DragTool();
71
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);
82
83     void keyPressEvent(QKeyEvent *event);
84     void keyReleaseEvent(QKeyEvent *keyEvent);
85
86     void itemsAboutToRemoved(const QList<FormEditorItem*> &itemList);
87
88     void selectedItemsChanged(const QList<FormEditorItem*> &itemList);
89
90     void updateMoveManipulator();
91
92     void beginWithPoint(const QPointF &beginPoint);
93
94
95     virtual void dropEvent(QGraphicsSceneDragDropEvent * event);
96     virtual void dragEnterEvent(QGraphicsSceneDragDropEvent * event);
97     virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent * event);
98     virtual void dragMoveEvent(QGraphicsSceneDragDropEvent * event);
99
100     //void beginWithPoint(const QPointF &beginPoint);
101
102     void clear();
103
104     void formEditorItemsChanged(const QList<FormEditorItem*> &itemList);
105
106     void instancesCompleted(const QList<FormEditorItem*> &itemList);
107
108     void clearMoveDelay();
109
110 protected:
111
112
113 private:
114
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);
118
119     void begin(QPointF scenePos);
120     void end(QPointF scenePos);
121     void move(QPointF scenePos);
122
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;
129     bool m_blockMove;
130     QPointF m_startPoint;
131 };
132
133
134 }
135 #endif // DRAGTOOL_H