QmlDebugging: Remove QQmlDebugClient
[profile/ivi/qtdeclarative.git] / tests / auto / qml / debugger / shared / qqmlenginedebug_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtQml module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QQMLENGINEDEBUG_H
43 #define QQMLENGINEDEBUG_H
44
45 //
46 //  W A R N I N G
47 //  -------------
48 //
49 // This file is not part of the Qt API.  It exists purely as an
50 // implementation detail.  This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55
56 #include <QtCore/qobject.h>
57 #include <QtCore/qurl.h>
58 #include <QtCore/qvariant.h>
59
60 #include <private/qtqmlglobal_p.h>
61
62 class QQmlDebugConnection;
63 class QQmlDebugWatch;
64 class QQmlDebugPropertyWatch;
65 class QQmlDebugObjectExpressionWatch;
66 class QQmlDebugEnginesQuery;
67 class QQmlDebugRootContextQuery;
68 class QQmlDebugObjectQuery;
69 class QQmlDebugExpressionQuery;
70 class QQmlDebugPropertyReference;
71 class QQmlDebugContextReference;
72 class QQmlDebugObjectReference;
73 class QQmlDebugFileReference;
74 class QQmlDebugEngineReference;
75 class QQmlEngineDebugPrivate;
76 class Q_QML_PRIVATE_EXPORT QQmlEngineDebug : public QObject
77 {
78     Q_OBJECT
79 public:
80     enum State { NotConnected, Unavailable, Enabled };
81
82     explicit QQmlEngineDebug(QQmlDebugConnection *, QObject * = 0);
83     ~QQmlEngineDebug();
84
85     State state() const;
86
87     QQmlDebugPropertyWatch *addWatch(const QQmlDebugPropertyReference &,
88                                              QObject *parent = 0);
89     QQmlDebugWatch *addWatch(const QQmlDebugContextReference &, const QString &,
90                                      QObject *parent = 0);
91     QQmlDebugObjectExpressionWatch *addWatch(const QQmlDebugObjectReference &, const QString &,
92                                                      QObject *parent = 0);
93     QQmlDebugWatch *addWatch(const QQmlDebugObjectReference &,
94                                      QObject *parent = 0);
95     QQmlDebugWatch *addWatch(const QQmlDebugFileReference &,
96                                      QObject *parent = 0);
97
98     void removeWatch(QQmlDebugWatch *watch);
99
100     QQmlDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0);
101     QQmlDebugRootContextQuery *queryRootContexts(const QQmlDebugEngineReference &,
102                                                          QObject *parent = 0);
103     QQmlDebugObjectQuery *queryObject(const QQmlDebugObjectReference &,
104                                               QObject *parent = 0);
105     QQmlDebugObjectQuery *queryObjectRecursive(const QQmlDebugObjectReference &,
106                                                        QObject *parent = 0);
107     QQmlDebugExpressionQuery *queryExpressionResult(int objectDebugId,
108                                                             const QString &expr,
109                                                             QObject *parent = 0);
110     bool setBindingForObject(int objectDebugId, const QString &propertyName,
111                              const QVariant &bindingExpression, bool isLiteralValue,
112                              QString source = QString(), int line = -1);
113     bool resetBindingForObject(int objectDebugId, const QString &propertyName);
114     bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody);
115
116 Q_SIGNALS:
117     void newObjects();
118     void stateChanged(State state);
119
120 private:
121     Q_DECLARE_PRIVATE(QQmlEngineDebug)
122 };
123
124 class Q_QML_PRIVATE_EXPORT QQmlDebugWatch : public QObject
125 {
126     Q_OBJECT
127 public:
128     enum State { Waiting, Active, Inactive, Dead };
129
130     QQmlDebugWatch(QObject *);
131     ~QQmlDebugWatch();
132
133     int queryId() const;
134     int objectDebugId() const;
135     State state() const;
136
137 Q_SIGNALS:
138     void stateChanged(QQmlDebugWatch::State);
139     //void objectChanged(int, const QQmlDebugObjectReference &);
140     //void valueChanged(int, const QVariant &);
141
142     // Server sends value as string if it is a user-type variant
143     void valueChanged(const QByteArray &name, const QVariant &value);
144
145 private:
146     friend class QQmlEngineDebug;
147     friend class QQmlEngineDebugPrivate;
148     void setState(State);
149     State m_state;
150     int m_queryId;
151     QQmlEngineDebug *m_client;
152     int m_objectDebugId;
153 };
154
155 class Q_QML_PRIVATE_EXPORT QQmlDebugPropertyWatch : public QQmlDebugWatch
156 {
157     Q_OBJECT
158 public:
159     QQmlDebugPropertyWatch(QObject *parent);
160
161     QString name() const;
162
163 private:
164     friend class QQmlEngineDebug;
165     QString m_name;
166 };
167
168 class Q_QML_PRIVATE_EXPORT QQmlDebugObjectExpressionWatch : public QQmlDebugWatch
169 {
170     Q_OBJECT
171 public:
172     QQmlDebugObjectExpressionWatch(QObject *parent);
173
174     QString expression() const;
175
176 private:
177     friend class QQmlEngineDebug;
178     QString m_expr;
179     int m_debugId;
180 };
181
182
183 class Q_QML_PRIVATE_EXPORT QQmlDebugQuery : public QObject
184 {
185     Q_OBJECT
186 public:
187     enum State { Waiting, Error, Completed };
188
189     State state() const;
190     bool isWaiting() const;
191
192 Q_SIGNALS:
193     void stateChanged(QQmlDebugQuery::State);
194
195 protected:
196     QQmlDebugQuery(QObject *);
197
198 private:
199     friend class QQmlEngineDebug;
200     friend class QQmlEngineDebugPrivate;
201     void setState(State);
202     State m_state;
203 };
204
205 class Q_QML_PRIVATE_EXPORT QQmlDebugFileReference 
206 {
207 public:
208     QQmlDebugFileReference();
209     QQmlDebugFileReference(const QQmlDebugFileReference &);
210     QQmlDebugFileReference &operator=(const QQmlDebugFileReference &);
211
212     QUrl url() const;
213     void setUrl(const QUrl &);
214     int lineNumber() const;
215     void setLineNumber(int);
216     int columnNumber() const;
217     void setColumnNumber(int);
218
219 private:
220     friend class QQmlEngineDebugPrivate;
221     QUrl m_url;
222     int m_lineNumber;
223     int m_columnNumber;
224 };
225
226 class Q_QML_PRIVATE_EXPORT QQmlDebugEngineReference
227 {
228 public:
229     QQmlDebugEngineReference();
230     QQmlDebugEngineReference(int);
231     QQmlDebugEngineReference(const QQmlDebugEngineReference &);
232     QQmlDebugEngineReference &operator=(const QQmlDebugEngineReference &);
233
234     int debugId() const;
235     QString name() const;
236
237 private:
238     friend class QQmlEngineDebugPrivate;
239     int m_debugId;
240     QString m_name;
241 };
242
243 class Q_QML_PRIVATE_EXPORT QQmlDebugObjectReference
244 {
245 public:
246     QQmlDebugObjectReference();
247     QQmlDebugObjectReference(int);
248     QQmlDebugObjectReference(const QQmlDebugObjectReference &);
249     QQmlDebugObjectReference &operator=(const QQmlDebugObjectReference &);
250
251     int debugId() const;
252     QString className() const;
253     QString idString() const;
254     QString name() const;
255
256     QQmlDebugFileReference source() const;
257     int contextDebugId() const;
258
259     QList<QQmlDebugPropertyReference> properties() const;
260     QList<QQmlDebugObjectReference> children() const;
261
262 private:
263     friend class QQmlEngineDebugPrivate;
264     int m_debugId;
265     QString m_class;
266     QString m_idString;
267     QString m_name;
268     QQmlDebugFileReference m_source;
269     int m_contextDebugId;
270     QList<QQmlDebugPropertyReference> m_properties;
271     QList<QQmlDebugObjectReference> m_children;
272 };
273
274 class Q_QML_PRIVATE_EXPORT QQmlDebugContextReference
275 {
276 public:
277     QQmlDebugContextReference();
278     QQmlDebugContextReference(const QQmlDebugContextReference &);
279     QQmlDebugContextReference &operator=(const QQmlDebugContextReference &);
280
281     int debugId() const;
282     QString name() const;
283
284     QList<QQmlDebugObjectReference> objects() const;
285     QList<QQmlDebugContextReference> contexts() const;
286
287 private:
288     friend class QQmlEngineDebugPrivate;
289     int m_debugId;
290     QString m_name;
291     QList<QQmlDebugObjectReference> m_objects;
292     QList<QQmlDebugContextReference> m_contexts;
293 };
294
295 class Q_QML_PRIVATE_EXPORT QQmlDebugPropertyReference
296 {
297 public:
298     QQmlDebugPropertyReference();
299     QQmlDebugPropertyReference(const QQmlDebugPropertyReference &);
300     QQmlDebugPropertyReference &operator=(const QQmlDebugPropertyReference &);
301
302     int objectDebugId() const;
303     QString name() const;
304     QVariant value() const;
305     QString valueTypeName() const;
306     QString binding() const;
307     bool hasNotifySignal() const;
308
309 private:
310     friend class QQmlEngineDebugPrivate;
311     int m_objectDebugId;
312     QString m_name;
313     QVariant m_value;
314     QString m_valueTypeName;
315     QString m_binding;
316     bool m_hasNotifySignal;
317 };
318
319
320 class Q_QML_PRIVATE_EXPORT QQmlDebugEnginesQuery : public QQmlDebugQuery
321 {
322     Q_OBJECT
323 public:
324     virtual ~QQmlDebugEnginesQuery();
325     QList<QQmlDebugEngineReference> engines() const;
326 private:
327     friend class QQmlEngineDebug;
328     friend class QQmlEngineDebugPrivate;
329     QQmlDebugEnginesQuery(QObject *);
330     QQmlEngineDebug *m_client;
331     int m_queryId;
332     QList<QQmlDebugEngineReference> m_engines;
333 };
334
335 class Q_QML_PRIVATE_EXPORT QQmlDebugRootContextQuery : public QQmlDebugQuery
336 {
337     Q_OBJECT
338 public:
339     virtual ~QQmlDebugRootContextQuery();
340     QQmlDebugContextReference rootContext() const;
341 private:
342     friend class QQmlEngineDebug;
343     friend class QQmlEngineDebugPrivate;
344     QQmlDebugRootContextQuery(QObject *);
345     QQmlEngineDebug *m_client;
346     int m_queryId;
347     QQmlDebugContextReference m_context;
348 };
349
350 class Q_QML_PRIVATE_EXPORT QQmlDebugObjectQuery : public QQmlDebugQuery
351 {
352     Q_OBJECT
353 public:
354     virtual ~QQmlDebugObjectQuery();
355     QQmlDebugObjectReference object() const;
356 private:
357     friend class QQmlEngineDebug;
358     friend class QQmlEngineDebugPrivate;
359     QQmlDebugObjectQuery(QObject *);
360     QQmlEngineDebug *m_client;
361     int m_queryId;
362     QQmlDebugObjectReference m_object;
363
364 };
365
366 class Q_QML_PRIVATE_EXPORT QQmlDebugExpressionQuery : public QQmlDebugQuery
367 {
368     Q_OBJECT
369 public:
370     virtual ~QQmlDebugExpressionQuery();
371     QVariant expression() const;
372     QVariant result() const;
373 private:
374     friend class QQmlEngineDebug;
375     friend class QQmlEngineDebugPrivate;
376     QQmlDebugExpressionQuery(QObject *);
377     QQmlEngineDebug *m_client;
378     int m_queryId;
379     QVariant m_expr;
380     QVariant m_result;
381 };
382
383 Q_DECLARE_METATYPE(QQmlDebugEngineReference)
384 Q_DECLARE_METATYPE(QQmlDebugObjectReference)
385 Q_DECLARE_METATYPE(QQmlDebugContextReference)
386 Q_DECLARE_METATYPE(QQmlDebugPropertyReference)
387
388 #endif // QQMLENGINEDEBUG_H