2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-04-18 14:20:54 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-04-18 14:20:54 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2012-04-18 14:20:54 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-04-18 14:20:54 +02:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2012-04-18 14:20:54 +02:00
|
|
|
|
2012-05-14 23:26:23 +02:00
|
|
|
#include <QStack>
|
2015-08-26 10:52:04 +02:00
|
|
|
#include <QPointer>
|
2012-05-14 23:26:23 +02:00
|
|
|
#include <QTimer>
|
2012-04-18 14:20:54 +02:00
|
|
|
|
2015-08-26 11:51:56 +02:00
|
|
|
#include <coreplugin/icontext.h>
|
|
|
|
|
#include <debugger/debuggerconstants.h>
|
2012-04-18 14:20:54 +02:00
|
|
|
#include <qmldebug/baseenginedebugclient.h>
|
2015-08-26 11:51:56 +02:00
|
|
|
|
|
|
|
|
namespace QmlDebug {
|
|
|
|
|
class BaseEngineDebugClient;
|
|
|
|
|
class BaseToolsClient;
|
|
|
|
|
class ObjectReference;
|
|
|
|
|
class FileReference;
|
|
|
|
|
class QmlDebugConnection;
|
|
|
|
|
}
|
2012-04-18 14:20:54 +02:00
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2014-12-12 15:33:16 +01:00
|
|
|
class DebuggerEngine;
|
2015-08-26 11:51:56 +02:00
|
|
|
class QmlEngine;
|
2015-12-16 17:17:38 +01:00
|
|
|
class WatchItem;
|
2012-04-18 14:20:54 +02:00
|
|
|
|
|
|
|
|
//map <filename, editorRevision> -> <lineNumber, columnNumber> -> debugId
|
|
|
|
|
typedef
|
|
|
|
|
QHash<QPair<QString, int>, QHash<QPair<int, int>, QList<int> > > DebugIdHash;
|
|
|
|
|
|
|
|
|
|
class QmlInspectorAgent : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2016-08-04 00:19:05 +02:00
|
|
|
|
2012-04-18 14:20:54 +02:00
|
|
|
public:
|
2015-08-26 11:51:56 +02:00
|
|
|
QmlInspectorAgent(QmlEngine *engine, QmlDebug::QmlDebugConnection *connection);
|
2012-04-18 14:20:54 +02:00
|
|
|
|
|
|
|
|
quint32 queryExpressionResult(int debugId, const QString &expression);
|
2015-12-16 17:17:38 +01:00
|
|
|
void assignValue(const WatchItem *data, const QString &expression, const QVariant &valueV);
|
|
|
|
|
void updateWatchData(const WatchItem &data);
|
2015-12-01 10:58:01 +01:00
|
|
|
void watchDataSelected(qint64 id);
|
2016-08-04 00:19:05 +02:00
|
|
|
|
|
|
|
|
private:
|
2012-05-25 17:43:56 +02:00
|
|
|
bool selectObjectInTree(int debugId);
|
2015-08-26 11:51:56 +02:00
|
|
|
void addObjectWatch(int objectDebugId);
|
2012-04-18 14:20:54 +02:00
|
|
|
|
2012-05-25 17:43:56 +02:00
|
|
|
QmlDebug::ObjectReference objectForId(int objectDebugId) const;
|
2012-05-14 23:26:23 +02:00
|
|
|
QString displayName(int objectDebugId) const;
|
2012-05-25 09:58:52 +02:00
|
|
|
void reloadEngines();
|
2016-08-04 00:19:05 +02:00
|
|
|
void fetchObject(int debugId);
|
2012-04-18 14:20:54 +02:00
|
|
|
|
2014-05-05 16:11:43 +02:00
|
|
|
void updateState();
|
2012-04-18 14:20:54 +02:00
|
|
|
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
|
|
|
|
2015-08-26 11:51:56 +02:00
|
|
|
void queryEngineContext();
|
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);
|
2015-03-18 17:23:35 +01:00
|
|
|
void addWatchData(const QmlDebug::ObjectReference &obj,
|
2016-06-07 17:04:53 +02:00
|
|
|
const QString &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
|
|
|
|
2015-08-26 11:51:56 +02:00
|
|
|
void onEngineStateChanged(const Debugger::DebuggerState);
|
|
|
|
|
|
|
|
|
|
void clientStateChanged(QmlDebug::QmlDebugClient::State state);
|
|
|
|
|
void toolsClientStateChanged(QmlDebug::QmlDebugClient::State state);
|
|
|
|
|
void engineClientStateChanged(QmlDebug::QmlDebugClient::State state);
|
|
|
|
|
|
|
|
|
|
void selectObjectsFromToolsClient(const QList<int> &debugIds);
|
|
|
|
|
|
|
|
|
|
void onSelectActionTriggered(bool checked);
|
|
|
|
|
void onZoomActionTriggered(bool checked);
|
|
|
|
|
void onShowAppOnTopChanged(bool checked);
|
|
|
|
|
void onReloaded();
|
|
|
|
|
void jumpToObjectDefinitionInEditor(const QmlDebug::FileReference &objSource, int debugId = -1);
|
|
|
|
|
|
|
|
|
|
void setActiveEngineClient(QmlDebug::BaseEngineDebugClient *client);
|
|
|
|
|
|
|
|
|
|
enum SelectionTarget { NoTarget, ToolTarget, EditorTarget };
|
|
|
|
|
void selectObject(
|
|
|
|
|
const QmlDebug::ObjectReference &objectReference,
|
|
|
|
|
SelectionTarget target);
|
|
|
|
|
|
|
|
|
|
void enableTools(const bool enable);
|
|
|
|
|
|
2012-04-18 14:20:54 +02:00
|
|
|
private:
|
2015-09-01 12:57:51 +02:00
|
|
|
QPointer<QmlEngine> m_qmlEngine;
|
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;
|
2016-06-07 17:04:53 +02:00
|
|
|
QHash<int, QString> 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;
|
2015-08-26 11:51:56 +02:00
|
|
|
|
|
|
|
|
DebuggerEngine *m_masterEngine;
|
|
|
|
|
QHash<QString, QmlDebug::BaseEngineDebugClient*> m_engineClients;
|
|
|
|
|
QmlDebug::BaseToolsClient *m_toolsClient;
|
|
|
|
|
|
|
|
|
|
SelectionTarget m_targetToSync;
|
|
|
|
|
int m_debugIdToSelect;
|
|
|
|
|
|
|
|
|
|
int m_currentSelectedDebugId;
|
|
|
|
|
QString m_currentSelectedDebugName;
|
|
|
|
|
|
|
|
|
|
// toolbar
|
|
|
|
|
bool m_toolsClientConnected;
|
|
|
|
|
Core::Context m_inspectorToolsContext;
|
|
|
|
|
QAction *m_selectAction;
|
|
|
|
|
QAction *m_zoomAction;
|
|
|
|
|
QAction *m_showAppOnTopAction;
|
|
|
|
|
|
|
|
|
|
bool m_engineClientConnected;
|
2012-04-18 14:20:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // Debugger
|