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 | |
25 | QT_BEGIN_NAMESPACE |
26 | |
27 | class QQmlEngine; |
28 | class QQmlContext; |
29 | class QQmlWatcher; |
30 | class QDataStream; |
31 | class QQmlDebugStatesDelegate; |
32 | |
33 | class QQmlEngineDebugServiceImpl : public QQmlEngineDebugService |
34 | { |
35 | Q_OBJECT |
36 | public: |
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 | |
73 | Q_SIGNALS: |
74 | void scheduleMessage(const QByteArray &); |
75 | |
76 | protected: |
77 | void messageReceived(const QByteArray &) override; |
78 | |
79 | private: |
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 | }; |
105 | QDataStream &operator<<(QDataStream &, const QQmlEngineDebugServiceImpl::QQmlObjectData &); |
106 | QDataStream &operator>>(QDataStream &, QQmlEngineDebugServiceImpl::QQmlObjectData &); |
107 | QDataStream &operator<<(QDataStream &, const QQmlEngineDebugServiceImpl::QQmlObjectProperty &); |
108 | QDataStream &operator>>(QDataStream &, QQmlEngineDebugServiceImpl::QQmlObjectProperty &); |
109 | |
110 | QT_END_NAMESPACE |
111 | |
112 | #endif // QQMLENGINEDEBUGSERVICE_H |
113 | |
114 | |