diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2011-10-26 15:52:48 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-01 17:03:29 +0100 |
commit | 1695f0622b4673c49ccb6b127f1a7d9b24611d80 (patch) | |
tree | 011ef84395cc5440fc537ae9b21cb6891b55db45 /src/declarative/debugger | |
parent | 3c8ea4c9151045d95dd0b0df72f6f680ce57c1fc (diff) |
Debugger: Split inspector plugin into a qtquick1 and a qtquick2 plugin
This allows the inspector to be used also when e.g. qtquick1 and widgets libraries
are not available.
Change-Id: Id8510ea2a1a9c2a776d67e6d7732a4e40363d5a3
Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
Diffstat (limited to 'src/declarative/debugger')
3 files changed, 35 insertions, 23 deletions
diff --git a/src/declarative/debugger/qdeclarativeinspectorinterface_p.h b/src/declarative/debugger/qdeclarativeinspectorinterface_p.h index d4cd783b16..dd30427277 100644 --- a/src/declarative/debugger/qdeclarativeinspectorinterface_p.h +++ b/src/declarative/debugger/qdeclarativeinspectorinterface_p.h @@ -67,8 +67,12 @@ public: QDeclarativeInspectorInterface() {} virtual ~QDeclarativeInspectorInterface() {} - virtual void activate() = 0; + virtual bool canHandleView(QObject *view) = 0; + + virtual void activate(QObject *view) = 0; virtual void deactivate() = 0; + + virtual void clientMessage(const QByteArray &message) = 0; }; Q_DECLARE_INTERFACE(QDeclarativeInspectorInterface, "com.trolltech.Qt.QDeclarativeInspectorInterface/1.0") diff --git a/src/declarative/debugger/qdeclarativeinspectorservice.cpp b/src/declarative/debugger/qdeclarativeinspectorservice.cpp index 56441ae606..d6fdaa59e3 100644 --- a/src/declarative/debugger/qdeclarativeinspectorservice.cpp +++ b/src/declarative/debugger/qdeclarativeinspectorservice.cpp @@ -54,7 +54,7 @@ Q_GLOBAL_STATIC(QDeclarativeInspectorService, serviceInstance) QDeclarativeInspectorService::QDeclarativeInspectorService() : QDeclarativeDebugService(QLatin1String("QDeclarativeObserverMode")) - , m_inspectorPlugin(0) + , m_currentInspectorPlugin(0) { } @@ -91,34 +91,46 @@ void QDeclarativeInspectorService::statusChanged(Status /*status*/) void QDeclarativeInspectorService::updateStatus() { if (m_views.isEmpty()) { - if (m_inspectorPlugin) - m_inspectorPlugin->deactivate(); + if (m_currentInspectorPlugin) { + m_currentInspectorPlugin->deactivate(); + m_currentInspectorPlugin = 0; + } return; } if (status() == Enabled) { - if (!m_inspectorPlugin) - m_inspectorPlugin = loadInspectorPlugin(); + if (m_inspectorPlugins.isEmpty()) + loadInspectorPlugins(); - if (!m_inspectorPlugin) { - qWarning() << "Error while loading inspector plugin"; + if (m_inspectorPlugins.isEmpty()) { + qWarning() << "QDeclarativeInspector: No plugins found."; QDeclarativeDebugServer::instance()->removeService(this); return; } - m_inspectorPlugin->activate(); + foreach (QDeclarativeInspectorInterface *inspector, m_inspectorPlugins) { + if (inspector->canHandleView(m_views.first())) { + m_currentInspectorPlugin = inspector; + break; + } + } + + m_currentInspectorPlugin->activate(m_views.first()); } else { - if (m_inspectorPlugin) - m_inspectorPlugin->deactivate(); + if (m_currentInspectorPlugin) { + m_currentInspectorPlugin->deactivate(); + m_currentInspectorPlugin = 0; + } } } void QDeclarativeInspectorService::messageReceived(const QByteArray &message) { - emit gotMessage(message); + if (m_currentInspectorPlugin) + m_currentInspectorPlugin->clientMessage(message); } -QDeclarativeInspectorInterface *QDeclarativeInspectorService::loadInspectorPlugin() +void QDeclarativeInspectorService::loadInspectorPlugins() { QStringList pluginCandidates; const QStringList paths = QCoreApplication::libraryPaths(); @@ -136,12 +148,11 @@ QDeclarativeInspectorInterface *QDeclarativeInspectorService::loadInspectorPlugi QDeclarativeInspectorInterface *inspector = qobject_cast<QDeclarativeInspectorInterface*>(loader.instance()); - if (inspector) - return inspector; - loader.unload(); + m_inspectorPlugins << inspector; + else + loader.unload(); } - return 0; } QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativeinspectorservice_p.h b/src/declarative/debugger/qdeclarativeinspectorservice_p.h index df51ab8bfe..9aa71ae953 100644 --- a/src/declarative/debugger/qdeclarativeinspectorservice_p.h +++ b/src/declarative/debugger/qdeclarativeinspectorservice_p.h @@ -76,23 +76,20 @@ public: void addView(QObject *); void removeView(QObject *); - QList<QObject*> views() const { return m_views; } void sendMessage(const QByteArray &message); -Q_SIGNALS: - void gotMessage(const QByteArray &message); - protected: virtual void statusChanged(Status status); virtual void messageReceived(const QByteArray &); private: void updateStatus(); - static QDeclarativeInspectorInterface *loadInspectorPlugin(); + void loadInspectorPlugins(); QList<QObject*> m_views; - QDeclarativeInspectorInterface *m_inspectorPlugin; + QDeclarativeInspectorInterface *m_currentInspectorPlugin; + QList<QDeclarativeInspectorInterface*> m_inspectorPlugins; }; QT_END_NAMESPACE |