Pass QQmlDebugService to AbstractViewInspector
authorUlf Hermann <ulf.hermann@theqtcompany.com>
Wed, 15 Jul 2015 15:36:28 +0000 (17:36 +0200)
committerUlf Hermann <ulf.hermann@theqtcompany.com>
Tue, 4 Aug 2015 13:35:03 +0000 (13:35 +0000)
This way we don't have to look up the implementation in order to send
messages.

Change-Id: I70cb122785875cf8b4ba6f7f2afd62cca77c8abb
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp
src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h
src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorinterface.h
src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp
src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.h
src/plugins/qmltooling/qmldbg_inspector/qquickviewinspector.cpp
src/plugins/qmltooling/qmldbg_inspector/qquickviewinspector.h
src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.cpp
src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.h

index ecbe31f2f63c41d81d317dac16099fe9c3ed94e3..fa6dca7aca08839b26a7b91818a1847db53ad3fe 100644 (file)
@@ -33,7 +33,6 @@
 
 #include "abstractviewinspector.h"
 #include "abstracttool.h"
-#include "qqmlinspectorservice.h"
 
 #include <QtCore/QDebug>
 #include <QtQml/QQmlEngine>
@@ -80,10 +79,10 @@ const char CLEAR_CACHE[] = "clearCache";
 namespace QmlJSDebugger {
 
 
-AbstractViewInspector::AbstractViewInspector(QObject *parent) :
+AbstractViewInspector::AbstractViewInspector(QQmlDebugService *service, QObject *parent) :
     QObject(parent),
     m_enabled(false),
-    m_debugService(QQmlDebugConnector::service<QQmlInspectorServiceImpl>()),
+    m_debugService(service),
     m_eventId(0),
     m_reloadEventId(-1)
 {
index 342e6359d7668563282ac6af54559f1c54348974..8f7ad4ac5bdd93c633907a498af57963c50fad92 100644 (file)
@@ -58,7 +58,7 @@ class AbstractViewInspector : public QObject
     Q_OBJECT
 
 public:
-    explicit AbstractViewInspector(QObject *parent = 0);
+    explicit AbstractViewInspector(QQmlDebugService *service, QObject *parent = 0);
 
     void handleMessage(const QByteArray &message);
 
index cd9acaba2ade01e56f9f419668ab89eb962bf69d..a31ccaee20fd60d8ee7559c06fc6cb11d0e68def 100644 (file)
@@ -47,6 +47,7 @@
 
 #include <QtQml/qtqmlglobal.h>
 #include <private/qqmlglobal_p.h>
+#include <private/qqmldebugservice_p.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -58,7 +59,7 @@ public:
 
     virtual bool canHandleView(QObject *view) = 0;
 
-    virtual void activate(QObject *view) = 0;
+    virtual void activate(QQmlDebugService *service, QObject *view) = 0;
     virtual void deactivate() = 0;
 
     virtual void clientMessage(const QByteArray &message) = 0;
index 848e6357b2095966cb940b77156efab7fd5c2c10..16e1c3e2ecc9ba8a1283c7eb3fd39bdc94d01d43 100644 (file)
@@ -97,7 +97,7 @@ void QQmlInspectorServiceImpl::updateState()
             qWarning() << "QQmlInspector: No plugin available for view '" << m_views.first()->metaObject()->className() << "'.";
             return;
         }
-        m_currentInspectorPlugin->activate(m_views.first());
+        m_currentInspectorPlugin->activate(this, m_views.first());
     } else {
         if (m_currentInspectorPlugin) {
             m_currentInspectorPlugin->deactivate();
index 72243cb6b48b5b6b5bb9d75aeb32f005a99a70f6..409a3fe2aae8ab8c2adc7a3a18fccacfedf542f0 100644 (file)
@@ -53,7 +53,6 @@
 
 QT_BEGIN_NAMESPACE
 
-namespace QmlJSDebugger { class AbstractViewInspector; }
 
 class QQmlInspectorInterface;
 
@@ -76,7 +75,6 @@ private Q_SLOTS:
     void updateState();
 
 private:
-    friend class QmlJSDebugger::AbstractViewInspector;
     friend class QQmlInspectorServiceFactory;
     void loadInspectorPlugins();
 
index 003349ef550d570b0b3df8417cd4172c79396190..de9d5617b560e82c5551f14c6b758a0b74bb8759 100644 (file)
@@ -109,8 +109,9 @@ static QQuickItem *itemAt(QQuickItem *item, const QPointF &pos,
 }
 
 
-QQuickViewInspector::QQuickViewInspector(QQuickView *view, QObject *parent) :
-    AbstractViewInspector(parent),
+QQuickViewInspector::QQuickViewInspector(QQmlDebugService *service, QQuickView *view,
+                                         QObject *parent) :
+    AbstractViewInspector(service, parent),
     m_view(view),
     m_overlay(new QQuickItem),
     m_inspectTool(new InspectTool(this, view)),
index 9a2ac4f3731d5e1fe8726dcad92277cf8b73ec56..e823e5a03d6c54f4de5e90928f6b0d4663a6bb1c 100644 (file)
@@ -53,7 +53,7 @@ class QQuickViewInspector : public AbstractViewInspector
 {
     Q_OBJECT
 public:
-    explicit QQuickViewInspector(QQuickView *view, QObject *parent = 0);
+    explicit QQuickViewInspector(QQmlDebugService *service, QQuickView *view, QObject *parent = 0);
 
     // AbstractViewInspector
     void changeCurrentObjects(const QList<QObject*> &objects);
index 197e618d75a57978806c90bb5c8982c8846e0960..b755c352f310280f844e01b71e78001f341e66d5 100644 (file)
@@ -57,11 +57,11 @@ bool QtQuick2Plugin::canHandleView(QObject *view)
     return qobject_cast<QQuickView*>(view);
 }
 
-void QtQuick2Plugin::activate(QObject *view)
+void QtQuick2Plugin::activate(QQmlDebugService *service, QObject *view)
 {
     QQuickView *qtQuickView = qobject_cast<QQuickView*>(view);
     Q_ASSERT(qtQuickView);
-    m_inspector = new QQuickViewInspector(qtQuickView, qtQuickView);
+    m_inspector = new QQuickViewInspector(service, qtQuickView, qtQuickView);
 }
 
 void QtQuick2Plugin::deactivate()
index 7334cc03d1da1a68585bc549de8a7a50e03a1e41..3e0704f19a6d9329ecf70cc69ed1922253263bb0 100644 (file)
@@ -36,6 +36,7 @@
 
 #include <QtCore/QPointer>
 #include "qqmlinspectorinterface.h"
+#include <private/qqmldebugservice_p.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -54,7 +55,7 @@ public:
 
     // QQmlInspectorInterface
     bool canHandleView(QObject *view);
-    void activate(QObject *view);
+    void activate(QQmlDebugService *service, QObject *view);
     void deactivate();
     void clientMessage(const QByteArray &message);