From 06a2a46f43604f802f9d8f963a1f27ad6ef8567b Mon Sep 17 00:00:00 2001
From: Kai Koehne <kai.koehne@nokia.com>
Date: Tue, 20 Sep 2011 12:29:03 +0200
Subject: [PATCH] QmlDebugger: Also show status of QDeclarativeEngine client in
 log

Fix QDeclarativeEngineDebug to use the same enum as the other clients.
Also, use objectName() to name the clients.

Change-Id: I826970bf248ce2f50c4bf66c1f58c0b9b56698b1
Reviewed-on: http://codereview.qt-project.org/5231
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
---
 src/libs/qmljsdebugclient/qdeclarativeenginedebug.cpp | 11 ++++++-----
 src/libs/qmljsdebugclient/qdeclarativeenginedebug.h   |  7 +++----
 src/plugins/qmljsinspector/qmljsclientproxy.cpp       |  8 +++++---
 src/plugins/qmljsinspector/qmljsinspectorclient.cpp   |  1 +
 4 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/libs/qmljsdebugclient/qdeclarativeenginedebug.cpp b/src/libs/qmljsdebugclient/qdeclarativeenginedebug.cpp
index db3f4a77810..23516ea24b7 100644
--- a/src/libs/qmljsdebugclient/qdeclarativeenginedebug.cpp
+++ b/src/libs/qmljsdebugclient/qdeclarativeenginedebug.cpp
@@ -56,7 +56,7 @@ public:
     QDeclarativeEngineDebugPrivate(QDeclarativeEngineDebug *, QDeclarativeDebugConnection *);
     ~QDeclarativeEngineDebugPrivate();
 
-    void statusChanged(QDeclarativeEngineDebug::Status status);
+    void statusChanged(QDeclarativeDebugClient::Status status);
     void message(const QByteArray &);
 
     QDeclarativeEngineDebugClient *client;
@@ -90,7 +90,7 @@ QDeclarativeEngineDebugClient::QDeclarativeEngineDebugClient(QDeclarativeDebugCo
 void QDeclarativeEngineDebugClient::statusChanged(Status status)
 {
     if (priv)
-        priv->statusChanged(static_cast<QDeclarativeEngineDebug::Status>(status));
+        priv->statusChanged(status);
 }
 
 void QDeclarativeEngineDebugClient::messageReceived(const QByteArray &data)
@@ -313,7 +313,7 @@ void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugCo
     }
 }
 
-void QDeclarativeEngineDebugPrivate::statusChanged(QDeclarativeEngineDebug::Status status)
+void QDeclarativeEngineDebugPrivate::statusChanged(QDeclarativeDebugClient::Status status)
 {
     emit q_ptr->statusChanged(status);
 }
@@ -438,17 +438,18 @@ void QDeclarativeEngineDebugPrivate::message(const QByteArray &data)
 QDeclarativeEngineDebug::QDeclarativeEngineDebug(QDeclarativeDebugConnection *client, QObject *parent)
     : QObject(parent), d_ptr(new QDeclarativeEngineDebugPrivate(this, client))
 {
+    setObjectName(d_ptr->client->name());
 }
 
 QDeclarativeEngineDebug::~QDeclarativeEngineDebug()
 {
 }
 
-QDeclarativeEngineDebug::Status QDeclarativeEngineDebug::status() const
+QDeclarativeDebugClient::Status QDeclarativeEngineDebug::status() const
 {
     Q_D(const QDeclarativeEngineDebug);
 
-    return static_cast<QDeclarativeEngineDebug::Status>(d->client->status());
+    return d->client->status();
 }
 
 QDeclarativeDebugPropertyWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugPropertyReference &property, QObject *parent)
diff --git a/src/libs/qmljsdebugclient/qdeclarativeenginedebug.h b/src/libs/qmljsdebugclient/qdeclarativeenginedebug.h
index ed941a5e3b5..b7eb6655251 100644
--- a/src/libs/qmljsdebugclient/qdeclarativeenginedebug.h
+++ b/src/libs/qmljsdebugclient/qdeclarativeenginedebug.h
@@ -33,6 +33,7 @@
 #define QDECLARATIVEENGINEDEBUG_H
 
 #include "qmljsdebugclient_global.h"
