2010-06-28 18:07:12 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** 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 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.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
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"
|
2010-07-08 11:34:51 +02:00
|
|
|
#include "qmljsdesigndebugclient.h"
|
2010-08-30 12:05:26 +02:00
|
|
|
#include "qmljsinspector.h"
|
2010-06-28 18:05:24 +02:00
|
|
|
|
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
|
|
|
|
|
|
|
|
#include <QUrl>
|
|
|
|
|
#include <QAbstractSocket>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
|
|
using namespace QmlJSInspector::Internal;
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
ClientProxy::ClientProxy(Debugger::Internal::QmlAdapter *adapter, QObject *parent)
|
|
|
|
|
: QObject(parent)
|
|
|
|
|
, m_adapter(adapter)
|
|
|
|
|
, m_client(m_adapter->client())
|
|
|
|
|
, m_designClient(0)
|
|
|
|
|
, m_engineQuery(0)
|
|
|
|
|
, m_contextQuery(0)
|
|
|
|
|
{
|
2010-08-24 15:24:04 +02:00
|
|
|
m_requestObjectsTimer.setSingleShot(true);
|
|
|
|
|
m_requestObjectsTimer.setInterval(3000);
|
2010-08-13 14:18:10 +02:00
|
|
|
connect(m_adapter, SIGNAL(aboutToDisconnect()), SLOT(disconnectFromServer()));
|
2010-08-24 15:24:04 +02:00
|
|
|
connect(m_client, SIGNAL(newObjects()), this, SLOT(newObjects()));
|
|
|
|
|
connect(&m_requestObjectsTimer, SIGNAL(timeout()), this, SLOT(refreshObjectTree()));
|
2010-08-13 14:18:10 +02:00
|
|
|
connectToServer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClientProxy::connectToServer()
|
|
|
|
|
{
|
|
|
|
|
m_designClient = new QmlJSDesignDebugClient(m_adapter->connection(), this);
|
|
|
|
|
emit connected();
|
|
|
|
|
|
|
|
|
|
connect(m_designClient, SIGNAL(currentObjectsChanged(QList<int>)),
|
|
|
|
|
SLOT(onCurrentObjectsChanged(QList<int>)));
|
|
|
|
|
connect(m_designClient, SIGNAL(colorPickerActivated()),
|
|
|
|
|
SIGNAL(colorPickerActivated()));
|
|
|
|
|
connect(m_designClient, SIGNAL(zoomToolActivated()),
|
|
|
|
|
SIGNAL(zoomToolActivated()));
|
|
|
|
|
connect(m_designClient, SIGNAL(selectToolActivated()),
|
|
|
|
|
SIGNAL(selectToolActivated()));
|
|
|
|
|
connect(m_designClient, SIGNAL(selectMarqueeToolActivated()),
|
|
|
|
|
SIGNAL(selectMarqueeToolActivated()));
|
|
|
|
|
connect(m_designClient, SIGNAL(animationSpeedChanged(qreal)),
|
|
|
|
|
SIGNAL(animationSpeedChanged(qreal)));
|
|
|
|
|
connect(m_designClient, SIGNAL(designModeBehaviorChanged(bool)),
|
|
|
|
|
SIGNAL(designModeBehaviorChanged(bool)));
|
|
|
|
|
connect(m_designClient, SIGNAL(reloaded()), this,
|
|
|
|
|
SIGNAL(serverReloaded()));
|
|
|
|
|
connect(m_designClient, SIGNAL(selectedColorChanged(QColor)),
|
|
|
|
|
SIGNAL(selectedColorChanged(QColor)));
|
|
|
|
|
connect(m_designClient, SIGNAL(contextPathUpdated(QStringList)),
|
|
|
|
|
SIGNAL(contextPathUpdated(QStringList)));
|
|
|
|
|
reloadEngines();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClientProxy::disconnectFromServer()
|
2010-06-28 18:05:24 +02:00
|
|
|
{
|
2010-07-08 11:34:51 +02:00
|
|
|
if (m_designClient) {
|
2010-07-14 14:21:10 +02:00
|
|
|
disconnect(m_designClient, SIGNAL(currentObjectsChanged(QList<int>)),
|
2010-08-12 09:25:40 +02:00
|
|
|
this, SLOT(onCurrentObjectsChanged(QList<int>)));
|
|
|
|
|
disconnect(m_designClient, SIGNAL(colorPickerActivated()),
|
|
|
|
|
this, SIGNAL(colorPickerActivated()));
|
|
|
|
|
disconnect(m_designClient, SIGNAL(zoomToolActivated()),
|
|
|
|
|
this, SIGNAL(zoomToolActivated()));
|
|
|
|
|
disconnect(m_designClient, SIGNAL(selectToolActivated()),
|
|
|
|
|
this, SIGNAL(selectToolActivated()));
|
|
|
|
|
disconnect(m_designClient, SIGNAL(selectMarqueeToolActivated()),
|
|
|
|
|
this, SIGNAL(selectMarqueeToolActivated()));
|
|
|
|
|
disconnect(m_designClient, SIGNAL(animationSpeedChanged(qreal)),
|
|
|
|
|
this, SIGNAL(animationSpeedChanged(qreal)));
|
|
|
|
|
disconnect(m_designClient, SIGNAL(designModeBehaviorChanged(bool)),
|
|
|
|
|
this, SIGNAL(designModeBehaviorChanged(bool)));
|
|
|
|
|
disconnect(m_designClient, SIGNAL(selectedColorChanged(QColor)),
|
|
|
|
|
this, SIGNAL(selectedColorChanged(QColor)));
|
|
|
|
|
disconnect(m_designClient, SIGNAL(contextPathUpdated(QStringList)),
|
|
|
|
|
this, SIGNAL(contextPathUpdated(QStringList)));
|
|
|
|
|
disconnect(m_designClient, SIGNAL(treeRefreshRequested()),
|
|
|
|
|
this, SLOT(refreshObjectTree()));
|
2010-06-28 18:05:24 +02:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
delete m_designClient;
|
|
|
|
|
m_designClient = 0;
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
if (m_engineQuery)
|
|
|
|
|
delete m_engineQuery;
|
|
|
|
|
m_engineQuery = 0;
|
2010-06-28 18:05:24 +02:00
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
if (m_contextQuery)
|
|
|
|
|
delete m_contextQuery;
|
|
|
|
|
m_contextQuery = 0;
|
2010-06-28 18:05:24 +02:00
|
|
|
|
2010-08-20 15:12:29 +02:00
|
|
|
qDeleteAll(m_objectTreeQuery);
|
|
|
|
|
m_objectTreeQuery.clear();
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-16 15:59:08 +02:00
|
|
|
void ClientProxy::refreshObjectTree()
|
|
|
|
|
{
|
2010-08-20 15:12:29 +02:00
|
|
|
if (!m_contextQuery) {
|
2010-08-24 15:24:04 +02:00
|
|
|
m_requestObjectsTimer.stop();
|
2010-08-20 15:12:29 +02:00
|
|
|
qDeleteAll(m_objectTreeQuery);
|
|
|
|
|
m_objectTreeQuery.clear();
|
|
|
|
|
queryEngineContext(m_engines.value(0).debugId());
|
2010-07-16 15:59:08 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-18 15:28:39 +02:00
|
|
|
void ClientProxy::onCurrentObjectsChanged(const QList< int >& debugIds, bool requestIfNeeded)
|
2010-07-14 14:21:10 +02:00
|
|
|
{
|
|
|
|
|
QList<QDeclarativeDebugObjectReference> selectedItems;
|
|
|
|
|
|
2010-08-12 09:25:40 +02:00
|
|
|
foreach (int debugId, debugIds) {
|
2010-07-14 14:21:10 +02:00
|
|
|
QDeclarativeDebugObjectReference ref = objectReferenceForId(debugId);
|
|
|
|
|
if (ref.debugId() != -1) {
|
|
|
|
|
selectedItems << ref;
|
2010-08-20 15:12:29 +02:00
|
|
|
} else if (requestIfNeeded) {
|
2010-07-14 14:21:10 +02:00
|
|
|
// ### FIXME right now, there's no way in the protocol to
|
2010-08-12 09:25:40 +02:00
|
|
|
// a) get some item and know its parent (although that's possible
|
|
|
|
|
// by adding it to a separate plugin)
|
2010-07-14 14:21:10 +02:00
|
|
|
// b) add children to part of an existing tree.
|
2010-08-12 09:25:40 +02:00
|
|
|
// So the only choice that remains is to update the complete
|
|
|
|
|
// tree when we have an unknown debug id.
|
2010-08-20 15:12:29 +02:00
|
|
|
// break;
|
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
|
|
|
}
|
|
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
void ClientProxy::setSelectedItemsByObjectId(const QList<QDeclarativeDebugObjectReference> &objectRefs)
|
|
|
|
|
{
|
|
|
|
|
if (isConnected() && m_designClient)
|
|
|
|
|
m_designClient->setSelectedItemsByObjectId(objectRefs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDeclarativeDebugObjectReference ClientProxy::objectReferenceForId(int debugId) const
|
|
|
|
|
{
|
2010-08-20 15:12:29 +02:00
|
|
|
foreach (const QDeclarativeDebugObjectReference& it, m_rootObjects) {
|
|
|
|
|
QDeclarativeDebugObjectReference result = objectReferenceForId(debugId, it);
|
|
|
|
|
if (result.debugId() == debugId)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
return QDeclarativeDebugObjectReference();
|
2010-07-08 11:34:51 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-20 15:12:29 +02:00
|
|
|
QList<QDeclarativeDebugObjectReference> 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
|
|
|
}
|
|
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
QDeclarativeDebugObjectReference ClientProxy::objectReferenceForId(int debugId,
|
|
|
|
|
const QDeclarativeDebugObjectReference &objectRef) const
|
2010-06-28 18:05:24 +02:00
|
|
|
{
|
2010-07-08 11:34:51 +02:00
|
|
|
if (objectRef.debugId() == debugId)
|
|
|
|
|
return objectRef;
|
|
|
|
|
|
|
|
|
|
foreach(const QDeclarativeDebugObjectReference &child, objectRef.children()) {
|
|
|
|
|
QDeclarativeDebugObjectReference result = objectReferenceForId(debugId, child);
|
|
|
|
|
if (result.debugId() == debugId)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QDeclarativeDebugObjectReference();
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
2010-09-08 16:44:42 +02:00
|
|
|
QDeclarativeDebugObjectReference ClientProxy::objectReferenceForId(const QString &objectId) const
|
|
|
|
|
{
|
|
|
|
|
if (!objectId.isEmpty() && objectId[0].isLower()) {
|
|
|
|
|
const QList<QDeclarativeDebugObjectReference> refs = objectReferences();
|
|
|
|
|
foreach (const QDeclarativeDebugObjectReference &ref, refs) {
|
|
|
|
|
if (ref.idString() == objectId)
|
|
|
|
|
return ref;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return QDeclarativeDebugObjectReference();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDeclarativeDebugObjectReference ClientProxy::objectReferenceForLocation(const int line, const int column) const
|
|
|
|
|
{
|
|
|
|
|
const QList<QDeclarativeDebugObjectReference> refs = objectReferences();
|
|
|
|
|
foreach (const QDeclarativeDebugObjectReference &ref, refs) {
|
|
|
|
|
if (ref.source().lineNumber() == line && ref.source().columnNumber() == column)
|
|
|
|
|
return ref;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QDeclarativeDebugObjectReference();
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-30 18:40:56 +02:00
|
|
|
QList<QDeclarativeDebugObjectReference> ClientProxy::objectReferences() const
|
2010-06-28 18:05:24 +02:00
|
|
|
{
|
2010-08-20 15:12:29 +02:00
|
|
|
QList<QDeclarativeDebugObjectReference> result;
|
|
|
|
|
foreach(const QDeclarativeDebugObjectReference &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
|
|
|
}
|
|
|
|
|
|
2010-08-30 18:40:56 +02:00
|
|
|
QList<QDeclarativeDebugObjectReference> ClientProxy::objectReferences(const QDeclarativeDebugObjectReference &objectRef) const
|
2010-06-28 18:05:24 +02:00
|
|
|
{
|
|
|
|
|
QList<QDeclarativeDebugObjectReference> result;
|
2010-08-30 18:40:56 +02:00
|
|
|
result.append(objectRef);
|
2010-06-28 18:05:24 +02:00
|
|
|
|
|
|
|
|
foreach(const QDeclarativeDebugObjectReference &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;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-08 15:44:35 +02:00
|
|
|
bool ClientProxy::setBindingForObject(int objectDebugId,
|
|
|
|
|
const QString &propertyName,
|
|
|
|
|
const QVariant &value,
|
|
|
|
|
bool isLiteralValue)
|
2010-06-28 18:05:24 +02:00
|
|
|
{
|
2010-07-16 15:22:52 +02:00
|
|
|
qDebug() << "setBindingForObject():" << objectDebugId << propertyName << value;
|
|
|
|
|
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
|
|
|
|
2010-08-03 14:07:30 +02:00
|
|
|
bool result = m_client->setBindingForObject(objectDebugId, propertyName, value.toString(), isLiteralValue);
|
|
|
|
|
|
|
|
|
|
return result;
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-08 16:51:25 +02:00
|
|
|
bool ClientProxy::setMethodBodyForObject(int objectDebugId, const QString &methodName, const QString &methodBody)
|
|
|
|
|
{
|
2010-07-16 15:22:52 +02:00
|
|
|
qDebug() << "setMethodBodyForObject():" << objectDebugId << methodName << methodBody;
|
2010-07-08 16:51:25 +02:00
|
|
|
if (objectDebugId == -1)
|
|
|
|
|
return 0;
|
|
|
|
|
return m_client->setMethodBody(objectDebugId, methodName, methodBody);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 15:22:52 +02:00
|
|
|
bool ClientProxy::resetBindingForObject(int objectDebugId, const QString& propertyName)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "resetBindingForObject():" << objectDebugId << propertyName;
|
|
|
|
|
if (objectDebugId == -1)
|
|
|
|
|
return false;
|
|
|
|
|
// if (propertyName == QLatin1String("id")) return false;
|
|
|
|
|
return m_client->resetBindingForObject(objectDebugId, propertyName);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-08 16:44:42 +02:00
|
|
|
QDeclarativeDebugExpressionQuery *ClientProxy::queryExpressionResult(int objectDebugId, const QString &expr, QObject *parent)
|
|
|
|
|
{
|
|
|
|
|
if (objectDebugId != -1)
|
|
|
|
|
return m_client->queryExpressionResult(objectDebugId,expr,parent);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-03 14:07:30 +02:00
|
|
|
void ClientProxy::clearComponentCache()
|
|
|
|
|
{
|
|
|
|
|
if (isDesignClientConnected())
|
|
|
|
|
m_designClient->clearComponentCache();
|
|
|
|
|
}
|
2010-07-16 15:22:52 +02:00
|
|
|
|
2010-06-28 18:05:24 +02:00
|
|
|
void ClientProxy::queryEngineContext(int id)
|
|
|
|
|
{
|
|
|
|
|
if (id < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (m_contextQuery) {
|
|
|
|
|
delete m_contextQuery;
|
|
|
|
|
m_contextQuery = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_contextQuery = m_client->queryRootContexts(QDeclarativeDebugEngineReference(id), this);
|
|
|
|
|
if (!m_contextQuery->isWaiting())
|
|
|
|
|
contextChanged();
|
|
|
|
|
else
|
2010-06-29 15:06:50 +02:00
|
|
|
connect(m_contextQuery, SIGNAL(stateChanged(QDeclarativeDebugQuery::State)),
|
|
|
|
|
this, SLOT(contextChanged()));
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClientProxy::contextChanged()
|
|
|
|
|
{
|
|
|
|
|
if (m_contextQuery) {
|
2010-08-20 17:28:12 +02:00
|
|
|
m_rootObjects.clear();
|
|
|
|
|
QDeclarativeDebugContextReference rootContext = m_contextQuery->rootContext();
|
2010-06-29 15:06:50 +02:00
|
|
|
delete m_contextQuery;
|
|
|
|
|
m_contextQuery = 0;
|
2010-06-28 18:05:24 +02:00
|
|
|
|
2010-08-20 15:12:29 +02:00
|
|
|
qDeleteAll(m_objectTreeQuery);
|
|
|
|
|
m_objectTreeQuery.clear();
|
2010-08-24 15:24:04 +02:00
|
|
|
m_requestObjectsTimer.stop();
|
2010-08-20 15:12:29 +02:00
|
|
|
|
2010-08-20 17:28:12 +02:00
|
|
|
fetchContextObjectRecusrsive(rootContext);
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
2010-08-20 17:28:12 +02:00
|
|
|
}
|
2010-06-28 18:05:24 +02:00
|
|
|
|
2010-08-20 17:28:12 +02:00
|
|
|
void ClientProxy::fetchContextObjectRecusrsive(const QDeclarativeDebugContextReference& context)
|
|
|
|
|
{
|
|
|
|
|
foreach (const QDeclarativeDebugObjectReference & obj, context.objects()) {
|
|
|
|
|
QDeclarativeDebugObjectQuery* query = m_client->queryObjectRecursive(obj, this);
|
|
|
|
|
if (!query->isWaiting()) {
|
|
|
|
|
query->deleteLater(); //ignore errors;
|
|
|
|
|
} else {
|
|
|
|
|
m_objectTreeQuery << query;
|
|
|
|
|
connect(query,
|
|
|
|
|
SIGNAL(stateChanged(QDeclarativeDebugQuery::State)),
|
|
|
|
|
SLOT(objectTreeFetched(QDeclarativeDebugQuery::State)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach (const QDeclarativeDebugContextReference& child, context.contexts()) {
|
|
|
|
|
fetchContextObjectRecusrsive(child);
|
|
|
|
|
}
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-20 17:28:12 +02:00
|
|
|
|
2010-06-28 18:05:24 +02:00
|
|
|
void ClientProxy::objectTreeFetched(QDeclarativeDebugQuery::State state)
|
|
|
|
|
{
|
2010-08-20 15:12:29 +02:00
|
|
|
QDeclarativeDebugObjectQuery *query = qobject_cast<QDeclarativeDebugObjectQuery *>(sender());
|
|
|
|
|
if (!query || state == QDeclarativeDebugQuery::Error) {
|
|
|
|
|
delete query;
|
2010-06-28 18:05:24 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-20 15:12:29 +02:00
|
|
|
m_rootObjects.append(query->object());
|
2010-06-28 18:05:24 +02:00
|
|
|
|
2010-08-20 15:12:29 +02:00
|
|
|
int removed = m_objectTreeQuery.removeAll(query);
|
|
|
|
|
Q_ASSERT(removed == 1);
|
|
|
|
|
Q_UNUSED(removed);
|
|
|
|
|
delete query;
|
2010-06-28 18:05:24 +02:00
|
|
|
|
2010-08-20 15:12:29 +02:00
|
|
|
if (m_objectTreeQuery.isEmpty()) {
|
2010-08-30 12:05:26 +02:00
|
|
|
int old_count = m_debugIdHash.count();
|
|
|
|
|
m_debugIdHash.clear();
|
|
|
|
|
m_debugIdHash.reserve(old_count + 1);
|
|
|
|
|
foreach(const QDeclarativeDebugObjectReference &it, m_rootObjects)
|
|
|
|
|
buildDebugIdHashRecursive(it);
|
2010-08-20 15:12:29 +02:00
|
|
|
emit objectTreeUpdated();
|
2010-07-14 17:22:22 +02:00
|
|
|
|
2010-08-20 15:12:29 +02:00
|
|
|
if (isDesignClientConnected()) {
|
|
|
|
|
if (!m_designClient->selectedItemIds().isEmpty())
|
|
|
|
|
onCurrentObjectsChanged(m_designClient->selectedItemIds(), false);
|
2010-07-26 15:31:59 +02:00
|
|
|
|
2010-08-20 15:12:29 +02:00
|
|
|
m_designClient->setObjectIdList(m_rootObjects);
|
|
|
|
|
}
|
2010-07-14 17:22:22 +02:00
|
|
|
}
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-30 12:05:26 +02:00
|
|
|
void ClientProxy::buildDebugIdHashRecursive(const QDeclarativeDebugObjectReference& ref)
|
|
|
|
|
{
|
|
|
|
|
QString filename = ref.source().url().toLocalFile();
|
|
|
|
|
int lineNum = ref.source().lineNumber();
|
|
|
|
|
int colNum = ref.source().columnNumber();
|
|
|
|
|
int rev = 0;
|
2010-08-30 18:40:56 +02:00
|
|
|
|
|
|
|
|
// handle the case where the url contains the revision number encoded. (for object created by the debugger)
|
2010-08-30 12:05:26 +02:00
|
|
|
static QRegExp rx("^(.*)_(\\d+):(\\d+)$");
|
|
|
|
|
if (rx.exactMatch(filename)) {
|
|
|
|
|
filename = rx.cap(1);
|
|
|
|
|
rev = rx.cap(2).toInt();
|
|
|
|
|
lineNum += rx.cap(3).toInt() - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//convert the filename to a canonical filename in case of febug build.
|
|
|
|
|
bool isShadowBuild = InspectorUi::instance()->isShadowBuildProject();
|
|
|
|
|
if (isShadowBuild && rev == 0) {
|
|
|
|
|
QString shadowBuildDir = InspectorUi::instance()->debugProjectBuildDirectory();
|
|
|
|
|
|
|
|
|
|
if (filename.startsWith(shadowBuildDir)) {
|
|
|
|
|
ProjectExplorer::Project *debugProject = InspectorUi::instance()->debugProject();
|
|
|
|
|
filename = debugProject->projectDirectory() + filename.mid(shadowBuildDir.length());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-30 18:40:56 +02:00
|
|
|
// append the debug ids in the hash
|
2010-08-30 12:05:26 +02:00
|
|
|
m_debugIdHash[qMakePair<QString, int>(filename, rev)][qMakePair<int, int>(lineNum, colNum)].append(ref.debugId());
|
|
|
|
|
|
|
|
|
|
foreach(const QDeclarativeDebugObjectReference &it, ref.children())
|
|
|
|
|
buildDebugIdHashRecursive(it);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
void ClientProxy::reloadQmlViewer()
|
2010-06-28 18:05:24 +02:00
|
|
|
{
|
2010-07-14 17:22:22 +02:00
|
|
|
if (isDesignClientConnected())
|
2010-07-08 11:34:51 +02:00
|
|
|
m_designClient->reloadViewer();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-12 12:02:35 +02:00
|
|
|
void ClientProxy::setDesignModeBehavior(bool inDesignMode)
|
|
|
|
|
{
|
2010-07-14 17:22:22 +02:00
|
|
|
if (isDesignClientConnected())
|
2010-07-12 12:02:35 +02:00
|
|
|
m_designClient->setDesignModeBehavior(inDesignMode);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
void ClientProxy::setAnimationSpeed(qreal slowdownFactor)
|
|
|
|
|
{
|
2010-07-14 17:22:22 +02:00
|
|
|
if (isDesignClientConnected())
|
2010-07-08 11:34:51 +02:00
|
|
|
m_designClient->setAnimationSpeed(slowdownFactor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClientProxy::changeToColorPickerTool()
|
|
|
|
|
{
|
2010-07-14 17:22:22 +02:00
|
|
|
if (isDesignClientConnected())
|
2010-07-08 11:34:51 +02:00
|
|
|
m_designClient->changeToColorPickerTool();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClientProxy::changeToZoomTool()
|
|
|
|
|
{
|
2010-07-14 17:22:22 +02:00
|
|
|
if (isDesignClientConnected())
|
2010-07-08 11:34:51 +02:00
|
|
|
m_designClient->changeToZoomTool();
|
|
|
|
|
}
|
|
|
|
|
void ClientProxy::changeToSelectTool()
|
|
|
|
|
{
|
2010-07-14 17:22:22 +02:00
|
|
|
if (isDesignClientConnected())
|
2010-07-08 11:34:51 +02:00
|
|
|
m_designClient->changeToSelectTool();
|
2010-06-28 18:05:24 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
void ClientProxy::changeToSelectMarqueeTool()
|
|
|
|
|
{
|
2010-07-14 17:22:22 +02:00
|
|
|
if (isDesignClientConnected())
|
2010-07-08 11:34:51 +02:00
|
|
|
m_designClient->changeToSelectMarqueeTool();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 14:26:25 +02:00
|
|
|
void ClientProxy::createQmlObject(const QString &qmlText, int parentDebugId,
|
2010-07-16 09:41:56 +02:00
|
|
|
const QStringList &imports, const QString &filename)
|
|
|
|
|
{
|
|
|
|
|
if (isDesignClientConnected())
|
2010-07-21 14:26:25 +02:00
|
|
|
m_designClient->createQmlObject(qmlText, parentDebugId, imports, filename);
|
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
|
|
|
{
|
|
|
|
|
if (isDesignClientConnected())
|
|
|
|
|
m_designClient->destroyQmlObject(debugId);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-26 17:38:31 +02:00
|
|
|
void ClientProxy::reparentQmlObject(int debugId, int newParent)
|
|
|
|
|
{
|
|
|
|
|
if (isDesignClientConnected())
|
|
|
|
|
m_designClient->reparentQmlObject(debugId, newParent);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-03 10:17:09 +02:00
|
|
|
void ClientProxy::setContextPathIndex(int contextIndex)
|
|
|
|
|
{
|
|
|
|
|
if (isDesignClientConnected())
|
|
|
|
|
m_designClient->setContextPathIndex(contextIndex);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-19 10:42:39 +02:00
|
|
|
|
2010-07-14 17:22:22 +02:00
|
|
|
bool ClientProxy::isDesignClientConnected() const
|
|
|
|
|
{
|
2010-08-13 14:18:10 +02:00
|
|
|
return (m_designClient && m_adapter->isConnected());
|
2010-07-14 17:22:22 +02:00
|
|
|
}
|
2010-07-08 11:34:51 +02:00
|
|
|
|
2010-06-28 18:05:24 +02:00
|
|
|
void ClientProxy::reloadEngines()
|
|
|
|
|
{
|
|
|
|
|
if (m_engineQuery) {
|
|
|
|
|
emit connectionStatusMessage("[Inspector] Waiting for response to previous engine query");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emit aboutToReloadEngines();
|
|
|
|
|
|
|
|
|
|
m_engineQuery = m_client->queryAvailableEngines(this);
|
|
|
|
|
if (!m_engineQuery->isWaiting())
|
|
|
|
|
updateEngineList();
|
|
|
|
|
else
|
2010-06-29 15:06:50 +02:00
|
|
|
connect(m_engineQuery, SIGNAL(stateChanged(QDeclarativeDebugQuery::State)),
|
2010-06-28 18:05:24 +02:00
|
|
|
this, SLOT(updateEngineList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<QDeclarativeDebugEngineReference> ClientProxy::engines() const
|
|
|
|
|
{
|
|
|
|
|
return m_engines;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClientProxy::updateEngineList()
|
|
|
|
|
{
|
|
|
|
|
m_engines = m_engineQuery->engines();
|
2010-06-29 15:06:50 +02:00
|
|
|
delete m_engineQuery;
|
|
|
|
|
m_engineQuery = 0;
|
2010-06-28 18:05:24 +02:00
|
|
|
|
|
|
|
|
emit enginesChanged();
|
|
|
|
|
}
|
2010-08-13 14:18:10 +02:00
|
|
|
|
|
|
|
|
Debugger::Internal::QmlAdapter *ClientProxy::qmlAdapter() const
|
|
|
|
|
{
|
|
|
|
|
return m_adapter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ClientProxy::isConnected() const
|
|
|
|
|
{
|
|
|
|
|
return m_adapter->isConnected();
|
|
|
|
|
}
|
2010-08-24 15:24:04 +02:00
|
|
|
|
|
|
|
|
void ClientProxy::newObjects()
|
|
|
|
|
{
|
|
|
|
|
if (!m_requestObjectsTimer.isActive())
|
|
|
|
|
m_requestObjectsTimer.start();
|
|
|
|
|
}
|