2010-06-28 18:07:12 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2010-06-28 18:07:12 +02:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2010-06-28 18:07:12 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2010-06-28 18:07:12 +02:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2010-06-28 18:07:12 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
2010-08-12 09:46:22 +02:00
|
|
|
|
2010-06-28 18:05:24 +02:00
|
|
|
#include "qmljsclientproxy.h"
|
2010-06-29 11:17:09 +02:00
|
|
|
#include "qmljsprivateapi.h"
|
2011-05-30 16:32:25 +02:00
|
|
|
#include "qmljsinspectorclient.h"
|
2010-08-30 12:05:26 +02:00
|
|
|
#include "qmljsinspector.h"
|
2010-06-28 18:05:24 +02:00
|
|
|
|
2012-04-02 08:00:39 +02:00
|
|
|
#include <qmljsdebugclient/qmljsdebugclientconstants.h>
|
2010-08-12 09:46:22 +02:00
|
|
|
#include <debugger/debuggerplugin.h>
|
|
|
|
|
#include <debugger/debuggerrunner.h>
|
|
|
|
|
#include <debugger/qml/qmlengine.h>
|
2010-08-13 14:18:10 +02:00
|
|
|
#include <debugger/qml/qmladapter.h>
|
2010-08-12 09:46:22 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2010-06-28 18:05:24 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2010-08-30 12:05:26 +02:00
|
|
|
#include <projectexplorer/project.h>
|
2010-06-28 18:05:24 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QUrl>
|
|
|
|
|
#include <QAbstractSocket>
|
2010-10-06 17:24:39 +02:00
|
|
|
|
2010-06-28 18:05:24 +02:00
|
|
|
using namespace QmlJSInspector::Internal;
|
|
|
|
|
|
2010-09-13 13:30:35 +02:00
|
|
|
ClientProxy::ClientProxy(Debugger::QmlAdapter *adapter, QObject *parent)
|
2010-08-13 14:18:10 +02:00
|
|
|
: QObject(parent)
|
|
|
|
|
, m_adapter(adapter)
|
2011-02-17 13:56:45 +01:00
|
|
|
, m_engineClient(0)
|
2011-05-30 16:32:25 +02:00
|
|
|
, m_inspectorClient(0)
|
2012-03-07 16:19:55 +01:00
|
|
|
, m_engineQueryId(0)
|
|
|
|
|
, m_contextQueryId(0)
|
2010-10-01 16:28:45 +02:00
|
|
|
, m_isConnected(false)
|
2010-08-13 14:18:10 +02:00
|
|
|
{
|
|
|
|
|
connectToServer();
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-06 17:38:28 +02:00
|
|
|
ClientProxy::~ClientProxy()
|
|
|
|
|
{
|
|
|
|
|
m_adapter.data()->setEngineDebugClient(0);
|
|
|
|
|
m_adapter.data()->setCurrentSelectedDebugInfo(-1);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void ClientProxy::connectToServer()
|
|
|
|
|
{
|
2012-03-15 12:11:41 +01:00
|
|
|
QmlEngineDebugClient *client1 = new QDeclarativeEngineClient(
|
|
|
|
|
m_adapter.data()->connection());
|
|
|
|
|
QmlEngineDebugClient *client2 = new QmlDebuggerClient(
|
|
|
|
|
m_adapter.data()->connection());
|
2011-02-17 13:56:45 +01:00
|
|
|
|
2012-03-15 12:11:41 +01:00
|
|
|
connect(client1, SIGNAL(newStatus(QDeclarativeDebugClient::Status)),
|
2012-03-07 16:19:55 +01:00
|
|
|
SLOT(clientStatusChanged(QDeclarativeDebugClient::Status)));
|
2012-03-15 12:11:41 +01:00
|
|
|
connect(client1, SIGNAL(newStatus(QDeclarativeDebugClient::Status)),
|
2012-03-07 16:19:55 +01:00
|
|
|
SLOT(engineClientStatusChanged(QDeclarativeDebugClient::Status)));
|
|
|
|
|
|
2012-03-15 12:11:41 +01:00
|
|
|
connect(client2, SIGNAL(newStatus(QDeclarativeDebugClient::Status)),
|
|
|
|
|
SLOT(clientStatusChanged(QDeclarativeDebugClient::Status)));
|
|
|
|
|
connect(client2, SIGNAL(newStatus(QDeclarativeDebugClient::Status)),
|
|
|
|
|
SLOT(engineClientStatusChanged(QDeclarativeDebugClient::Status)));
|
2011-02-17 13:56:45 +01:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
m_inspectorClient =
|
|
|
|
|
new QmlJSInspectorClient(m_adapter.data()->connection(), this);
|
2010-08-13 14:18:10 +02:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
connect(m_inspectorClient,
|
|
|
|
|
SIGNAL(connectedStatusChanged(QDeclarativeDebugClient::Status)),
|
|
|
|
|
this, SLOT(clientStatusChanged(QDeclarativeDebugClient::Status)));
|
2011-05-30 16:32:25 +02:00
|
|
|
connect(m_inspectorClient, SIGNAL(currentObjectsChanged(QList<int>)),
|
2010-08-13 14:18:10 +02:00
|
|
|
SLOT(onCurrentObjectsChanged(QList<int>)));
|
2011-05-30 16:32:25 +02:00
|
|
|
connect(m_inspectorClient, SIGNAL(zoomToolActivated()),
|
2010-08-13 14:18:10 +02:00
|
|
|
SIGNAL(zoomToolActivated()));
|
2011-05-30 16:32:25 +02:00
|
|
|
connect(m_inspectorClient, SIGNAL(selectToolActivated()),
|
2010-08-13 14:18:10 +02:00
|
|
|
SIGNAL(selectToolActivated()));
|
2011-05-30 16:32:25 +02:00
|
|
|
connect(m_inspectorClient, SIGNAL(selectMarqueeToolActivated()),
|
2010-08-13 14:18:10 +02:00
|
|
|
SIGNAL(selectMarqueeToolActivated()));
|
2011-05-30 16:32:25 +02:00
|
|
|
connect(m_inspectorClient, SIGNAL(animationSpeedChanged(qreal)),
|
2010-08-13 14:18:10 +02:00
|
|
|
SIGNAL(animationSpeedChanged(qreal)));
|
2011-05-30 16:32:25 +02:00
|
|
|
connect(m_inspectorClient, SIGNAL(animationPausedChanged(bool)),
|
2011-03-22 10:37:14 +01:00
|
|
|
SIGNAL(animationPausedChanged(bool)));
|
2011-05-30 16:32:25 +02:00
|
|
|
connect(m_inspectorClient, SIGNAL(designModeBehaviorChanged(bool)),
|
2010-08-13 14:18:10 +02:00
|
|
|
SIGNAL(designModeBehaviorChanged(bool)));
|
2011-05-30 16:32:25 +02:00
|
|
|
connect(m_inspectorClient, SIGNAL(showAppOnTopChanged(bool)),
|
2010-11-23 10:07:09 +01:00
|
|
|
SIGNAL(showAppOnTopChanged(bool)));
|
2011-05-30 16:32:25 +02:00
|
|
|
connect(m_inspectorClient, SIGNAL(reloaded()), this,
|
2010-08-13 14:18:10 +02:00
|
|
|
SIGNAL(serverReloaded()));
|
2011-05-30 16:32:25 +02:00
|
|
|
connect(m_inspectorClient, SIGNAL(logActivity(QString,QString)),
|
2011-07-27 12:30:34 +02:00
|
|
|
m_adapter.data(), SLOT(logServiceActivity(QString,QString)));
|
2010-10-01 16:28:45 +02:00
|
|
|
|
|
|
|
|
updateConnected();
|
2010-08-13 14:18:10 +02:00
|
|
|
}
|
|
|
|
|
|
2010-09-30 14:05:20 +02:00
|
|
|
void ClientProxy::clientStatusChanged(QDeclarativeDebugClient::Status status)
|
|
|
|
|
{
|
|
|
|
|
QString serviceName;
|
2011-09-20 12:29:03 +02:00
|
|
|
if (sender()) {
|
|
|
|
|
serviceName = sender()->objectName();
|
2010-09-30 14:05:20 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-27 12:30:34 +02:00
|
|
|
if (m_adapter)
|
|
|
|
|
m_adapter.data()->logServiceStatusChange(serviceName, status);
|
2010-09-30 14:05:20 +02:00
|
|
|
|
2010-10-01 16:28:45 +02:00
|
|
|
updateConnected();
|
2010-09-30 14:05:20 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-02 10:30:29 +02:00
|
|
|
QDeclarativeDebugClient *ClientProxy::qmlDebugger() const
|
|
|
|
|
{
|
|
|
|
|
return m_engineClient;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-06 17:38:28 +02:00
|
|
|
void ClientProxy::engineClientStatusChanged(QDeclarativeDebugClient::Status status)
|
|
|
|
|
{
|
|
|
|
|
if (status == QDeclarativeDebugClient::Enabled) {
|
2012-03-15 12:11:41 +01:00
|
|
|
m_engineClient = qobject_cast<QmlEngineDebugClient *>(sender());
|
|
|
|
|
connect(m_engineClient, SIGNAL(newObjects()), this, SLOT(newObjects()));
|
2012-03-28 11:42:47 +02:00
|
|
|
connect(m_engineClient, SIGNAL(result(quint32,QVariant,QByteArray)),
|
|
|
|
|
SLOT(onResult(quint32,QVariant,QByteArray)));
|
2012-03-15 12:11:41 +01:00
|
|
|
connect(m_engineClient, SIGNAL(valueChanged(int,QByteArray,QVariant)),
|
|
|
|
|
SLOT(objectWatchTriggered(int,QByteArray,QVariant)));
|
|
|
|
|
m_adapter.data()->setEngineDebugClient(m_engineClient);
|
|
|
|
|
updateConnected();
|
2011-10-06 17:38:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 15:59:08 +02:00
|
|
|
void ClientProxy::refreshObjectTree()
|
|
|
|
|
{
|
2012-03-07 16:19:55 +01:00
|
|
|
if (!m_contextQueryId) {
|
|
|
|
|
m_objectTreeQueryIds.clear();
|
2010-08-20 15:12:29 +02:00
|
|
|
queryEngineContext(m_engines.value(0).debugId());
|
2010-07-16 15:59:08 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
void ClientProxy::onCurrentObjectsChanged(const QList<int> &debugIds,
|
|
|
|
|
bool requestIfNeeded)
|
2010-07-14 14:21:10 +02:00
|
|
|
{
|
2012-03-07 16:19:55 +01:00
|
|
|
QList<QmlDebugObjectReference> selectedItems;
|
2012-03-29 14:18:30 +02:00
|
|
|
m_fetchCurrentObjects.clear();
|
|
|
|
|
m_fetchCurrentObjectsQueryIds.clear();
|
2010-08-12 09:25:40 +02:00
|
|
|
foreach (int debugId, debugIds) {
|
2012-03-07 16:19:55 +01:00
|
|
|
QmlDebugObjectReference ref = objectReferenceForId(debugId);
|
2012-03-29 14:18:30 +02:00
|
|
|
if (ref.debugId() != -1 && !ref.needsMoreData()) {
|
2010-07-14 14:21:10 +02:00
|
|
|
selectedItems << ref;
|
2010-08-20 15:12:29 +02:00
|
|
|
} else if (requestIfNeeded) {
|
2012-03-29 14:18:30 +02:00
|
|
|
m_fetchCurrentObjectsQueryIds << fetchContextObject(
|
|
|
|
|
QmlDebugObjectReference(debugId));
|
|
|
|
|
|
2010-07-14 14:21:10 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-20 15:12:29 +02:00
|
|
|
emit selectedItemsChanged(selectedItems);
|
2010-07-14 14:21:10 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:18:30 +02:00
|
|
|
void ClientProxy::onCurrentObjectsFetched(quint32 queryId, const QVariant &result)
|
|
|
|
|
{
|
|
|
|
|
m_fetchCurrentObjectsQueryIds.removeOne(queryId);
|
|
|
|
|
QmlDebugObjectReference obj = qvariant_cast<QmlDebugObjectReference>(result);
|
|
|
|
|
m_fetchCurrentObjects.push_front(obj);
|
|
|
|
|
|
2012-04-02 08:00:39 +02:00
|
|
|
if (!getObjectHierarchy(obj))
|
2012-03-29 14:18:30 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
foreach (const QmlDebugObjectReference &o, m_fetchCurrentObjects)
|
|
|
|
|
addObjectToTree(o);
|
|
|
|
|
emit selectedItemsChanged(QList<QmlDebugObjectReference>() <<
|
|
|
|
|
m_fetchCurrentObjects.last());
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-02 08:00:39 +02:00
|
|
|
bool ClientProxy::getObjectHierarchy(const QmlDebugObjectReference &obj)
|
|
|
|
|
{
|
|
|
|
|
QmlDebugObjectReference parent = objectReferenceForId(obj.parentId());
|
|
|
|
|
//for root object
|
|
|
|
|
if (obj.parentId() == -1)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
//for other objects
|
|
|
|
|
if (parent.debugId() == -1 || parent.needsMoreData()) {
|
|
|
|
|
m_fetchCurrentObjectsQueryIds << fetchContextObject(
|
|
|
|
|
QmlDebugObjectReference(obj.parentId()));
|
|
|
|
|
} else {
|
|
|
|
|
return getObjectHierarchy(parent);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-26 14:21:44 +02:00
|
|
|
void ClientProxy::setSelectedItemsByDebugId(const QList<int> &debugIds)
|
|
|
|
|
{
|
|
|
|
|
if (!isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
2011-05-30 16:32:25 +02:00
|
|
|
m_inspectorClient->setCurrentObjects(debugIds);
|
2011-05-26 14:21:44 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
void ClientProxy::setSelectedItemsByObjectId(
|
|
|
|
|
const QList<QmlDebugObjectReference> &objectRefs)
|
2010-07-08 11:34:51 +02:00
|
|
|
{
|
2010-10-25 08:05:13 +02:00
|
|
|
if (isConnected()) {
|
|
|
|
|
QList<int> debugIds;
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
foreach (const QmlDebugObjectReference &ref, objectRefs) {
|
2010-10-25 08:05:13 +02:00
|
|
|
debugIds << ref.debugId();
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-30 16:32:25 +02:00
|
|
|
m_inspectorClient->setCurrentObjects(debugIds);
|
2010-10-25 08:05:13 +02:00
|
|
|
}
|
2010-07-08 11:34:51 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-19 15:58:47 +01:00
|
|
|
void ClientProxy::addObjectToTree(const QmlDebugObjectReference &obj)
|
|
|
|
|
{
|
|
|
|
|
int count = m_rootObjects.count();
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
|
if (m_rootObjects[i].insertObjectInTree(obj)) {
|
|
|
|
|
buildDebugIdHashRecursive(obj);
|
|
|
|
|
emit objectTreeUpdated();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
QmlDebugObjectReference ClientProxy::objectReferenceForId(int debugId) const
|
2010-07-08 11:34:51 +02:00
|
|
|
{
|
2012-03-07 16:19:55 +01:00
|
|
|
foreach (const QmlDebugObjectReference& it, m_rootObjects) {
|
|
|
|
|
QmlDebugObjectReference result = objectReferenceForId(debugId, it);
|
2010-08-20 15:12:29 +02:00
|
|
|
if (result.debugId() == debugId)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2012-03-07 16:19:55 +01:00
|
|
|
return QmlDebugObjectReference();
|
2010-07-08 11:34:51 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-07 16:30:05 +01:00
|
|
|
void ClientProxy::log(LogDirection direction, const QString &message)
|
|
|
|
|
{
|
|
|
|
|
QString msg;
|
|
|
|
|
if (direction == LogSend) {
|
|
|
|
|
msg += " sending ";
|
|
|
|
|
} else {
|
|
|
|
|
msg += " receiving ";
|
|
|
|
|
}
|
|
|
|
|
msg += message;
|
|
|
|
|
|
2011-07-27 12:30:34 +02:00
|
|
|
if (m_adapter)
|
|
|
|
|
m_adapter.data()->logServiceActivity("QDeclarativeDebug", msg);
|
2011-02-07 16:30:05 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
QList<QmlDebugObjectReference>
|
|
|
|
|
QmlJSInspector::Internal::ClientProxy::rootObjectReference() const
|
2010-07-20 12:50:14 +02:00
|
|
|
{
|
2010-08-20 15:12:29 +02:00
|
|
|
return m_rootObjects;
|
2010-07-20 12:50:14 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
QmlDebugObjectReference
|
|
|
|
|
ClientProxy::objectReferenceForId(int debugId,
|
|
|
|
|
const QmlDebugObjectReference &objectRef) const
|
2010-06-28 18:05:24 +02:00
|
|
|
{
|
2010-07-08 11:34:51 +02:00
|
|
|
if (objectRef.debugId() == debugId)
|
|
|
|
|
return objectRef;
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
foreach (const QmlDebugObjectReference &child, objectRef.children()) {
|
|
|
|
|
QmlDebugObjectReference result = objectReferenceForId(debugId, child);
|
2010-07-08 11:34:51 +02:00
|
|
|
if (result.debugId() == debugId)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
return QmlDebugObjectReference();
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
QmlDebugObjectReference ClientProxy::objectReferenceForId(
|
|
|
|
|
const QString &objectId) const
|
2010-09-08 16:44:42 +02:00
|
|
|
{
|
|
|
|
|
if (!objectId.isEmpty() && objectId[0].isLower()) {
|
2012-03-07 16:19:55 +01:00
|
|
|
const QList<QmlDebugObjectReference> refs = objectReferences();
|
|
|
|
|
foreach (const QmlDebugObjectReference &ref, refs) {
|
2010-09-08 16:44:42 +02:00
|
|
|
if (ref.idString() == objectId)
|
|
|
|
|
return ref;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-07 16:19:55 +01:00
|
|
|
return QmlDebugObjectReference();
|
2010-09-08 16:44:42 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
QmlDebugObjectReference ClientProxy::objectReferenceForLocation(
|
|
|
|
|
const int line, const int column) const
|
2010-09-08 16:44:42 +02:00
|
|
|
{
|
2012-03-07 16:19:55 +01:00
|
|
|
const QList<QmlDebugObjectReference> refs = objectReferences();
|
|
|
|
|
foreach (const QmlDebugObjectReference &ref, refs) {
|
2010-09-08 16:44:42 +02:00
|
|
|
if (ref.source().lineNumber() == line && ref.source().columnNumber() == column)
|
|
|
|
|
return ref;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
return QmlDebugObjectReference();
|
2010-09-08 16:44:42 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
QList<QmlDebugObjectReference> ClientProxy::objectReferences() const
|
2010-06-28 18:05:24 +02:00
|
|
|
{
|
2012-03-07 16:19:55 +01:00
|
|
|
QList<QmlDebugObjectReference> result;
|
|
|
|
|
foreach (const QmlDebugObjectReference &it, m_rootObjects) {
|
2010-08-30 18:40:56 +02:00
|
|
|
result.append(objectReferences(it));
|
2010-08-20 15:12:29 +02:00
|
|
|
}
|
|
|
|
|
return result;
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
QList<QmlDebugObjectReference>
|
|
|
|
|
ClientProxy::objectReferences(const QmlDebugObjectReference &objectRef) const
|
2010-06-28 18:05:24 +02:00
|
|
|
{
|
2012-03-07 16:19:55 +01:00
|
|
|
QList<QmlDebugObjectReference> result;
|
2010-08-30 18:40:56 +02:00
|
|
|
result.append(objectRef);
|
2010-06-28 18:05:24 +02:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
foreach (const QmlDebugObjectReference &child, objectRef.children()) {
|
2010-08-30 18:40:56 +02:00
|
|
|
result.append(objectReferences(child));
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
quint32 ClientProxy::setBindingForObject(int objectDebugId,
|
2010-07-08 15:44:35 +02:00
|
|
|
const QString &propertyName,
|
|
|
|
|
const QVariant &value,
|
2011-04-29 15:34:12 +02:00
|
|
|
bool isLiteralValue,
|
|
|
|
|
QString source,
|
|
|
|
|
int line)
|
2010-06-28 18:05:24 +02:00
|
|
|
{
|
2010-07-16 15:22:52 +02:00
|
|
|
if (objectDebugId == -1)
|
2010-07-08 16:51:25 +02:00
|
|
|
return false;
|
|
|
|
|
|
2010-07-16 15:22:52 +02:00
|
|
|
if (propertyName == QLatin1String("id"))
|
|
|
|
|
return false; // Crashes the QMLViewer.
|
2010-06-28 18:05:24 +02:00
|
|
|
|
2011-02-17 13:56:45 +01:00
|
|
|
if (!isConnected())
|
|
|
|
|
return false;
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
log(LogSend, QString("SET_BINDING %1 %2 %3 %4").arg(
|
|
|
|
|
QString::number(objectDebugId), propertyName, value.toString(),
|
|
|
|
|
QString(isLiteralValue ? "true" : "false")));
|
2011-02-07 16:30:05 +01:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
quint32 queryId = m_engineClient->setBindingForObject(
|
|
|
|
|
objectDebugId, propertyName, value.toString(), isLiteralValue,
|
|
|
|
|
source, line);
|
2010-08-03 14:07:30 +02:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
if (!queryId)
|
2011-02-07 16:30:05 +01:00
|
|
|
log(LogSend, QString("failed!"));
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
return queryId;
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
quint32 ClientProxy::setMethodBodyForObject(int objectDebugId,
|
|
|
|
|
const QString &methodName,
|
|
|
|
|
const QString &methodBody)
|
2010-07-08 16:51:25 +02:00
|
|
|
{
|
|
|
|
|
if (objectDebugId == -1)
|
2011-02-17 13:56:45 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!isConnected())
|
|
|
|
|
return false;
|
2011-02-07 16:30:05 +01:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
log(LogSend, QString("SET_METHOD_BODY %1 %2 %3").arg(
|
|
|
|
|
QString::number(objectDebugId), methodName, methodBody));
|
2011-02-07 16:30:05 +01:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
quint32 queryId = m_engineClient->setMethodBody(
|
|
|
|
|
objectDebugId, methodName, methodBody);
|
2011-02-07 16:30:05 +01:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
if (!queryId)
|
2011-02-07 16:30:05 +01:00
|
|
|
log(LogSend, QString("failed!"));
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
return queryId;
|
2010-07-08 16:51:25 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
quint32 ClientProxy::resetBindingForObject(int objectDebugId,
|
|
|
|
|
const QString& propertyName)
|
2010-07-16 15:22:52 +02:00
|
|
|
{
|
|
|
|
|
if (objectDebugId == -1)
|
|
|
|
|
return false;
|
2011-02-07 16:30:05 +01:00
|
|
|
|
2011-02-17 13:56:45 +01:00
|
|
|
if (!isConnected())
|
|
|
|
|
return false;
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
log(LogSend, QString("RESET_BINDING %1 %2").arg(
|
|
|
|
|
QString::number(objectDebugId), propertyName));
|
2011-02-07 16:30:05 +01:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
quint32 queryId = m_engineClient->resetBindingForObject(
|
|
|
|
|
objectDebugId, propertyName);
|
2011-02-07 16:30:05 +01:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
if (!queryId)
|
2011-02-07 16:30:05 +01:00
|
|
|
log(LogSend, QString("failed!"));
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
return queryId;
|
2010-07-16 15:22:52 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
quint32 ClientProxy::queryExpressionResult(int objectDebugId,
|
|
|
|
|
const QString &expr)
|
2010-09-08 16:44:42 +02:00
|
|
|
{
|
2011-02-17 13:56:45 +01:00
|
|
|
if (objectDebugId == -1)
|
|
|
|
|
return 0;
|
2011-02-07 16:30:05 +01:00
|
|
|
|
2011-02-17 13:56:45 +01:00
|
|
|
if (!isConnected())
|
|
|
|
|
return 0;
|
2011-02-07 16:30:05 +01:00
|
|
|
|
2011-07-27 12:30:34 +02:00
|
|
|
bool block = false;
|
|
|
|
|
if (m_adapter)
|
|
|
|
|
block = m_adapter.data()->disableJsDebugging(true);
|
2011-02-17 13:56:45 +01:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
log(LogSend, QString("EVAL_EXPRESSION %1 %2").arg(
|
|
|
|
|
QString::number(objectDebugId), expr));
|
|
|
|
|
quint32 queryId = m_engineClient->queryExpressionResult(objectDebugId, expr);
|
2011-02-17 13:56:45 +01:00
|
|
|
|
2011-07-27 12:30:34 +02:00
|
|
|
if (m_adapter)
|
|
|
|
|
m_adapter.data()->disableJsDebugging(block);
|
2012-03-07 16:19:55 +01:00
|
|
|
return queryId;
|
2010-09-08 16:44:42 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-03 14:07:30 +02:00
|
|
|
void ClientProxy::clearComponentCache()
|
|
|
|
|
{
|
2010-09-30 14:05:20 +02:00
|
|
|
if (isConnected())
|
2011-05-30 16:32:25 +02:00
|
|
|
m_inspectorClient->clearComponentCache();
|
2010-08-03 14:07:30 +02:00
|
|
|
}
|
2010-07-16 15:22:52 +02:00
|
|
|
|
2011-01-18 17:17:17 +01:00
|
|
|
bool ClientProxy::addObjectWatch(int objectDebugId)
|
|
|
|
|
{
|
|
|
|
|
if (objectDebugId == -1)
|
|
|
|
|
return false;
|
|
|
|
|
|
2011-02-17 13:56:45 +01:00
|
|
|
if (!isConnected())
|
|
|
|
|
return false;
|
|
|
|
|
|
2011-01-18 17:17:17 +01:00
|
|
|
// already set
|
2012-03-07 16:19:55 +01:00
|
|
|
if (m_objectWatches.contains(objectDebugId))
|
2011-01-18 17:17:17 +01:00
|
|
|
return true;
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
QmlDebugObjectReference ref = objectReferenceForId(objectDebugId);
|
2011-01-18 17:17:17 +01:00
|
|
|
if (ref.debugId() != objectDebugId)
|
|
|
|
|
return false;
|
|
|
|
|
|
2011-02-07 16:30:05 +01:00
|
|
|
// is flooding the debugging output log!
|
|
|
|
|
// log(LogSend, QString("WATCH_PROPERTY %1").arg(objectDebugId));
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
if (m_engineClient->addWatch(ref))
|
|
|
|
|
m_objectWatches.append(objectDebugId);
|
2011-01-18 17:17:17 +01:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-28 11:42:47 +02:00
|
|
|
bool ClientProxy::isObjectBeingWatched(int objectDebugId)
|
|
|
|
|
{
|
|
|
|
|
return m_objectWatches.contains(objectDebugId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
void ClientProxy::objectWatchTriggered(int objectDebugId,
|
|
|
|
|
const QByteArray &propertyName,
|
|
|
|
|
const QVariant &propertyValue)
|
2011-01-18 17:17:17 +01:00
|
|
|
{
|
2012-03-07 16:19:55 +01:00
|
|
|
if (m_objectWatches.contains(objectDebugId))
|
|
|
|
|
emit propertyChanged(objectDebugId, propertyName, propertyValue);
|
2011-01-18 17:17:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ClientProxy::removeObjectWatch(int objectDebugId)
|
|
|
|
|
{
|
|
|
|
|
if (objectDebugId == -1)
|
|
|
|
|
return false;
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
if (!m_objectWatches.contains(objectDebugId))
|
2011-01-18 17:17:17 +01:00
|
|
|
return false;
|
|
|
|
|
|
2011-02-17 13:56:45 +01:00
|
|
|
if (!isConnected())
|
|
|
|
|
return false;
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
m_objectWatches.removeOne(objectDebugId);
|
2011-01-18 17:17:17 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClientProxy::removeAllObjectWatches()
|
|
|
|
|
{
|
2012-03-07 16:19:55 +01:00
|
|
|
foreach (int watchedObject, m_objectWatches)
|
2011-01-18 17:17:17 +01:00
|
|
|
removeObjectWatch(watchedObject);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-28 18:05:24 +02:00
|
|
|
void ClientProxy::queryEngineContext(int id)
|
|
|
|
|
{
|
|
|
|
|
if (id < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2011-02-17 13:56:45 +01:00
|
|
|
if (!isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
if (m_contextQueryId)
|
|
|
|
|
m_contextQueryId = 0;
|
2010-06-28 18:05:24 +02:00
|
|
|
|
2011-02-07 16:30:05 +01:00
|
|
|
log(LogSend, QString("LIST_OBJECTS %1").arg(QString::number(id)));
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
m_contextQueryId = m_engineClient->queryRootContexts(QmlDebugEngineReference(id));
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
void ClientProxy::contextChanged(const QVariant &value)
|
2010-06-28 18:05:24 +02:00
|
|
|
{
|
2012-03-28 11:42:47 +02:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
if (m_contextQueryId) {
|
|
|
|
|
m_contextQueryId = 0;
|
2012-03-28 11:42:47 +02:00
|
|
|
emit rootContext(value);
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
2010-08-20 17:28:12 +02:00
|
|
|
}
|
2010-06-28 18:05:24 +02:00
|
|
|
|
2012-03-19 15:58:47 +01:00
|
|
|
quint32 ClientProxy::fetchContextObject(const QmlDebugObjectReference& obj)
|
|
|
|
|
{
|
2012-04-02 14:45:25 +02:00
|
|
|
if (!isConnected())
|
|
|
|
|
return 0;
|
2012-03-19 15:58:47 +01:00
|
|
|
|
2012-04-02 14:45:25 +02:00
|
|
|
log(LogSend, QString("FETCH_OBJECT %1").arg(obj.idString()));
|
2012-03-19 15:58:47 +01:00
|
|
|
return m_engineClient->queryObject(obj);
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-10 10:36:00 +02:00
|
|
|
void ClientProxy::fetchRootObjects(
|
2012-03-28 11:42:47 +02:00
|
|
|
const QmlDebugContextReference& context, bool clear)
|
2010-08-20 17:28:12 +02:00
|
|
|
{
|
2011-02-17 13:56:45 +01:00
|
|
|
if (!isConnected())
|
|
|
|
|
return;
|
2012-03-28 11:42:47 +02:00
|
|
|
if (clear) {
|
|
|
|
|
m_rootObjects.clear();
|
|
|
|
|
m_objectTreeQueryIds.clear();
|
|
|
|
|
}
|
2012-03-07 16:19:55 +01:00
|
|
|
foreach (const QmlDebugObjectReference & obj, context.objects()) {
|
2012-04-02 08:00:39 +02:00
|
|
|
quint32 queryId = 0;
|
|
|
|
|
using namespace QmlJsDebugClient::Constants;
|
|
|
|
|
if (m_engineClient->objectName() == QML_DEBUGGER &&
|
2012-04-10 10:36:00 +02:00
|
|
|
m_engineClient->serviceVersion() >= CURRENT_SUPPORTED_VERSION) {
|
|
|
|
|
//Fetch only root objects
|
|
|
|
|
if (obj.parentId() == -1)
|
|
|
|
|
queryId = fetchContextObject(obj);
|
|
|
|
|
} else {
|
2012-04-02 08:00:39 +02:00
|
|
|
queryId = m_engineClient->queryObjectRecursive(obj);
|
2012-04-10 10:36:00 +02:00
|
|
|
}
|
2012-04-02 08:00:39 +02:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
if (queryId)
|
|
|
|
|
m_objectTreeQueryIds << queryId;
|
2010-08-20 17:28:12 +02:00
|
|
|
}
|
2012-03-07 16:19:55 +01:00
|
|
|
foreach (const QmlDebugContextReference& child, context.contexts()) {
|
2012-04-10 10:36:00 +02:00
|
|
|
fetchRootObjects(child, false);
|
2010-08-20 17:28:12 +02:00
|
|
|
}
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-28 16:16:28 +02:00
|
|
|
void ClientProxy::insertObjectInTreeIfNeeded(const QmlDebugObjectReference &object)
|
|
|
|
|
{
|
|
|
|
|
if (!m_rootObjects.contains(object))
|
|
|
|
|
return;
|
|
|
|
|
int count = m_rootObjects.count();
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
|
if (m_rootObjects[i].parentId() < 0 && m_rootObjects[i].insertObjectInTree(object)) {
|
|
|
|
|
m_rootObjects.removeOne(object);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-28 11:42:47 +02:00
|
|
|
void ClientProxy::onResult(quint32 queryId, const QVariant &value, const QByteArray &type)
|
2010-06-28 18:05:24 +02:00
|
|
|
{
|
2012-03-28 11:42:47 +02:00
|
|
|
if (type == "FETCH_OBJECT_R") {
|
|
|
|
|
log(LogReceive, QString("FETCH_OBJECT_R %1").arg(
|
|
|
|
|
qvariant_cast<QmlDebugObjectReference>(value).idString()));
|
|
|
|
|
} else {
|
|
|
|
|
log(LogReceive, QLatin1String(type));
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
if (m_objectTreeQueryIds.contains(queryId))
|
|
|
|
|
objectTreeFetched(queryId, value);
|
|
|
|
|
else if (queryId == m_engineQueryId)
|
|
|
|
|
updateEngineList(value);
|
|
|
|
|
else if (queryId == m_contextQueryId)
|
|
|
|
|
contextChanged(value);
|
2012-03-29 14:18:30 +02:00
|
|
|
else if (m_fetchCurrentObjectsQueryIds.contains(queryId))
|
|
|
|
|
onCurrentObjectsFetched(queryId, value);
|
2012-03-07 16:19:55 +01:00
|
|
|
else
|
|
|
|
|
emit result(queryId, value);
|
|
|
|
|
}
|
2010-06-28 18:05:24 +02:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
void ClientProxy::objectTreeFetched(quint32 queryId, const QVariant &result)
|
|
|
|
|
{
|
|
|
|
|
QmlDebugObjectReference obj = qvariant_cast<QmlDebugObjectReference>(result);
|
|
|
|
|
m_rootObjects.append(obj);
|
2010-06-28 18:05:24 +02:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
m_objectTreeQueryIds.removeOne(queryId);
|
|
|
|
|
if (m_objectTreeQueryIds.isEmpty()) {
|
2010-08-30 12:05:26 +02:00
|
|
|
int old_count = m_debugIdHash.count();
|
|
|
|
|
m_debugIdHash.clear();
|
|
|
|
|
m_debugIdHash.reserve(old_count + 1);
|
2012-03-07 16:19:55 +01:00
|
|
|
foreach (const QmlDebugObjectReference &it, m_rootObjects)
|
2010-08-30 12:05:26 +02:00
|
|
|
buildDebugIdHashRecursive(it);
|
2010-08-20 15:12:29 +02:00
|
|
|
emit objectTreeUpdated();
|
2010-07-14 17:22:22 +02:00
|
|
|
|
2010-09-30 14:05:20 +02:00
|
|
|
if (isConnected()) {
|
2011-05-30 16:32:25 +02:00
|
|
|
if (!m_inspectorClient->currentObjects().isEmpty())
|
|
|
|
|
onCurrentObjectsChanged(m_inspectorClient->currentObjects(), false);
|
2010-07-26 15:31:59 +02:00
|
|
|
|
2011-05-30 16:32:25 +02:00
|
|
|
m_inspectorClient->setObjectIdList(m_rootObjects);
|
2010-08-20 15:12:29 +02:00
|
|
|
}
|
2010-07-14 17:22:22 +02:00
|
|
|
}
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
void ClientProxy::buildDebugIdHashRecursive(const QmlDebugObjectReference& ref)
|
2010-08-30 12:05:26 +02:00
|
|
|
{
|
2011-07-19 17:48:57 +02:00
|
|
|
QUrl fileUrl = ref.source().url();
|
2010-08-30 12:05:26 +02:00
|
|
|
int lineNum = ref.source().lineNumber();
|
|
|
|
|
int colNum = ref.source().columnNumber();
|
|
|
|
|
int rev = 0;
|
2010-08-30 18:40:56 +02:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
// handle the case where the url contains the revision number encoded.
|
|
|
|
|
//(for object created by the debugger)
|
2010-12-14 16:21:47 +01:00
|
|
|
static QRegExp rx("(.*)_(\\d+):(\\d+)$");
|
2011-07-19 17:48:57 +02:00
|
|
|
if (rx.exactMatch(fileUrl.path())) {
|
|
|
|
|
fileUrl.setPath(rx.cap(1));
|
2010-08-30 12:05:26 +02:00
|
|
|
rev = rx.cap(2).toInt();
|
|
|
|
|
lineNum += rx.cap(3).toInt() - 1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-19 17:48:57 +02:00
|
|
|
const QString filePath = InspectorUi::instance()->findFileInProject(fileUrl);
|
2010-08-30 12:05:26 +02:00
|
|
|
|
2010-08-30 18:40:56 +02:00
|
|
|
// append the debug ids in the hash
|
2012-03-07 16:19:55 +01:00
|
|
|
m_debugIdHash[qMakePair<QString, int>(filePath, rev)][qMakePair<int, int>(
|
|
|
|
|
lineNum, colNum)].append(ref.debugId());
|
2010-08-30 12:05:26 +02:00
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
foreach (const QmlDebugObjectReference &it, ref.children())
|
2010-08-30 12:05:26 +02:00
|
|
|
buildDebugIdHashRecursive(it);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
void ClientProxy::reloadQmlViewer()
|
2010-06-28 18:05:24 +02:00
|
|
|
{
|
2010-09-30 14:05:20 +02:00
|
|
|
if (isConnected())
|
2011-05-30 16:32:25 +02:00
|
|
|
m_inspectorClient->reloadViewer();
|
2010-07-08 11:34:51 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-12 12:02:35 +02:00
|
|
|
void ClientProxy::setDesignModeBehavior(bool inDesignMode)
|
|
|
|
|
{
|
2010-09-30 14:05:20 +02:00
|
|
|
if (isConnected())
|
2011-05-30 16:32:25 +02:00
|
|
|
m_inspectorClient->setDesignModeBehavior(inDesignMode);
|
2010-07-12 12:02:35 +02:00
|
|
|
}
|
|
|
|
|
|
2011-03-18 20:45:23 +01:00
|
|
|
void ClientProxy::setAnimationSpeed(qreal slowDownFactor)
|
2010-07-08 11:34:51 +02:00
|
|
|
{
|
2010-09-30 14:05:20 +02:00
|
|
|
if (isConnected())
|
2011-05-30 16:32:25 +02:00
|
|
|
m_inspectorClient->setAnimationSpeed(slowDownFactor);
|
2011-03-18 20:45:23 +01:00
|
|
|
}
|
|
|
|
|
|
2011-03-22 10:37:14 +01:00
|
|
|
void ClientProxy::setAnimationPaused(bool paused)
|
2011-03-18 20:45:23 +01:00
|
|
|
{
|
|
|
|
|
if (isConnected())
|
2011-05-30 16:32:25 +02:00
|
|
|
m_inspectorClient->setAnimationPaused(paused);
|
2010-07-08 11:34:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClientProxy::changeToZoomTool()
|
|
|
|
|
{
|
2010-09-30 14:05:20 +02:00
|
|
|
if (isConnected())
|
2011-05-30 16:32:25 +02:00
|
|
|
m_inspectorClient->changeToZoomTool();
|
2010-07-08 11:34:51 +02:00
|
|
|
}
|
|
|
|
|
void ClientProxy::changeToSelectTool()
|
|
|
|
|
{
|
2010-09-30 14:05:20 +02:00
|
|
|
if (isConnected())
|
2011-05-30 16:32:25 +02:00
|
|
|
m_inspectorClient->changeToSelectTool();
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
void ClientProxy::changeToSelectMarqueeTool()
|
|
|
|
|
{
|
2010-09-30 14:05:20 +02:00
|
|
|
if (isConnected())
|
2011-05-30 16:32:25 +02:00
|
|
|
m_inspectorClient->changeToSelectMarqueeTool();
|
2010-07-08 11:34:51 +02:00
|
|
|
}
|
|
|
|
|
|
2010-11-23 10:07:09 +01:00
|
|
|
void ClientProxy::showAppOnTop(bool showOnTop)
|
|
|
|
|
{
|
|
|
|
|
if (isConnected())
|
2011-05-30 16:32:25 +02:00
|
|
|
m_inspectorClient->showAppOnTop(showOnTop);
|
2010-11-23 10:07:09 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-21 14:26:25 +02:00
|
|
|
void ClientProxy::createQmlObject(const QString &qmlText, int parentDebugId,
|
2012-03-07 16:19:55 +01:00
|
|
|
const QStringList &imports,
|
|
|
|
|
const QString &filename, int order)
|
2010-07-16 09:41:56 +02:00
|
|
|
{
|
2010-09-30 14:05:20 +02:00
|
|
|
if (isConnected())
|
2012-03-07 16:19:55 +01:00
|
|
|
m_inspectorClient->createQmlObject(qmlText, parentDebugId, imports,
|
|
|
|
|
filename, order);
|
2010-07-16 09:41:56 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-03 10:17:09 +02:00
|
|
|
void ClientProxy::destroyQmlObject(int debugId)
|
2010-07-19 10:42:39 +02:00
|
|
|
{
|
2010-09-30 14:05:20 +02:00
|
|
|
if (isConnected())
|
2011-05-30 16:32:25 +02:00
|
|
|
m_inspectorClient->destroyQmlObject(debugId);
|
2010-07-19 10:42:39 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-26 17:38:31 +02:00
|
|
|
void ClientProxy::reparentQmlObject(int debugId, int newParent)
|
|
|
|
|
{
|
2010-09-30 14:05:20 +02:00
|
|
|
if (isConnected())
|
2011-05-30 16:32:25 +02:00
|
|
|
m_inspectorClient->reparentQmlObject(debugId, newParent);
|
2010-08-26 17:38:31 +02:00
|
|
|
}
|
|
|
|
|
|
2010-10-01 16:28:45 +02:00
|
|
|
void ClientProxy::updateConnected()
|
|
|
|
|
{
|
2012-03-07 16:19:55 +01:00
|
|
|
bool isConnected = m_inspectorClient &&
|
|
|
|
|
m_inspectorClient->status() == QDeclarativeDebugClient::Enabled &&
|
|
|
|
|
m_engineClient &&
|
|
|
|
|
m_engineClient->status() == QDeclarativeDebugClient::Enabled;
|
2010-10-01 16:28:45 +02:00
|
|
|
|
|
|
|
|
if (isConnected != m_isConnected) {
|
|
|
|
|
m_isConnected = isConnected;
|
|
|
|
|
if (isConnected) {
|
|
|
|
|
emit connected();
|
2010-10-01 17:30:50 +02:00
|
|
|
reloadEngines();
|
2010-10-01 16:28:45 +02:00
|
|
|
} else {
|
|
|
|
|
emit disconnected();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-28 18:05:24 +02:00
|
|
|
void ClientProxy::reloadEngines()
|
|
|
|
|
{
|
2011-02-17 13:56:45 +01:00
|
|
|
if (!isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
2010-06-28 18:05:24 +02:00
|
|
|
emit aboutToReloadEngines();
|
|
|
|
|
|
2011-02-07 16:30:05 +01:00
|
|
|
log(LogSend, QString("LIST_ENGINES"));
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
m_engineQueryId = m_engineClient->queryAvailableEngines();
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
QList<QmlDebugEngineReference> ClientProxy::engines() const
|
2010-06-28 18:05:24 +02:00
|
|
|
{
|
|
|
|
|
return m_engines;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
void ClientProxy::updateEngineList(const QVariant &value)
|
2010-06-28 18:05:24 +02:00
|
|
|
{
|
2012-03-07 16:19:55 +01:00
|
|
|
m_engines = qvariant_cast<QmlDebugEngineReferenceList>(value);
|
|
|
|
|
m_engineQueryId = 0;
|
2010-06-28 18:05:24 +02:00
|
|
|
emit enginesChanged();
|
|
|
|
|
}
|
2010-08-13 14:18:10 +02:00
|
|
|
|
2010-09-13 13:30:35 +02:00
|
|
|
Debugger::QmlAdapter *ClientProxy::qmlAdapter() const
|
2010-08-13 14:18:10 +02:00
|
|
|
{
|
2011-07-27 12:30:34 +02:00
|
|
|
return m_adapter.data();
|
2010-08-13 14:18:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ClientProxy::isConnected() const
|
|
|
|
|
{
|
2010-10-01 16:28:45 +02:00
|
|
|
return m_isConnected;
|
2010-08-13 14:18:10 +02:00
|
|
|
}
|
2010-08-24 15:24:04 +02:00
|
|
|
|
|
|
|
|
void ClientProxy::newObjects()
|
|
|
|
|
{
|
2011-02-07 16:30:05 +01:00
|
|
|
log(LogReceive, QString("OBJECT_CREATED"));
|
2012-03-28 11:42:47 +02:00
|
|
|
refreshObjectTree();
|
2010-08-24 15:24:04 +02:00
|
|
|
}
|