1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
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.
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef LIVESELECTIONTOOL_H
34 #define LIVESELECTIONTOOL_H
37 #include "abstractliveedittool.h"
38 #include "liverubberbandselectionmanipulator.h"
39 #include "livesingleselectionmanipulator.h"
40 #include "liveselectionindicator.h"
42 #include <QtCore/QList>
43 #include <QtCore/QTime>
45 QT_FORWARD_DECLARE_CLASS(QGraphicsItem)
46 QT_FORWARD_DECLARE_CLASS(QMouseEvent)
47 QT_FORWARD_DECLARE_CLASS(QKeyEvent)
48 QT_FORWARD_DECLARE_CLASS(QAction)
50 namespace QmlJSDebugger {
52 class LiveSelectionTool : public AbstractLiveEditTool
57 LiveSelectionTool(QDeclarativeViewObserver* editorView);
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);
69 void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList);
70 // QVariant itemChange(const QList<QGraphicsItem*> &itemList,
71 // QGraphicsItem::GraphicsItemChange change,
72 // const QVariant &value );
78 void selectedItemsChanged(const QList<QGraphicsItem*> &itemList);
80 void selectUnderPoint(QMouseEvent *event);
82 void setSelectOnlyContentItems(bool selectOnlyContentItems);
84 void setRubberbandSelectionMode(bool value);
87 void contextMenuElementSelected();
88 void contextMenuElementHovered(QAction *action);
89 void repaintBoundingRects();
92 void createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos);
93 LiveSingleSelectionManipulator::SelectionType getSelectionType(Qt::KeyboardModifiers modifiers);
94 bool alreadySelected(const QList<QGraphicsItem*> &itemList) const;
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;
105 QList<QWeakPointer<QGraphicsObject> > m_selectedItemList;
107 QList<QGraphicsItem*> m_contextMenuItemList;
110 } // namespace QmlJSDebugger
112 #endif // LIVESELECTIONTOOL_H