1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLENGINEDEBUGSERVICE_H
5#define QQMLENGINEDEBUGSERVICE_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qqmldebugservice_p.h>
19#include <private/qqmldebugserviceinterfaces_p.h>
20
21#include <QtCore/qurl.h>
22#include <QtCore/qvariant.h>
23#include <QtCore/QPointer>
24
25QT_BEGIN_NAMESPACE
26
27class QQmlEngine;
28class QQmlContext;
29class QQmlWatcher;
30class QDataStream;
31class QQmlDebugStatesDelegate;
32
33class QQmlEngineDebugServiceImpl : public QQmlEngineDebugService
34{
35 Q_OBJECT
36public:
37 QQmlEngineDebugServiceImpl(QObject * = nullptr);
38 ~QQmlEngineDebugServiceImpl();
39
40 struct QQmlObjectData {
41 QUrl url;
42 int lineNumber;
43 int columnNumber;
44 QString idString;
45 QString objectName;
46 QString objectType;
47 int objectId;
48 int contextId;
49 int parentId;
50 };
51
52 struct QQmlObjectProperty {
53 enum Type { Unknown, Basic, Object, List, SignalProperty, Variant };
54 Type type;
55 QString name;
56 QVariant value;
57 QString valueTypeName;
58 QString binding;
59 bool hasNotifySignal;
60 };
61
62 void engineAboutToBeAdded(QJSEngine *) override;
63 void engineAboutToBeRemoved(QJSEngine *) override;
64 void objectCreated(QJSEngine *, QObject *) override;
65
66 QQmlDebugStatesDelegate *statesDelegate()
67 {
68 if (!m_statesDelegate)
69 m_statesDelegate = createStatesDelegate();
70 return m_statesDelegate;
71 }
72
73Q_SIGNALS:
74 void scheduleMessage(const QByteArray &);
75
76protected:
77 void messageReceived(const QByteArray &) override;
78
79private:
80 friend class QQmlDebuggerServiceFactory;
81
82 void processMessage(const QByteArray &msg);
83 void propertyChanged(qint32 id, qint32 objectId, const QMetaProperty &property,
84 const QVariant &value);
85
86 void prepareDeferredObjects(QObject *);
87 void buildObjectList(QDataStream &, QQmlContext *,
88 const QList<QPointer<QObject> > &instances);
89 void buildObjectDump(QDataStream &, QObject *, bool, bool);
90 void buildStatesList(bool cleanList, const QList<QPointer<QObject> > &instances);
91 QQmlObjectData objectData(QObject *);
92 QQmlObjectProperty propertyData(QObject *, int);
93 QVariant valueContents(QVariant defaultValue) const;
94 bool setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue, QString filename = QString(), int line = -1, int column = 0);
95 bool resetBinding(int objectId, const QString &propertyName);
96 bool setMethodBody(int objectId, const QString &method, const QString &body);
97 void storeObjectIds(QObject *co);
98 QList<QObject *> objectForLocationInfo(const QString &filename, int lineNumber,
99 int columnNumber);
100
101 QList<QJSEngine *> m_engines;
102 QQmlWatcher *m_watch;
103 QQmlDebugStatesDelegate *m_statesDelegate;
104};
105QDataStream &operator<<(QDataStream &, const QQmlEngineDebugServiceImpl::QQmlObjectData &);
106QDataStream &operator>>(QDataStream &, QQmlEngineDebugServiceImpl::QQmlObjectData &);
107QDataStream &operator<<(QDataStream &, const QQmlEngineDebugServiceImpl::QQmlObjectProperty &);
108QDataStream &operator>>(QDataStream &, QQmlEngineDebugServiceImpl::QQmlObjectProperty &);
109
110QT_END_NAMESPACE
111
112#endif // QQMLENGINEDEBUGSERVICE_H
113
114

source code of qtdeclarative/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.h