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>
|
2018-11-15 13:33:45 +01:00
|
|
|
#include <debugger/watchdata.h>
|
|
|
|
|
#include <qmldebug/qmlenginedebugclient.h>
|
2015-08-26 11:51:56 +02:00
|
|
|
|
|
|
|
|
namespace QmlDebug {
|
2018-11-15 13:33:45 +01:00
|
|
|
class QmlToolsClient;
|
2015-08-26 11:51:56 +02:00
|
|
|
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;
|
2012-04-18 14:20:54 +02:00
|
|
|
|
|
|
|
|
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
|
|
|
|
2018-11-15 17:14:48 +01:00
|
|
|
quint32 queryExpressionResult(int debugId, const QString &expression, int engineId);
|
2015-12-16 17:17:38 +01:00
|
|
|
void assignValue(const WatchItem *data, const QString &expression, const QVariant &valueV);
|
|
|
|
|
void updateWatchData(const WatchItem &data);
|
2018-11-15 13:33:45 +01:00
|
|
|
void watchDataSelected(int id);
|
2017-05-19 13:14:44 +02:00
|
|
|
void enableTools(bool enable);
|
2018-11-15 17:14:48 +01:00
|
|
|
int engineId(const WatchItem *item) const;
|
2016-08-04 00:19:05 +02:00
|
|
|
|
|
|
|
|
private:
|
2018-11-15 16:42:25 +01:00
|
|
|
void selectObjectsInTree(const QList<int> &debugIds);
|
2015-08-26 11:51:56 +02:00
|
|
|
void addObjectWatch(int objectDebugId);
|
2012-04-18 14:20:54 +02:00
|
|
|
|
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();
|
2018-11-15 17:14:48 +01:00
|
|
|
void updateObjectTree(const QmlDebug::ContextReference &contexts, int engineId = -1);
|
|
|
|
|
void verifyAndInsertObjectInTree(const QmlDebug::ObjectReference &object, int engineId = -1);
|
2018-11-22 12:12:43 +01:00
|
|
|
void insertObjectInTree(const QmlDebug::ObjectReference &result, int parentId);
|
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 toolsClientStateChanged(QmlDebug::QmlDebugClient::State state);
|
|
|
|
|
|
|
|
|
|
void selectObjectsFromToolsClient(const QList<int> &debugIds);
|
|
|
|
|
|
|
|
|
|
void onSelectActionTriggered(bool checked);
|
|
|
|
|
void onShowAppOnTopChanged(bool checked);
|
|
|
|
|
void onReloaded();
|
2018-11-15 13:33:45 +01:00
|
|
|
void jumpToObjectDefinitionInEditor(const QmlDebug::FileReference &objSource);
|
2015-08-26 11:51:56 +02:00
|
|
|
|
2018-11-15 16:42:25 +01:00
|
|
|
void selectObjects(const QList<int> &debugIds, const QmlDebug::FileReference &source);
|
2015-08-26 11:51:56 +02:00
|
|
|
|
2015-09-01 12:57:51 +02:00
|
|
|
QPointer<QmlEngine> m_qmlEngine;
|
2018-11-15 13:33:45 +01:00
|
|
|
QmlDebug::QmlEngineDebugClient *m_engineClient = nullptr;
|
|
|
|
|
QmlDebug::QmlToolsClient *m_toolsClient = nullptr;
|
2012-04-18 14:20:54 +02:00
|
|
|
|
2018-07-23 22:28:49 +02:00
|
|
|
quint32 m_engineQueryId = 0;
|
2018-11-15 17:14:48 +01:00
|
|
|
|
|
|
|
|
QList<quint32> m_rootContextQueryIds;
|
|
|
|
|
QHash<int, QmlDebug::ContextReference> m_rootContexts;
|
2018-11-15 13:33:45 +01:00
|
|
|
|
2018-11-15 16:42:25 +01:00
|
|
|
QList<int> m_objectsToSelect;
|
2018-11-15 13:33:45 +01:00
|
|
|
|
2012-04-18 14:20:54 +02:00
|
|
|
QList<quint32> m_objectTreeQueryIds;
|
2018-11-15 17:14:48 +01:00
|
|
|
QStack<QPair<QmlDebug::ObjectReference, int>> m_objectStack;
|
|
|
|
|
QList<QmlDebug::EngineReference> m_engines;
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
// toolbar
|
|
|
|
|
Core::Context m_inspectorToolsContext;
|
2018-11-15 13:33:45 +01:00
|
|
|
QAction *m_selectAction = nullptr;
|
|
|
|
|
QAction *m_showAppOnTopAction = nullptr;
|
2012-04-18 14:20:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // Debugger
|