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 **************************************************************************/
34 #ifndef ABSTRACTFORMEDITORTOOL_H
35 #define ABSTRACTFORMEDITORTOOL_H
37 #include "formeditoritem.h"
43 namespace QmlDesigner {
47 class AbstractFormEditorTool
51 AbstractFormEditorTool(FormEditorView* view);
53 virtual ~AbstractFormEditorTool();
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);
64 virtual void hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
65 QGraphicsSceneMouseEvent *event) = 0;
67 virtual void dropEvent(QGraphicsSceneDragDropEvent * event);
68 virtual void dragEnterEvent(QGraphicsSceneDragDropEvent * event);
69 virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent * event);
70 virtual void dragMoveEvent(QGraphicsSceneDragDropEvent * event);
72 virtual void keyPressEvent(QKeyEvent *event) = 0;
73 virtual void keyReleaseEvent(QKeyEvent *keyEvent) = 0;
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;
82 virtual void formEditorItemsChanged(const QList<FormEditorItem*> &itemList) = 0;
84 virtual void instancesCompleted(const QList<FormEditorItem*> &itemList) = 0;
86 void setItems(const QList<FormEditorItem*> &itemList);
87 QList<FormEditorItem*> items() const;
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);
95 static FormEditorItem* topFormEditorItem(const QList<QGraphicsItem*> &itemList);
96 static FormEditorItem* topFormEditorItemWithRootItem(const QList<QGraphicsItem*> &itemList);
99 virtual void selectedItemsChanged(const QList<FormEditorItem*> &itemList) = 0;
102 FormEditorView *view() const;
103 FormEditorScene* scene() const;
105 FormEditorView *m_view;
106 QList<FormEditorItem*> m_itemList;
111 #endif // ABSTRACTFORMEDITORTOOL_H