OSDN Git Service

It's 2011 now.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qmldesigner / components / formeditor / movetool.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 (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
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
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
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.
24 **
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.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef MOVETOOL_H
35 #define MOVETOOL_H
36
37 #include "abstractformeditortool.h"
38 #include "movemanipulator.h"
39 #include "selectionindicator.h"
40 #include "resizeindicator.h"
41
42 #include <QHash>
43
44
45 namespace QmlDesigner {
46
47
48 class MoveTool : public AbstractFormEditorTool
49 {
50 public:
51     MoveTool(FormEditorView* editorView);
52     ~MoveTool();
53
54     void mousePressEvent(const QList<QGraphicsItem*> &itemList,
55                          QGraphicsSceneMouseEvent *event);
56     void mouseMoveEvent(const QList<QGraphicsItem*> &itemList,
57                         QGraphicsSceneMouseEvent *event);
58     void mouseReleaseEvent(const QList<QGraphicsItem*> &itemList,
59                            QGraphicsSceneMouseEvent *event);
60     void mouseDoubleClickEvent(const QList<QGraphicsItem*> &itemList,
61                                QGraphicsSceneMouseEvent *event);
62     void hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
63                         QGraphicsSceneMouseEvent *event);
64     void keyPressEvent(QKeyEvent *event);
65     void keyReleaseEvent(QKeyEvent *keyEvent);
66
67     void itemsAboutToRemoved(const QList<FormEditorItem*> &itemList);
68
69     void selectedItemsChanged(const QList<FormEditorItem*> &itemList);
70
71     void instancesCompleted(const QList<FormEditorItem*> &/*itemList*/);
72
73     void updateMoveManipulator();
74
75     void beginWithPoint(const QPointF &beginPoint);
76
77     void clear();
78
79     void formEditorItemsChanged(const QList<FormEditorItem*> &itemList);
80
81 protected:
82     static bool haveSameParent(const QList<FormEditorItem*> &itemList);
83
84     static QList<FormEditorItem*> movingItems(const QList<FormEditorItem*> &selectedItemList);
85
86     static FormEditorItem* containerFormEditorItem(const QList<QGraphicsItem*> &itemUnderMouseList,
87                                             const QList<FormEditorItem*> &selectedItemList);
88
89     static bool isAncestorOfAllItems(FormEditorItem* maybeAncestorItem,
90                                     const QList<FormEditorItem*> &itemList);
91     static FormEditorItem* ancestorIfOtherItemsAreChild(const QList<FormEditorItem*> &itemList);
92
93 private:
94     MoveManipulator m_moveManipulator;
95     SelectionIndicator m_selectionIndicator;
96     ResizeIndicator m_resizeIndicator;
97     QList<FormEditorItem*> m_movingItems;
98 };
99
100 }
101 #endif // MOVETOOL_H