| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtQml module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #ifndef QQMLENGINEDEBUGSERVICE_H |
| 41 | #define QQMLENGINEDEBUGSERVICE_H |
| 42 | |
| 43 | // |
| 44 | // W A R N I N G |
| 45 | // ------------- |
| 46 | // |
| 47 | // This file is not part of the Qt API. It exists purely as an |
| 48 | // implementation detail. This header file may change from version to |
| 49 | // version without notice, or even be removed. |
| 50 | // |
| 51 | // We mean it. |
| 52 | // |
| 53 | |
| 54 | #include <private/qqmldebugservice_p.h> |
| 55 | #include <private/qqmldebugserviceinterfaces_p.h> |
| 56 | |
| 57 | #include <QtCore/qurl.h> |
| 58 | #include <QtCore/qvariant.h> |
| 59 | #include <QtCore/QPointer> |
| 60 | |
| 61 | QT_BEGIN_NAMESPACE |
| 62 | |
| 63 | class QQmlEngine; |
| 64 | class QQmlContext; |
| 65 | class QQmlWatcher; |
| 66 | class QDataStream; |
| 67 | class QQmlDebugStatesDelegate; |
| 68 | |
| 69 | class QQmlEngineDebugServiceImpl : public QQmlEngineDebugService |
| 70 | { |
| 71 | Q_OBJECT |
| 72 | public: |
| 73 | QQmlEngineDebugServiceImpl(QObject * = 0); |
| 74 | ~QQmlEngineDebugServiceImpl(); |
| 75 | |
| 76 | struct QQmlObjectData { |
| 77 | QUrl url; |
| 78 | int lineNumber; |
| 79 | int columnNumber; |
| 80 | QString idString; |
| 81 | QString objectName; |
| 82 | QString objectType; |
| 83 | int objectId; |
| 84 | int contextId; |
| 85 | int parentId; |
| 86 | }; |
| 87 | |
| 88 | struct QQmlObjectProperty { |
| 89 | enum Type { Unknown, Basic, Object, List, SignalProperty, Variant }; |
| 90 | Type type; |
| 91 | QString name; |
| 92 | QVariant value; |
| 93 | QString valueTypeName; |
| 94 | QString binding; |
| 95 | bool hasNotifySignal; |
| 96 | }; |
| 97 | |
| 98 | void engineAboutToBeAdded(QJSEngine *) override; |
| 99 | void engineAboutToBeRemoved(QJSEngine *) override; |
| 100 | void objectCreated(QJSEngine *, QObject *) override; |
| 101 | |
| 102 | void setStatesDelegate(QQmlDebugStatesDelegate *) override; |
| 103 | |
| 104 | signals: |
| 105 | void scheduleMessage(const QByteArray &); |
| 106 | |
| 107 | protected: |
| 108 | void messageReceived(const QByteArray &) override; |
| 109 | |
| 110 | private: |
| 111 | friend class QQmlDebuggerServiceFactory; |
| 112 | |
| 113 | void processMessage(const QByteArray &msg); |
| 114 | void propertyChanged(qint32 id, qint32 objectId, const QMetaProperty &property, |
| 115 | const QVariant &value); |
| 116 | |
| 117 | void prepareDeferredObjects(QObject *); |
| 118 | void buildObjectList(QDataStream &, QQmlContext *, |
| 119 | const QList<QPointer<QObject> > &instances); |
| 120 | void buildObjectDump(QDataStream &, QObject *, bool, bool); |
| 121 | void buildStatesList(bool cleanList, const QList<QPointer<QObject> > &instances); |
| 122 | QQmlObjectData objectData(QObject *); |
| 123 | QQmlObjectProperty propertyData(QObject *, int); |
| 124 | QVariant valueContents(QVariant defaultValue) const; |
| 125 | bool setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue, QString filename = QString(), int line = -1, int column = 0); |
| 126 | bool resetBinding(int objectId, const QString &propertyName); |
| 127 | bool setMethodBody(int objectId, const QString &method, const QString &body); |
| 128 | void storeObjectIds(QObject *co); |
| 129 | QList<QObject *> objectForLocationInfo(const QString &filename, int lineNumber, |
| 130 | int columnNumber); |
| 131 | |
| 132 | QList<QJSEngine *> m_engines; |
| 133 | QQmlWatcher *m_watch; |
| 134 | QQmlDebugStatesDelegate *m_statesDelegate; |
| 135 | }; |
| 136 | QDataStream &operator<<(QDataStream &, const QQmlEngineDebugServiceImpl::QQmlObjectData &); |
| 137 | QDataStream &operator>>(QDataStream &, QQmlEngineDebugServiceImpl::QQmlObjectData &); |
| 138 | QDataStream &operator<<(QDataStream &, const QQmlEngineDebugServiceImpl::QQmlObjectProperty &); |
| 139 | QDataStream &operator>>(QDataStream &, QQmlEngineDebugServiceImpl::QQmlObjectProperty &); |
| 140 | |
| 141 | QT_END_NAMESPACE |
| 142 | |
| 143 | #endif // QQMLENGINEDEBUGSERVICE_H |
| 144 | |
| 145 | |