1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
9 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
14 ** Please review the following information to ensure the GNU Lesser General
15 ** Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
24 ** Alternatively, this file may be used in accordance with the terms and
25 ** conditions contained in a signed written agreement between you and Nokia.
27 ** If you have questions regarding the use of this file, please contact
28 ** Nokia at qt-info@nokia.com.
30 **************************************************************************/
32 #ifndef QDECLARATIVEDEBUG_H
33 #define QDECLARATIVEDEBUG_H
35 #include <QtCore/qobject.h>
36 #include <QtCore/qurl.h>
37 #include <QtCore/qvariant.h>
41 namespace QmlJsDebugClient {
43 class QDeclarativeDebugConnection;
44 class QDeclarativeDebugWatch;
45 class QDeclarativeDebugPropertyWatch;
46 class QDeclarativeDebugObjectExpressionWatch;
47 class QDeclarativeDebugEnginesQuery;
48 class QDeclarativeDebugRootContextQuery;
49 class QDeclarativeDebugObjectQuery;
50 class QDeclarativeDebugExpressionQuery;
51 class QDeclarativeDebugPropertyReference;
52 class QDeclarativeDebugContextReference;
53 class QDeclarativeDebugObjectReference;
54 class QDeclarativeDebugFileReference;
55 class QDeclarativeDebugEngineReference;
56 class QDeclarativeEngineDebugPrivate;
58 class QDeclarativeEngineDebug : public QObject
62 enum Status { NotConnected, Unavailable, Enabled };
64 explicit QDeclarativeEngineDebug(QDeclarativeDebugConnection *, QObject * = 0);
65 ~QDeclarativeEngineDebug();
67 Status status() const;
69 QDeclarativeDebugPropertyWatch *addWatch(const QDeclarativeDebugPropertyReference &,
71 QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugContextReference &, const QString &,
73 QDeclarativeDebugObjectExpressionWatch *addWatch(const QDeclarativeDebugObjectReference &, const QString &,
75 QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugObjectReference &,
77 QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugFileReference &,
80 void removeWatch(QDeclarativeDebugWatch *watch);
82 QDeclarativeDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0);
83 QDeclarativeDebugRootContextQuery *queryRootContexts(const QDeclarativeDebugEngineReference &,
85 QDeclarativeDebugObjectQuery *queryObject(const QDeclarativeDebugObjectReference &,
87 QDeclarativeDebugObjectQuery *queryObjectRecursive(const QDeclarativeDebugObjectReference &,
89 QDeclarativeDebugExpressionQuery *queryExpressionResult(int objectDebugId,
92 bool setBindingForObject(int objectDebugId, const QString &propertyName,
93 const QVariant &bindingExpression, bool isLiteralValue);
94 bool resetBindingForObject(int objectDebugId, const QString &propertyName);
95 bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody);
99 void statusChanged(Status status);
102 Q_DECLARE_PRIVATE(QDeclarativeEngineDebug)
103 QScopedPointer<QDeclarativeEngineDebugPrivate> d_ptr;
106 class QDeclarativeDebugWatch : public QObject
110 enum State { Waiting, Active, Inactive, Dead };
112 QDeclarativeDebugWatch(QObject *);
113 ~QDeclarativeDebugWatch();
116 int objectDebugId() const;
120 void stateChanged(QDeclarativeDebugWatch::State);
121 //void objectChanged(int, const QDeclarativeDebugObjectReference &);
122 //void valueChanged(int, const QVariant &);
124 // Server sends value as string if it is a user-type variant
125 void valueChanged(const QByteArray &name, const QVariant &value);
128 friend class QDeclarativeEngineDebug;
129 friend class QDeclarativeEngineDebugPrivate;
130 void setState(State);
133 QDeclarativeEngineDebug *m_client;
137 class QDeclarativeDebugPropertyWatch : public QDeclarativeDebugWatch
141 QDeclarativeDebugPropertyWatch(QObject *parent);
143 QString name() const;
146 friend class QDeclarativeEngineDebug;
150 class QDeclarativeDebugObjectExpressionWatch : public QDeclarativeDebugWatch
154 QDeclarativeDebugObjectExpressionWatch(QObject *parent);
156 QString expression() const;
159 friend class QDeclarativeEngineDebug;
164 class QDeclarativeDebugQuery : public QObject
168 enum State { Waiting, Error, Completed };
171 bool isWaiting() const;
173 // bool waitUntilCompleted();
176 void stateChanged(QDeclarativeDebugQuery::State);
179 QDeclarativeDebugQuery(QObject *);
182 friend class QDeclarativeEngineDebug;
183 friend class QDeclarativeEngineDebugPrivate;
184 void setState(State);
188 class QDeclarativeDebugFileReference
191 QDeclarativeDebugFileReference();
192 QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &);
193 QDeclarativeDebugFileReference &operator=(const QDeclarativeDebugFileReference &);
196 void setUrl(const QUrl &);
197 int lineNumber() const;
198 void setLineNumber(int);
199 int columnNumber() const;
200 void setColumnNumber(int);
203 friend class QDeclarativeEngineDebugPrivate;
209 class QDeclarativeDebugEngineReference
212 QDeclarativeDebugEngineReference();
213 QDeclarativeDebugEngineReference(int);
214 QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &);
215 QDeclarativeDebugEngineReference &operator=(const QDeclarativeDebugEngineReference &);
218 QString name() const;
221 friend class QDeclarativeEngineDebugPrivate;
226 class QDeclarativeDebugObjectReference
229 QDeclarativeDebugObjectReference();
230 QDeclarativeDebugObjectReference(int);
231 QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &);
232 QDeclarativeDebugObjectReference &operator=(const QDeclarativeDebugObjectReference &);
235 QString className() const;
236 QString idString() const;
237 QString name() const;
239 QDeclarativeDebugFileReference source() const;
240 int contextDebugId() const;
242 QList<QDeclarativeDebugPropertyReference> properties() const;
243 QList<QDeclarativeDebugObjectReference> children() const;
246 friend class QDeclarativeEngineDebugPrivate;
251 QDeclarativeDebugFileReference m_source;
252 int m_contextDebugId;
253 QList<QDeclarativeDebugPropertyReference> m_properties;
254 QList<QDeclarativeDebugObjectReference> m_children;
257 class QDeclarativeDebugContextReference
260 QDeclarativeDebugContextReference();
261 QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &);
262 QDeclarativeDebugContextReference &operator=(const QDeclarativeDebugContextReference &);
265 QString name() const;
267 QList<QDeclarativeDebugObjectReference> objects() const;
268 QList<QDeclarativeDebugContextReference> contexts() const;
271 friend class QDeclarativeEngineDebugPrivate;
274 QList<QDeclarativeDebugObjectReference> m_objects;
275 QList<QDeclarativeDebugContextReference> m_contexts;
278 class QDeclarativeDebugPropertyReference
281 QDeclarativeDebugPropertyReference();
282 QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &);
283 QDeclarativeDebugPropertyReference &operator=(const QDeclarativeDebugPropertyReference &);
285 int objectDebugId() const;
286 QString name() const;
287 QVariant value() const;
288 QString valueTypeName() const;
289 QString binding() const;
290 bool hasNotifySignal() const;
293 friend class QDeclarativeEngineDebugPrivate;
297 QString m_valueTypeName;
299 bool m_hasNotifySignal;
303 class QDeclarativeDebugEnginesQuery : public QDeclarativeDebugQuery
307 virtual ~QDeclarativeDebugEnginesQuery();
308 QList<QDeclarativeDebugEngineReference> engines() const;
310 friend class QDeclarativeEngineDebug;
311 friend class QDeclarativeEngineDebugPrivate;
312 QDeclarativeDebugEnginesQuery(QObject *);
313 QDeclarativeEngineDebug *m_client;
315 QList<QDeclarativeDebugEngineReference> m_engines;
318 class QDeclarativeDebugRootContextQuery : public QDeclarativeDebugQuery
322 virtual ~QDeclarativeDebugRootContextQuery();
323 QDeclarativeDebugContextReference rootContext() const;
325 friend class QDeclarativeEngineDebug;
326 friend class QDeclarativeEngineDebugPrivate;
327 QDeclarativeDebugRootContextQuery(QObject *);
328 QDeclarativeEngineDebug *m_client;
330 QDeclarativeDebugContextReference m_context;
333 class QDeclarativeDebugObjectQuery : public QDeclarativeDebugQuery
337 virtual ~QDeclarativeDebugObjectQuery();
338 QDeclarativeDebugObjectReference object() const;
340 friend class QDeclarativeEngineDebug;
341 friend class QDeclarativeEngineDebugPrivate;
342 QDeclarativeDebugObjectQuery(QObject *);
343 QDeclarativeEngineDebug *m_client;
345 QDeclarativeDebugObjectReference m_object;
349 class QDeclarativeDebugExpressionQuery : public QDeclarativeDebugQuery
353 virtual ~QDeclarativeDebugExpressionQuery();
354 QVariant expression() const;
355 QVariant result() const;
357 friend class QDeclarativeEngineDebug;
358 friend class QDeclarativeEngineDebugPrivate;
359 QDeclarativeDebugExpressionQuery(QObject *);
360 QDeclarativeEngineDebug *m_client;
368 Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugEngineReference)
369 Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugObjectReference)
370 Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugContextReference)
371 Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugPropertyReference)
374 #endif // QDECLARATIVEDEBUG_H