+#include "qdeclarativedebugclient.h"
 #include <QtCore/qobject.h>
 #include <QtCore/qurl.h>
 #include <QtCore/qvariant.h>
@@ -58,12 +59,10 @@ class QMLJSDEBUGCLIENT_EXPORT QDeclarativeEngineDebug : public QObject
 {
     Q_OBJECT
 public:
-    enum Status { NotConnected, Unavailable, Enabled };
-
     explicit QDeclarativeEngineDebug(QDeclarativeDebugConnection *, QObject * = 0);
     ~QDeclarativeEngineDebug();
 
-    Status status() const;
+    QDeclarativeDebugClient::Status status() const;
 
     QDeclarativeDebugPropertyWatch *addWatch(const QDeclarativeDebugPropertyReference &,
                                              QObject *parent = 0);
@@ -96,7 +95,7 @@ public:
 
 Q_SIGNALS:
     void newObjects();
-    void statusChanged(Status status);
+    void statusChanged(QDeclarativeDebugClient::Status status);
 
 private:
     Q_DECLARE_PRIVATE(QDeclarativeEngineDebug)
diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.cpp b/src/plugins/qmljsinspector/qmljsclientproxy.cpp
index 135dc58e9a6..4cddca45df6 100644
--- a/src/plugins/qmljsinspector/qmljsclientproxy.cpp
+++ b/src/plugins/qmljsinspector/qmljsclientproxy.cpp
@@ -68,6 +68,8 @@ void ClientProxy::connectToServer()
     m_engineClient = new QDeclarativeEngineDebug(m_adapter.data()->connection(), this);
 
     connect(m_engineClient, SIGNAL(newObjects()), this, SLOT(newObjects()));
+    connect(m_engineClient, SIGNAL(statusChanged(QDeclarativeDebugClient::Status)),
+            this, SLOT(clientStatusChanged(QDeclarativeDebugClient::Status)));
 
     m_inspectorClient = new QmlJSInspectorClient(m_adapter.data()->connection(), this);
 
@@ -104,8 +106,8 @@ void ClientProxy::connectToServer()
 void ClientProxy::clientStatusChanged(QDeclarativeDebugClient::Status status)
 {
     QString serviceName;
-    if (QDeclarativeDebugClient *client = qobject_cast<QDeclarativeDebugClient*>(sender())) {
-        serviceName = client->name();
+    if (sender()) {
+        serviceName = sender()->objectName();
     }
 
     if (m_adapter)
@@ -613,7 +615,7 @@ void ClientProxy::reparentQmlObject(int debugId, int newParent)
 void ClientProxy::updateConnected()
 {
     bool isConnected = m_inspectorClient && m_inspectorClient->status() == QDeclarativeDebugClient::Enabled
-            && m_engineClient && m_engineClient->status() == QDeclarativeEngineDebug::Enabled;
+            && m_engineClient && m_engineClient->status() == QDeclarativeDebugClient::Enabled;
 
     if (isConnected != m_isConnected) {
         m_isConnected = isConnected;
diff --git a/src/plugins/qmljsinspector/qmljsinspectorclient.cpp b/src/plugins/qmljsinspector/qmljsinspectorclient.cpp
index 77527d6bb23..9db45adfabd 100644
--- a/src/plugins/qmljsinspector/qmljsinspectorclient.cpp
+++ b/src/plugins/qmljsinspector/qmljsinspectorclient.cpp
@@ -45,6 +45,7 @@ QmlJSInspectorClient::QmlJSInspectorClient(QDeclarativeDebugConnection *client,
     : QDeclarativeDebugClient(QLatin1String("QDeclarativeObserverMode"), client) ,
     m_connection(client)
 {
+    setObjectName(name());
 }
 
 void QmlJSInspectorClient::statusChanged(Status status)
-- 
GitLab