aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-07-15 18:01:53 +0200
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-08-04 13:35:07 +0000
commitc7c6dc833936751fc8777f76842f5e28ced71ee8 (patch)
treeef6dc45d8a88c99ec5db7bd3f82e3e8ac31712bb
parentd4d7bb6394f01eee118e6e37b0826b878f025341 (diff)
Remove extra layer of indirection from inspector service
We are not loading any secondary inspector plugins anymore, so the logic to select them is unnecessary now. Change-Id: Ic44c49e41c6bff4b19ce527df4657c6d73c0c82b Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro3
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorinterface.h70
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp58
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.h7
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.cpp80
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.h70
6 files changed, 16 insertions, 272 deletions
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro
index 3a1de3fb19..2a058d0e68 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro
+++ b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro
@@ -8,7 +8,6 @@ load(qt_plugin)
INCLUDEPATH *= $$PWD $$PWD/../shared
SOURCES += \
- $$PWD/qtquick2plugin.cpp \
$$PWD/highlight.cpp \
$$PWD/qquickviewinspector.cpp \
$$PWD/abstracttool.cpp \
@@ -17,13 +16,11 @@ SOURCES += \
$$PWD/qqmlinspectorservice.cpp
HEADERS += \
- $$PWD/qtquick2plugin.h \
$$PWD/highlight.h \
$$PWD/qquickviewinspector.h \
$$PWD/qqmlinspectorservice.h \
$$PWD/abstracttool.h \
$$PWD/abstractviewinspector.h \
- $$PWD/qqmlinspectorinterface.h \
$$PWD/inspecttool.h
OTHER_FILES += \
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorinterface.h b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorinterface.h
deleted file mode 100644
index a31ccaee20..0000000000
--- a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorinterface.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQMLINSPECTORINTERFACE_H
-#define QQMLINSPECTORINTERFACE_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtQml/qtqmlglobal.h>
-#include <private/qqmlglobal_p.h>
-#include <private/qqmldebugservice_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QQmlInspectorInterface
-{
-public:
- QQmlInspectorInterface() {}
- virtual ~QQmlInspectorInterface() {}
-
- virtual bool canHandleView(QObject *view) = 0;
-
- virtual void activate(QQmlDebugService *service, QObject *view) = 0;
- virtual void deactivate() = 0;
-
- virtual void clientMessage(const QByteArray &message) = 0;
-};
-
-QT_END_NAMESPACE
-
-#endif // QQMLINSPECTORINTERFACE_H
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp
index 16e1c3e2ec..0b085cc960 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp
@@ -32,8 +32,7 @@
****************************************************************************/
#include "qqmlinspectorservice.h"
-#include "qqmlinspectorinterface.h"
-#include "qtquick2plugin.h"
+#include "qquickviewinspector.h"
#include <private/qqmlglobal_p.h>
@@ -45,7 +44,7 @@
QT_BEGIN_NAMESPACE
QQmlInspectorServiceImpl::QQmlInspectorServiceImpl(QObject *parent):
- QQmlInspectorService(1, parent), m_currentInspectorPlugin(0)
+ QQmlInspectorService(1, parent), m_currentInspector(0)
{
}
@@ -68,42 +67,18 @@ void QQmlInspectorServiceImpl::stateChanged(State /*state*/)
void QQmlInspectorServiceImpl::updateState()
{
- if (m_views.isEmpty()) {
- if (m_currentInspectorPlugin) {
- m_currentInspectorPlugin->deactivate();
- m_currentInspectorPlugin = 0;
- }
- return;
- }
-
- if (state() == Enabled) {
- if (m_inspectorPlugins.isEmpty())
- loadInspectorPlugins();
+ delete m_currentInspector;
+ m_currentInspector = 0;
- if (m_inspectorPlugins.isEmpty()) {
- qWarning() << "QQmlInspector: No plugins found.";
- return;
- }
-
- m_currentInspectorPlugin = 0;
- foreach (QQmlInspectorInterface *inspector, m_inspectorPlugins) {
- if (inspector->canHandleView(m_views.first())) {
- m_currentInspectorPlugin = inspector;
- break;
- }
- }
+ if (m_views.isEmpty() || state() != Enabled)
+ return;
- if (!m_currentInspectorPlugin) {
- qWarning() << "QQmlInspector: No plugin available for view '" << m_views.first()->metaObject()->className() << "'.";
- return;
- }
- m_currentInspectorPlugin->activate(this, m_views.first());
- } else {
- if (m_currentInspectorPlugin) {
- m_currentInspectorPlugin->deactivate();
- m_currentInspectorPlugin = 0;
- }
- }
+ QQuickView *qtQuickView = qobject_cast<QQuickView*>(m_views.first());
+ if (qtQuickView)
+ m_currentInspector = new QmlJSDebugger::QQuickViewInspector(this, qtQuickView, this);
+ else
+ qWarning() << "QQmlInspector: No inspector available for view '"
+ << m_views.first()->metaObject()->className() << "'.";
}
void QQmlInspectorServiceImpl::messageReceived(const QByteArray &message)
@@ -113,13 +88,8 @@ void QQmlInspectorServiceImpl::messageReceived(const QByteArray &message)
void QQmlInspectorServiceImpl::processMessage(const QByteArray &message)
{
- if (m_currentInspectorPlugin)
- m_currentInspectorPlugin->clientMessage(message);
-}
-
-void QQmlInspectorServiceImpl::loadInspectorPlugins()
-{
- m_inspectorPlugins << new QmlJSDebugger::QtQuick2Plugin;
+ if (m_currentInspector)
+ m_currentInspector->handleMessage(message);
}
QQmlDebugService *QQmlInspectorServiceFactory::create(const QString &key)
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.h b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.h
index 409a3fe2aa..3197951612 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.h
@@ -53,8 +53,7 @@
QT_BEGIN_NAMESPACE
-
-class QQmlInspectorInterface;
+namespace QmlJSDebugger { class AbstractViewInspector; }
class QQmlInspectorServiceImpl : public QQmlInspectorService
{
@@ -76,11 +75,9 @@ private Q_SLOTS:
private:
friend class QQmlInspectorServiceFactory;
- void loadInspectorPlugins();
QList<QObject*> m_views;
- QQmlInspectorInterface *m_currentInspectorPlugin;
- QList<QQmlInspectorInterface*> m_inspectorPlugins;
+ QmlJSDebugger::AbstractViewInspector *m_currentInspector;
};
class QQmlInspectorServiceFactory : public QQmlDebugServiceFactory
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.cpp b/src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.cpp
deleted file mode 100644
index b755c352f3..0000000000
--- a/src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qtquick2plugin.h"
-#include "qquickviewinspector.h"
-#include "qqmlinspectorservice.h"
-
-#include <QtCore/qplugin.h>
-#include <QtQuick/QQuickView>
-
-QT_BEGIN_NAMESPACE
-
-namespace QmlJSDebugger {
-
-QtQuick2Plugin::QtQuick2Plugin() :
- m_inspector(0)
-{
-}
-
-QtQuick2Plugin::~QtQuick2Plugin()
-{
- delete m_inspector;
-}
-
-bool QtQuick2Plugin::canHandleView(QObject *view)
-{
- return qobject_cast<QQuickView*>(view);
-}
-
-void QtQuick2Plugin::activate(QQmlDebugService *service, QObject *view)
-{
- QQuickView *qtQuickView = qobject_cast<QQuickView*>(view);
- Q_ASSERT(qtQuickView);
- m_inspector = new QQuickViewInspector(service, qtQuickView, qtQuickView);
-}
-
-void QtQuick2Plugin::deactivate()
-{
- delete m_inspector;
-}
-
-void QtQuick2Plugin::clientMessage(const QByteArray &message)
-{
- if (m_inspector)
- m_inspector->handleMessage(message);
-}
-
-} // namespace QmlJSDebugger
-
-QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.h b/src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.h
deleted file mode 100644
index 3e0704f19a..0000000000
--- a/src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTQUICK2PLUGINPLUGIN_H
-#define QTQUICK2PLUGINPLUGIN_H
-
-#include <QtCore/QPointer>
-#include "qqmlinspectorinterface.h"
-#include <private/qqmldebugservice_p.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace QmlJSDebugger {
-
-class AbstractViewInspector;
-
-class QtQuick2Plugin : public QObject, public QQmlInspectorInterface
-{
- Q_OBJECT
- Q_DISABLE_COPY(QtQuick2Plugin)
-
-public:
- QtQuick2Plugin();
- ~QtQuick2Plugin();
-
- // QQmlInspectorInterface
- bool canHandleView(QObject *view);
- void activate(QQmlDebugService *service, QObject *view);
- void deactivate();
- void clientMessage(const QByteArray &message);
-
-private:
- QPointer<AbstractViewInspector> m_inspector;
-};
-
-} // namespace QmlJSDebugger
-
-QT_END_NAMESPACE
-
-#endif // QTQUICK2PLUGINPLUGIN_H