OSDN Git Service

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