summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/abstracttool.cpp54
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/abstracttool.h85
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp121
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h20
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp8
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.h15
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp177
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h11
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h3
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro6
10 files changed, 320 insertions, 180 deletions
diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstracttool.cpp b/src/plugins/qmltooling/qmldbg_inspector/abstracttool.cpp
new file mode 100644
index 0000000..39ced2a
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_inspector/abstracttool.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "abstracttool.h"
+
+#include "abstractviewinspector.h"
+
+namespace QmlJSDebugger {
+
+AbstractTool::AbstractTool(AbstractViewInspector *inspector) :
+ QObject(inspector),
+ m_inspector(inspector)
+{
+}
+
+} // namespace QmlJSDebugger
diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstracttool.h b/src/plugins/qmltooling/qmldbg_inspector/abstracttool.h
new file mode 100644
index 0000000..0a216bf
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_inspector/abstracttool.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ABSTRACTTOOL_H
+#define ABSTRACTTOOL_H
+
+#include <QtCore/QObject>
+
+QT_BEGIN_NAMESPACE
+class QMouseEvent;
+class QKeyEvent;
+class QWheelEvent;
+QT_END_NAMESPACE
+
+namespace QmlJSDebugger {
+
+class AbstractViewInspector;
+
+class AbstractTool : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit AbstractTool(AbstractViewInspector *inspector);
+
+ AbstractViewInspector *inspector() const { return m_inspector; }
+
+ virtual void leaveEvent(QEvent *event) = 0;
+
+ virtual void mousePressEvent(QMouseEvent *event) = 0;
+ virtual void mouseMoveEvent(QMouseEvent *event) = 0;
+ virtual void mouseReleaseEvent(QMouseEvent *event) = 0;
+ virtual void mouseDoubleClickEvent(QMouseEvent *event) = 0;
+
+ virtual void hoverMoveEvent(QMouseEvent *event) = 0;
+ virtual void wheelEvent(QWheelEvent *event) = 0;
+
+ virtual void keyPressEvent(QKeyEvent *event) = 0;
+ virtual void keyReleaseEvent(QKeyEvent *keyEvent) = 0;
+
+private:
+ AbstractViewInspector *m_inspector;
+};
+
+} // namespace QmlJSDebugger
+
+#endif // ABSTRACTTOOL_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp
index a698819..3323d54 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp
@@ -41,6 +41,7 @@
#include "abstractviewinspector.h"
+#include "abstracttool.h"
#include "editor/qmltoolbar.h"
#include "qdeclarativeinspectorprotocol.h"
@@ -50,6 +51,7 @@
#include "QtDeclarative/private/qdeclarativeinspectorservice_p.h"
#include <QtGui/QVBoxLayout>
+#include <QtGui/QMouseEvent>
#include <QtCore/QSettings>
static inline void initEditorResource() { Q_INIT_RESOURCE(editor); }
@@ -99,6 +101,7 @@ ToolBox::~ToolBox()
AbstractViewInspector::AbstractViewInspector(QObject *parent) :
QObject(parent),
m_toolBox(0),
+ m_currentTool(0),
m_showAppOnTop(false),
m_designModeBehavior(false),
m_animationPaused(false),
@@ -284,6 +287,124 @@ void AbstractViewInspector::changeToMarqueeSelectTool()
changeTool(InspectorProtocol::SelectMarqueeTool);
}
+bool AbstractViewInspector::eventFilter(QObject *obj, QEvent *event)
+{
+ if (!designModeBehavior())
+ return QObject::eventFilter(obj, event);
+
+ switch (event->type()) {
+ case QEvent::Leave:
+ if (leaveEvent(event))
+ return true;
+ break;
+ case QEvent::MouseButtonPress:
+ if (mousePressEvent(static_cast<QMouseEvent*>(event)))
+ return true;
+ break;
+ case QEvent::MouseMove:
+ if (mouseMoveEvent(static_cast<QMouseEvent*>(event)))
+ return true;
+ break;
+ case QEvent::MouseButtonRelease:
+ if (mouseReleaseEvent(static_cast<QMouseEvent*>(event)))
+ return true;
+ break;
+ case QEvent::KeyPress:
+ if (keyPressEvent(static_cast<QKeyEvent*>(event)))
+ return true;
+ break;
+ case QEvent::KeyRelease:
+ if (keyReleaseEvent(static_cast<QKeyEvent*>(event)))
+ return true;
+ break;
+ case QEvent::MouseButtonDblClick:
+ if (mouseDoubleClickEvent(static_cast<QMouseEvent*>(event)))
+ return true;
+ break;
+ case QEvent::Wheel:
+ if (wheelEvent(static_cast<QWheelEvent*>(event)))
+ return true;
+ break;
+ default:
+ break;
+ }
+
+ return QObject::eventFilter(obj, event);
+}
+
+bool AbstractViewInspector::leaveEvent(QEvent *event)
+{
+ m_currentTool->leaveEvent(event);
+ return true;
+}
+
+bool AbstractViewInspector::mousePressEvent(QMouseEvent *event)
+{
+ m_currentTool->mousePressEvent(event);
+ return true;
+}
+
+bool AbstractViewInspector::mouseMoveEvent(QMouseEvent *event)
+{
+ if (event->buttons()) {
+ m_currentTool->mouseMoveEvent(event);
+ } else {
+ m_currentTool->hoverMoveEvent(event);
+ }
+ return true;
+}
+
+bool AbstractViewInspector::mouseReleaseEvent(QMouseEvent *event)
+{
+ m_currentTool->mouseReleaseEvent(event);
+ return true;
+}
+
+bool AbstractViewInspector::keyPressEvent(QKeyEvent *event)
+{
+ m_currentTool->keyPressEvent(event);
+ return true;
+}
+
+bool AbstractViewInspector::keyReleaseEvent(QKeyEvent *event)
+{
+ switch (event->key()) {
+ case Qt::Key_V:
+ changeTool(InspectorProtocol::SelectTool);
+ break;
+// disabled because multiselection does not do anything useful without design mode
+// case Qt::Key_M:
+// changeTool(InspectorProtocol::SelectMarqueeTool);
+// break;
+ case Qt::Key_I:
+ changeTool(InspectorProtocol::ColorPickerTool);
+ break;
+ case Qt::Key_Z:
+ changeTool(InspectorProtocol::ZoomTool);
+ break;
+ case Qt::Key_Space:
+ setAnimationPaused(!animationPaused());
+ break;
+ default:
+ break;
+ }
+
+ m_currentTool->keyReleaseEvent(event);
+ return true;
+}
+
+bool AbstractViewInspector::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ m_currentTool->mouseDoubleClickEvent(event);
+ return true;
+}
+
+bool AbstractViewInspector::wheelEvent(QWheelEvent *event)
+{
+ m_currentTool->wheelEvent(event);
+ return true;
+}
+
void AbstractViewInspector::handleMessage(const QByteArray &message)
{
QDataStream ds(message);
diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h
index 0a56ead..7202bcc 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h
@@ -53,10 +53,14 @@
QT_BEGIN_NAMESPACE
class QDeclarativeEngine;
class QDeclarativeInspectorService;
+class QKeyEvent;
+class QMouseEvent;
+class QWheelEvent;
QT_END_NAMESPACE
namespace QmlJSDebugger {
+class AbstractTool;
class ToolBox;
/*
@@ -131,6 +135,21 @@ signals:
void animationSpeedChanged(qreal factor);
void animationPausedChanged(bool paused);
+protected:
+ bool eventFilter(QObject *, QEvent *);
+
+ virtual bool leaveEvent(QEvent *);
+ virtual bool mousePressEvent(QMouseEvent *event);
+ virtual bool mouseMoveEvent(QMouseEvent *event);
+ virtual bool mouseReleaseEvent(QMouseEvent *event);
+ virtual bool keyPressEvent(QKeyEvent *event);
+ virtual bool keyReleaseEvent(QKeyEvent *keyEvent);
+ virtual bool mouseDoubleClickEvent(QMouseEvent *event);
+ virtual bool wheelEvent(QWheelEvent *event);
+
+ AbstractTool *currentTool() const { return m_currentTool; }
+ void setCurrentTool(AbstractTool *tool) { m_currentTool = tool; }
+
private slots:
void handleMessage(const QByteArray &message);
@@ -142,6 +161,7 @@ private:
void createToolBox();
ToolBox *m_toolBox;
+ AbstractTool *m_currentTool;
bool m_showAppOnTop;
bool m_designModeBehavior;
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp
index 4353e97..dce147c 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp
@@ -51,7 +51,7 @@
namespace QmlJSDebugger {
AbstractLiveEditTool::AbstractLiveEditTool(QDeclarativeViewInspector *editorView)
- : QObject(editorView), m_inspector(editorView)
+ : AbstractTool(editorView)
{
}
@@ -62,12 +62,12 @@ AbstractLiveEditTool::~AbstractLiveEditTool()
QDeclarativeViewInspector *AbstractLiveEditTool::inspector() const
{
- return m_inspector;
+ return static_cast<QDeclarativeViewInspector*>(AbstractTool::inspector());
}
QDeclarativeView *AbstractLiveEditTool::view() const
{
- return m_inspector->declarativeView();
+ return inspector()->declarativeView();
}
QGraphicsScene* AbstractLiveEditTool::scene() const
@@ -175,7 +175,7 @@ QString AbstractLiveEditTool::titleForItem(QGraphicsItem *item)
QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(gfxObject);
if (declarativeItem) {
- objectStringId = m_inspector->idStringForObject(declarativeItem);
+ objectStringId = inspector()->idStringForObject(declarativeItem);
}
if (!objectStringId.isEmpty()) {
diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.h b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.h
index accec79..04b5f4e 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.h
@@ -43,7 +43,7 @@
#define ABSTRACTLIVEEDITTOOL_H
#include <QtCore/QList>
-#include <QtCore/QObject>
+#include "../abstracttool.h"
QT_BEGIN_NAMESPACE
class QMouseEvent;
@@ -60,7 +60,7 @@ namespace QmlJSDebugger {
class QDeclarativeViewInspector;
-class AbstractLiveEditTool : public QObject
+class AbstractLiveEditTool : public AbstractTool
{
Q_OBJECT
public:
@@ -68,16 +68,8 @@ public:
virtual ~AbstractLiveEditTool();
- virtual void mousePressEvent(QMouseEvent *event) = 0;
- virtual void mouseMoveEvent(QMouseEvent *event) = 0;
- virtual void mouseReleaseEvent(QMouseEvent *event) = 0;
- virtual void mouseDoubleClickEvent(QMouseEvent *event) = 0;
+ void leaveEvent(QEvent *) {}
- virtual void hoverMoveEvent(QMouseEvent *event) = 0;
- virtual void wheelEvent(QWheelEvent *event) = 0;
-
- virtual void keyPressEvent(QKeyEvent *event) = 0;
- virtual void keyReleaseEvent(QKeyEvent *keyEvent) = 0;
virtual void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList) = 0;
virtual void clear() = 0;
@@ -104,7 +96,6 @@ protected:
QGraphicsScene *scene() const;
private:
- QDeclarativeViewInspector *m_inspector;
QList<QGraphicsItem*> m_itemList;
};
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp
index 462fd19..67a581d 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp
@@ -49,13 +49,9 @@
#include "editor/boundingrecthighlighter.h"
#include <QtDeclarative/QDeclarativeItem>
-#include <QtDeclarative/QDeclarativeEngine>
-#include <QtDeclarative/QDeclarativeContext>
-#include <QtDeclarative/QDeclarativeExpression>
#include <QtGui/QWidget>
#include <QtGui/QMouseEvent>
#include <QtGui/QGraphicsObject>
-#include <QtGui/QApplication>
namespace QmlJSDebugger {
@@ -79,7 +75,7 @@ QDeclarativeViewInspector::QDeclarativeViewInspector(QDeclarativeView *view,
data->zoomTool = new ZoomTool(this);
data->colorPickerTool = new ColorPickerTool(this);
data->boundingRectHighlighter = new BoundingRectHighlighter(this);
- data->currentTool = data->selectionTool;
+ setCurrentTool(data->selectionTool);
// to capture ChildRemoved event when viewport changes
data->view->installEventFilter(this);
@@ -142,6 +138,11 @@ void QDeclarativeViewInspector::changeTool(InspectorProtocol::Tool tool)
}
}
+AbstractLiveEditTool *QDeclarativeViewInspector::currentTool() const
+{
+ return static_cast<AbstractLiveEditTool*>(AbstractViewInspector::currentTool());
+}
+
QDeclarativeEngine *QDeclarativeViewInspector::declarativeEngine() const
{
return data->view->engine();
@@ -181,143 +182,39 @@ bool QDeclarativeViewInspector::eventFilter(QObject *obj, QEvent *event)
return QObject::eventFilter(obj, event);
}
- // Event from viewport
- switch (event->type()) {
- case QEvent::Leave: {
- if (leaveEvent(event))
- return true;
- break;
- }
- case QEvent::MouseButtonPress: {
- if (mousePressEvent(static_cast<QMouseEvent*>(event)))
- return true;
- break;
- }
- case QEvent::MouseMove: {
- if (mouseMoveEvent(static_cast<QMouseEvent*>(event)))
- return true;
- break;
- }
- case QEvent::MouseButtonRelease: {
- if (mouseReleaseEvent(static_cast<QMouseEvent*>(event)))
- return true;
- break;
- }
- case QEvent::KeyPress: {
- if (keyPressEvent(static_cast<QKeyEvent*>(event)))
- return true;
- break;
- }
- case QEvent::KeyRelease: {
- if (keyReleaseEvent(static_cast<QKeyEvent*>(event)))
- return true;
- break;
- }
- case QEvent::MouseButtonDblClick: {
- if (mouseDoubleClickEvent(static_cast<QMouseEvent*>(event)))
- return true;
- break;
- }
- case QEvent::Wheel: {
- if (wheelEvent(static_cast<QWheelEvent*>(event)))
- return true;
- break;
- }
- default: {
- break;
- }
- } //switch
-
- // standard event processing
- return QObject::eventFilter(obj, event);
+ return AbstractViewInspector::eventFilter(obj, event);
}
-bool QDeclarativeViewInspector::leaveEvent(QEvent * /*event*/)
+bool QDeclarativeViewInspector::leaveEvent(QEvent *event)
{
- if (!designModeBehavior())
- return false;
data->clearHighlight();
- return true;
+ return AbstractViewInspector::leaveEvent(event);
}
bool QDeclarativeViewInspector::mousePressEvent(QMouseEvent *event)
{
- if (!designModeBehavior())
- return false;
data->cursorPos = event->pos();
- data->currentTool->mousePressEvent(event);
- return true;
+ return AbstractViewInspector::mousePressEvent(event);
}
bool QDeclarativeViewInspector::mouseMoveEvent(QMouseEvent *event)
{
- if (!designModeBehavior()) {
- data->clearEditorItems();
- return false;
- }
data->cursorPos = event->pos();
QList<QGraphicsItem*> selItems = data->selectableItems(event->pos());
if (!selItems.isEmpty()) {
- declarativeView()->setToolTip(data->currentTool->titleForItem(selItems.first()));
+ declarativeView()->setToolTip(currentTool()->titleForItem(selItems.first()));
} else {
declarativeView()->setToolTip(QString());
}
- if (event->buttons()) {
- data->currentTool->mouseMoveEvent(event);
- } else {
- data->currentTool->hoverMoveEvent(event);
- }
- return true;
+
+ return AbstractViewInspector::mouseMoveEvent(event);
}
bool QDeclarativeViewInspector::mouseReleaseEvent(QMouseEvent *event)
{
- if (!designModeBehavior())
- return false;
-
data->cursorPos = event->pos();
- data->currentTool->mouseReleaseEvent(event);
- return true;
-}
-
-bool QDeclarativeViewInspector::keyPressEvent(QKeyEvent *event)
-{
- if (!designModeBehavior())
- return false;
-
- data->currentTool->keyPressEvent(event);
- return true;
-}
-
-bool QDeclarativeViewInspector::keyReleaseEvent(QKeyEvent *event)
-{
- if (!designModeBehavior())
- return false;
-
- switch (event->key()) {
- case Qt::Key_V:
- changeTool(InspectorProtocol::SelectTool);
- break;
-// disabled because multiselection does not do anything useful without design mode
-// case Qt::Key_M:
-// changeTool(InspectorProtocol::SelectMarqueeTool);
-// break;
- case Qt::Key_I:
- changeTool(InspectorProtocol::ColorPickerTool);
- break;
- case Qt::Key_Z:
- changeTool(InspectorProtocol::ZoomTool);
- break;
- case Qt::Key_Space:
- setAnimationPaused(!animationPaused());
- break;
- default:
- break;
- }
-
- data->currentTool->keyReleaseEvent(event);
- return true;
+ return AbstractViewInspector::mouseReleaseEvent(event);
}
void QDeclarativeViewInspector::reparentQmlObject(QObject *object, QObject *newParent)
@@ -340,22 +237,6 @@ void QDeclarativeViewInspectorPrivate::_q_removeFromSelection(QObject *obj)
setSelectedItems(items);
}
-bool QDeclarativeViewInspector::mouseDoubleClickEvent(QMouseEvent * /*event*/)
-{
- if (!designModeBehavior())
- return false;
-
- return true;
-}
-
-bool QDeclarativeViewInspector::wheelEvent(QWheelEvent *event)
-{
- if (!designModeBehavior())
- return false;
- data->currentTool->wheelEvent(event);
- return true;
-}
-
void QDeclarativeViewInspectorPrivate::setSelectedItemsForTools(const QList<QGraphicsItem *> &items)
{
foreach (const QWeakPointer<QGraphicsObject> &obj, currentSelection) {
@@ -378,7 +259,7 @@ void QDeclarativeViewInspectorPrivate::setSelectedItemsForTools(const QList<QGra
}
}
- currentTool->updateSelectedItems();
+ q->currentTool()->updateSelectedItems();
}
void QDeclarativeViewInspectorPrivate::setSelectedItems(const QList<QGraphicsItem *> &items)
@@ -468,7 +349,6 @@ QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::selectableItems(
void QDeclarativeViewInspectorPrivate::changeToSingleSelectTool()
{
- currentToolMode = Constants::SelectionToolMode;
selectionTool->setRubberbandSelectionMode(false);
changeToSelectTool();
@@ -479,19 +359,18 @@ void QDeclarativeViewInspectorPrivate::changeToSingleSelectTool()
void QDeclarativeViewInspectorPrivate::changeToSelectTool()
{
- if (currentTool == selectionTool)
+ if (q->currentTool() == selectionTool)
return;
- currentTool->clear();
- currentTool = selectionTool;
- currentTool->clear();
- currentTool->updateSelectedItems();
+ q->currentTool()->clear();
+ q->setCurrentTool(selectionTool);
+ q->currentTool()->clear();
+ q->currentTool()->updateSelectedItems();
}
void QDeclarativeViewInspectorPrivate::changeToMarqueeSelectTool()
{
changeToSelectTool();
- currentToolMode = Constants::MarqueeSelectionToolMode;
selectionTool->setRubberbandSelectionMode(true);
emit q->marqueeSelectToolActivated();
@@ -500,10 +379,9 @@ void QDeclarativeViewInspectorPrivate::changeToMarqueeSelectTool()
void QDeclarativeViewInspectorPrivate::changeToZoomTool()
{
- currentToolMode = Constants::ZoomMode;
- currentTool->clear();
- currentTool = zoomTool;
- currentTool->clear();
+ q->currentTool()->clear();
+ q->setCurrentTool(zoomTool);
+ q->currentTool()->clear();
emit q->zoomToolActivated();
q->sendCurrentTool(Constants::ZoomMode);
@@ -511,13 +389,12 @@ void QDeclarativeViewInspectorPrivate::changeToZoomTool()
void QDeclarativeViewInspectorPrivate::changeToColorPickerTool()
{
- if (currentTool == colorPickerTool)
+ if (q->currentTool() == colorPickerTool)
return;
- currentToolMode = Constants::ColorPickerMode;
- currentTool->clear();
- currentTool = colorPickerTool;
- currentTool->clear();
+ q->currentTool()->clear();
+ q->setCurrentTool(colorPickerTool);
+ q->currentTool()->clear();
emit q->colorPickerActivated();
q->sendCurrentTool(Constants::ColorPickerMode);
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h
index c08ef54..3cd53ff 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h
@@ -50,12 +50,9 @@
#include <QtCore/QScopedPointer>
#include <QtDeclarative/QDeclarativeView>
-QT_FORWARD_DECLARE_CLASS(QDeclarativeItem)
-QT_FORWARD_DECLARE_CLASS(QMouseEvent)
-QT_FORWARD_DECLARE_CLASS(QToolBar)
-
namespace QmlJSDebugger {
+class AbstractLiveEditTool;
class QDeclarativeViewInspectorPrivate;
class QDeclarativeViewInspector : public AbstractViewInspector
@@ -88,12 +85,8 @@ protected:
bool mousePressEvent(QMouseEvent *event);
bool mouseMoveEvent(QMouseEvent *event);
bool mouseReleaseEvent(QMouseEvent *event);
- bool keyPressEvent(QKeyEvent *event);
- bool keyReleaseEvent(QKeyEvent *keyEvent);
- bool mouseDoubleClickEvent(QMouseEvent *event);
- bool wheelEvent(QWheelEvent *event);
- void setSelectedItemsForTools(QList<QGraphicsItem *> items);
+ AbstractLiveEditTool *currentTool() const;
private:
Q_DISABLE_COPY(QDeclarativeViewInspector)
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h
index cd8d749..a6e6a3c 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h
@@ -73,9 +73,6 @@ public:
QPointF cursorPos;
QList<QWeakPointer<QGraphicsObject> > currentSelection;
- Constants::DesignTool currentToolMode;
- AbstractLiveEditTool *currentTool;
-
LiveSelectionTool *selectionTool;
ZoomTool *zoomTool;
ColorPickerTool *colorPickerTool;
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro
index 6c56e62..0116441 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro
+++ b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro
@@ -22,7 +22,8 @@ SOURCES += \
editor/zoomtool.cpp \
editor/colorpickertool.cpp \
editor/qmltoolbar.cpp \
- editor/toolbarcolorbox.cpp
+ editor/toolbarcolorbox.cpp \
+ abstracttool.cpp
HEADERS += \
abstractviewinspector.h \
@@ -43,7 +44,8 @@ HEADERS += \
editor/zoomtool.h \
editor/colorpickertool.h \
editor/qmltoolbar.h \
- editor/toolbarcolorbox.h
+ editor/toolbarcolorbox.h \
+ abstracttool.h
RESOURCES += editor/editor.qrc