OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qmldesigner / components / formeditor / abstractformeditortool.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 ABSTRACTFORMEDITORTOOL_H
34 #define ABSTRACTFORMEDITORTOOL_H
35
36 #include "formeditoritem.h"
37
38 QT_BEGIN_NAMESPACE
39 class QGraphicsItem;
40 QT_END_NAMESPACE
41
42 namespace QmlDesigner {
43
44 class FormEditorView;
45
46 class AbstractFormEditorTool
47 {
48
49 public:
50     AbstractFormEditorTool(FormEditorView* view);
51
52     virtual ~AbstractFormEditorTool();
53
54     virtual void mousePressEvent(const QList<QGraphicsItem*> &itemList,
55                          QGraphicsSceneMouseEvent *event) = 0;
56     virtual void mouseMoveEvent(const QList<QGraphicsItem*> &itemList,
57                         QGraphicsSceneMouseEvent *event) = 0;
58     virtual void mouseReleaseEvent(const QList<QGraphicsItem*> &itemList,
59                            QGraphicsSceneMouseEvent *event) = 0;
60     virtual void mouseDoubleClickEvent(const QList<QGraphicsItem*> &itemList,
61                                        QGraphicsSceneMouseEvent *event);
62
63     virtual void hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
64                         QGraphicsSceneMouseEvent *event) = 0;
65
66     virtual void dropEvent(QGraphicsSceneDragDropEvent * event);
67     virtual void dragEnterEvent(QGraphicsSceneDragDropEvent * event);
68     virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent * event);
69     virtual void dragMoveEvent(QGraphicsSceneDragDropEvent * event);
70
71     virtual void keyPressEvent(QKeyEvent *event) = 0;
72     virtual void keyReleaseEvent(QKeyEvent *keyEvent) = 0;
73
74     virtual void itemsAboutToRemoved(const QList<FormEditorItem*> &itemList) = 0;
75     //    virtual QVariant itemChange(QList<QGraphicsItem*> itemList,
76 //                        QGraphicsItem::GraphicsItemChange change,
77 //                        const QVariant &value ) = 0;
78 //    virtual void update() = 0;
79     virtual void clear() = 0;
80
81     virtual void formEditorItemsChanged(const QList<FormEditorItem*> &itemList) = 0;
82
83     virtual void instancesCompleted(const QList<FormEditorItem*> &itemList) = 0;
84
85     void setItems(const QList<FormEditorItem*> &itemList);
86     QList<FormEditorItem*> items() const;
87
88     static QGraphicsItem* topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList);
89     static FormEditorItem* topMovableFormEditorItem(const QList<QGraphicsItem*> &itemList);
90     bool topItemIsMovable(const QList<QGraphicsItem*> &itemList);
91     bool topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList);
92     bool topItemIsResizeHandle(const QList<QGraphicsItem*> &itemList);
93
94     static FormEditorItem* topFormEditorItem(const QList<QGraphicsItem*> &itemList);
95     static FormEditorItem* topFormEditorItemWithRootItem(const QList<QGraphicsItem*> &itemList);
96 protected:
97
98     virtual void selectedItemsChanged(const QList<FormEditorItem*> &itemList) = 0;
99
100
101     FormEditorView *view() const;
102     FormEditorScene* scene() const;
103 private:
104     FormEditorView *m_view;
105     QList<FormEditorItem*> m_itemList;
106 };
107
108 }
109
110 #endif // ABSTRACTFORMEDITORTOOL_H