OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / share / qtcreator / qml / qmljsdebugger / editor / liveselectiontool.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 LIVESELECTIONTOOL_H
34 #define LIVESELECTIONTOOL_H
35
36
37 #include "abstractliveedittool.h"
38 #include "liverubberbandselectionmanipulator.h"
39 #include "livesingleselectionmanipulator.h"
40 #include "liveselectionindicator.h"
41
42 #include <QtCore/QList>
43 #include <QtCore/QTime>
44
45 QT_FORWARD_DECLARE_CLASS(QGraphicsItem)
46 QT_FORWARD_DECLARE_CLASS(QMouseEvent)
47 QT_FORWARD_DECLARE_CLASS(QKeyEvent)
48 QT_FORWARD_DECLARE_CLASS(QAction)
49
50 namespace QmlJSDebugger {
51
52 class LiveSelectionTool : public AbstractLiveEditTool
53 {
54     Q_OBJECT
55
56 public:
57     LiveSelectionTool(QDeclarativeViewObserver* editorView);
58     ~LiveSelectionTool();
59
60     void mousePressEvent(QMouseEvent *event);
61     void mouseMoveEvent(QMouseEvent *event);
62     void mouseReleaseEvent(QMouseEvent *event);
63     void mouseDoubleClickEvent(QMouseEvent *event);
64     void hoverMoveEvent(QMouseEvent *event);
65     void keyPressEvent(QKeyEvent *event);
66     void keyReleaseEvent(QKeyEvent *keyEvent);
67     void wheelEvent(QWheelEvent *event);
68
69     void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList);
70 //    QVariant itemChange(const QList<QGraphicsItem*> &itemList,
71 //                        QGraphicsItem::GraphicsItemChange change,
72 //                        const QVariant &value );
73
74 //    void update();
75
76     void clear();
77
78     void selectedItemsChanged(const QList<QGraphicsItem*> &itemList);
79
80     void selectUnderPoint(QMouseEvent *event);
81
82     void setSelectOnlyContentItems(bool selectOnlyContentItems);
83
84     void setRubberbandSelectionMode(bool value);
85
86 private slots:
87     void contextMenuElementSelected();
88     void contextMenuElementHovered(QAction *action);
89     void repaintBoundingRects();
90
91 private:
92     void createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos);
93     LiveSingleSelectionManipulator::SelectionType getSelectionType(Qt::KeyboardModifiers modifiers);
94     bool alreadySelected(const QList<QGraphicsItem*> &itemList) const;
95
96 private:
97     bool m_rubberbandSelectionMode;
98     LiveRubberBandSelectionManipulator m_rubberbandSelectionManipulator;
99     LiveSingleSelectionManipulator m_singleSelectionManipulator;
100     LiveSelectionIndicator m_selectionIndicator;
101     //ResizeIndicator m_resizeIndicator;
102     QTime m_mousePressTimer;
103     bool m_selectOnlyContentItems;
104
105     QList<QWeakPointer<QGraphicsObject> > m_selectedItemList;
106
107     QList<QGraphicsItem*> m_contextMenuItemList;
108 };
109
110 } // namespace QmlJSDebugger
111
112 #endif // LIVESELECTIONTOOL_H