2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-04-18 14:20:54 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2012-04-18 14:20:54 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-04-18 14:20:54 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2012-04-18 14:20:54 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2012-04-18 14:20:54 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-04-18 14:20:54 +02:00
|
|
|
|
|
|
|
|
#ifndef QMLINSPECTORAGENT_H
|
|
|
|
|
#define QMLINSPECTORAGENT_H
|
|
|
|
|
|
2012-05-14 23:26:23 +02:00
|
|
|
#include <QStack>
|
|
|
|
|
#include <QTimer>
|
2012-04-18 14:20:54 +02:00
|
|
|
|
|
|
|
|
#include <qmldebug/baseenginedebugclient.h>
|
|
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
|
|
|
|
|
|
class DebuggerEngine;
|
|
|
|
|
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class WatchData;
|
|
|
|
|
|
|
|
|
|
//map <filename, editorRevision> -> <lineNumber, columnNumber> -> debugId
|
|
|
|
|
typedef
|
|
|
|
|
QHash<QPair<QString, int>, QHash<QPair<int, int>, QList<int> > > DebugIdHash;
|
|
|
|
|
|
|
|
|
|
class QmlInspectorAgent : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
explicit QmlInspectorAgent(DebuggerEngine *engine, QObject *parent = 0);
|
|
|
|
|
|
|
|
|
|
void fetchObject(int debugId);
|
|
|
|
|
quint32 queryExpressionResult(int debugId, const QString &expression);
|
|
|
|
|
|
2012-05-23 14:55:48 +02:00
|
|
|
void assignValue(const WatchData *data, const QString &expression, const QVariant &valueV);
|
2012-04-18 14:20:54 +02:00
|
|
|
void updateWatchData(const WatchData &data);
|
2012-11-23 13:35:44 +01:00
|
|
|
void watchDataSelected(const WatchData *data);
|
2012-05-25 17:43:56 +02:00
|
|
|
bool selectObjectInTree(int debugId);
|
2012-04-18 14:20:54 +02:00
|
|
|
|
|
|
|
|
quint32 setBindingForObject(int objectDebugId,
|
|
|
|
|
const QString &propertyName,
|
|
|
|
|
const QVariant &value,
|
|
|
|
|
bool isLiteralValue,
|
|
|
|
|
QString source,
|
|
|
|
|
int line);
|
|
|
|
|
quint32 setMethodBodyForObject(int objectDebugId, const QString &methodName,
|
|
|
|
|
const QString &methodBody);
|
|
|
|
|
quint32 resetBindingForObject(int objectDebugId,
|
|
|
|
|
const QString &propertyName);
|
|
|
|
|
|
2012-05-25 17:43:56 +02:00
|
|
|
QmlDebug::ObjectReference objectForName(const QString &objectId) const;
|
|
|
|
|
QmlDebug::ObjectReference objectForId(int objectDebugId) const;
|
2012-05-14 23:26:23 +02:00
|
|
|
int objectIdForLocation(int line, int column) const;
|
|
|
|
|
QHash<int, QString> rootObjectIds() const;
|
2012-04-18 14:20:54 +02:00
|
|
|
DebugIdHash debugIdHash() const { return m_debugIdHash; }
|
|
|
|
|
|
|
|
|
|
bool addObjectWatch(int objectDebugId);
|
|
|
|
|
bool isObjectBeingWatched(int objectDebugId);
|
|
|
|
|
bool removeObjectWatch(int objectDebugId);
|
|
|
|
|
void removeAllObjectWatches();
|
|
|
|
|
|
2012-05-10 10:29:11 +02:00
|
|
|
void setEngineClient(QmlDebug::BaseEngineDebugClient *client);
|
2012-05-14 23:26:23 +02:00
|
|
|
QString displayName(int objectDebugId) const;
|
2012-05-25 09:33:02 +02:00
|
|
|
int parentIdForObject(int objectDebugId);
|
2012-05-25 09:58:52 +02:00
|
|
|
void reloadEngines();
|
2012-04-18 14:20:54 +02:00
|
|
|
|
2012-05-10 17:06:29 +02:00
|
|
|
public slots:
|
|
|
|
|
void fetchContextObjectsForLocation(const QString &file,
|
|
|
|
|
int lineNumber, int columnNumber);
|
2012-05-14 23:26:23 +02:00
|
|
|
void queryEngineContext();
|
|
|
|
|
|
2012-04-18 14:20:54 +02:00
|
|
|
signals:
|
|
|
|
|
void objectTreeUpdated();
|
2012-05-10 10:29:11 +02:00
|
|
|
void objectFetched(const QmlDebug::ObjectReference &ref);
|
2012-04-18 14:20:54 +02:00
|
|
|
void expressionResult(quint32 queryId, const QVariant &value);
|
|
|
|
|
void propertyChanged(int debugId, const QByteArray &propertyName,
|
|
|
|
|
const QVariant &propertyValue);
|
2012-06-04 17:17:50 +02:00
|
|
|
void automaticUpdateFailed();
|
2012-11-27 17:16:57 +01:00
|
|
|
void jumpToObjectDefinition(const QmlDebug::FileReference &objSource, int debugId);
|
2012-04-18 14:20:54 +02:00
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void updateStatus();
|
|
|
|
|
void onResult(quint32 queryId, const QVariant &value, const QByteArray &type);
|
2012-05-14 16:11:12 +02:00
|
|
|
void newObject(int engineId, int objectId, int parentId);
|
2012-05-23 14:55:48 +02:00
|
|
|
void onValueChanged(int debugId, const QByteArray &propertyName, const QVariant &value);
|
2012-04-18 14:20:54 +02:00
|
|
|
|
|
|
|
|
private:
|
2012-10-01 17:13:21 +02:00
|
|
|
void updateObjectTree(const QmlDebug::ContextReference &context);
|
2012-11-23 17:15:29 +01:00
|
|
|
void verifyAndInsertObjectInTree(const QmlDebug::ObjectReference &object);
|
2012-10-01 17:13:21 +02:00
|
|
|
void insertObjectInTree(const QmlDebug::ObjectReference &result);
|
2012-04-18 14:20:54 +02:00
|
|
|
|
2012-05-10 10:29:11 +02:00
|
|
|
void buildDebugIdHashRecursive(const QmlDebug::ObjectReference &ref);
|
|
|
|
|
QList<WatchData> buildWatchData(const QmlDebug::ObjectReference &obj,
|
2012-05-29 22:21:04 +02:00
|
|
|
const QByteArray &parentIname, bool append);
|
2012-04-18 14:20:54 +02:00
|
|
|
|
|
|
|
|
enum LogDirection {
|
|
|
|
|
LogSend,
|
|
|
|
|
LogReceive
|
|
|
|
|
};
|
|
|
|
|
void log(LogDirection direction, const QString &message);
|
|
|
|
|
|
2012-05-14 23:26:23 +02:00
|
|
|
bool isConnected() const;
|
|
|
|
|
void clearObjectTree();
|
2012-04-18 14:20:54 +02:00
|
|
|
|
|
|
|
|
private:
|
2012-05-14 23:26:23 +02:00
|
|
|
DebuggerEngine *m_debuggerEngine;
|
2012-04-18 14:20:54 +02:00
|
|
|
QmlDebug::BaseEngineDebugClient *m_engineClient;
|
|
|
|
|
|
|
|
|
|
quint32 m_engineQueryId;
|
|
|
|
|
quint32 m_rootContextQueryId;
|
|
|
|
|
int m_objectToSelect;
|
|
|
|
|
QList<quint32> m_objectTreeQueryIds;
|
2012-05-14 23:26:23 +02:00
|
|
|
QStack<QmlDebug::ObjectReference> m_objectStack;
|
|
|
|
|
QmlDebug::EngineReference m_engine;
|
2012-04-18 14:20:54 +02:00
|
|
|
QHash<int, QByteArray> m_debugIdToIname;
|
2012-05-14 23:26:23 +02:00
|
|
|
QHash<int, QmlDebug::FileReference> m_debugIdLocations;
|
2012-04-18 14:20:54 +02:00
|
|
|
DebugIdHash m_debugIdHash;
|
|
|
|
|
|
|
|
|
|
QList<int> m_objectWatches;
|
2012-05-18 02:28:41 +02:00
|
|
|
QList<int> m_fetchDataIds;
|
2012-05-14 23:26:23 +02:00
|
|
|
QTimer m_delayQueryTimer;
|
2012-04-18 14:20:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // Debugger
|
|
|
|
|
|
|
|
|
|
#endif // QMLINSPECTORAGENT_H
|