2cc6bfb9e9999ba64bfaa3d402d72eaf213d4714
[profile/ivi/qtdeclarative.git] / src / declarative / debugger / qdeclarativeenginedebug_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** 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
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
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.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QDECLARATIVEENGINEDEBUG_H
43 #define QDECLARATIVEENGINEDEBUG_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/qdeclarativeglobal_p.h>
61
62 QT_BEGIN_HEADER
63
64 QT_BEGIN_NAMESPACE
65
66 QT_MODULE(Declarative)
67
68 class QDeclarativeDebugConnection;
69 class QDeclarativeDebugWatch;
70 class QDeclarativeDebugPropertyWatch;
71 class QDeclarativeDebugObjectExpressionWatch;
72 class QDeclarativeDebugEnginesQuery;
73 class QDeclarativeDebugRootContextQuery;
74 class QDeclarativeDebugObjectQuery;
75 class QDeclarativeDebugExpressionQuery;
76 class QDeclarativeDebugPropertyReference;
77 class QDeclarativeDebugContextReference;
78 class QDeclarativeDebugObjectReference;
79 class QDeclarativeDebugFileReference;
80 class QDeclarativeDebugEngineReference;
81 class QDeclarativeEngineDebugPrivate;
82 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeEngineDebug : public QObject
83 {
84     Q_OBJECT
85 public:
86     enum Status { NotConnected, Unavailable, Enabled };
87
88     explicit QDeclarativeEngineDebug(QDeclarativeDebugConnection *, QObject * = 0);
89
90     Status status() const;
91
92     QDeclarativeDebugPropertyWatch *addWatch(const QDeclarativeDebugPropertyReference &,
93                                              QObject *parent = 0);
94     QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugContextReference &, const QString &,
95                                      QObject *parent = 0);
96     QDeclarativeDebugObjectExpressionWatch *addWatch(const QDeclarativeDebugObjectReference &, const QString &,
97                                                      QObject *parent = 0);
98     QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugObjectReference &,
99                                      QObject *parent = 0);
100     QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugFileReference &,
101                                      QObject *parent = 0);
102
103     void removeWatch(QDeclarativeDebugWatch *watch);
104
105     QDeclarativeDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0);
106     QDeclarativeDebugRootContextQuery *queryRootContexts(const QDeclarativeDebugEngineReference &,
107                                                          QObject *parent = 0);
108     QDeclarativeDebugObjectQuery *queryObject(const QDeclarativeDebugObjectReference &,
109                                               QObject *parent = 0);
110     QDeclarativeDebugObjectQuery *queryObjectRecursive(const QDeclarativeDebugObjectReference &,
111                                                        QObject *parent = 0);
112     QDeclarativeDebugExpressionQuery *queryExpressionResult(int objectDebugId,
113                                                             const QString &expr,
114                                                             QObject *parent = 0);
115     bool setBindingForObject(int objectDebugId, const QString &propertyName,
116                              const QVariant &bindingExpression, bool isLiteralValue,
117                              QString source = QString(), int line = -1);
118     bool resetBindingForObject(int objectDebugId, const QString &propertyName);
119     bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody);
120
121 Q_SIGNALS:
122     void newObjects();
123     void statusChanged(Status status);
124
125 private:
126     Q_DECLARE_PRIVATE(QDeclarativeEngineDebug)
127 };
128
129 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugWatch : public QObject
130 {
131     Q_OBJECT
132 public:
133     enum State { Waiting, Active, Inactive, Dead };
134
135     QDeclarativeDebugWatch(QObject *);
136     ~QDeclarativeDebugWatch();
137
138     int queryId() const;
139     int objectDebugId() const;
140     State state() const;
141
142 Q_SIGNALS:
143     void stateChanged(QDeclarativeDebugWatch::State);
144     //void objectChanged(int, const QDeclarativeDebugObjectReference &);
145     //void valueChanged(int, const QVariant &);
146
147     // Server sends value as string if it is a user-type variant
148     void valueChanged(const QByteArray &name, const QVariant &value);
149
150 private:
151     friend class QDeclarativeEngineDebug;
152     friend class QDeclarativeEngineDebugPrivate;
153     void setState(State);
154     State m_state;
155     int m_queryId;
156     QDeclarativeEngineDebug *m_client;
157     int m_objectDebugId;
158 };
159
160 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugPropertyWatch : public QDeclarativeDebugWatch
161 {
162     Q_OBJECT
163 public:
164     QDeclarativeDebugPropertyWatch(QObject *parent);
165
166     QString name() const;
167
168 private:
169     friend class QDeclarativeEngineDebug;
170     QString m_name;
171 };
172
173 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectExpressionWatch : public QDeclarativeDebugWatch
174 {
175     Q_OBJECT
176 public:
177     QDeclarativeDebugObjectExpressionWatch(QObject *parent);
178
179     QString expression() const;
180
181 private:
182     friend class QDeclarativeEngineDebug;
183     QString m_expr;
184     int m_debugId;
185 };
186
187
188 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugQuery : public QObject
189 {
190     Q_OBJECT
191 public:
192     enum State { Waiting, Error, Completed };
193
194     State state() const;
195     bool isWaiting() const;
196
197     //    bool waitUntilCompleted();
198
199 Q_SIGNALS:
200     void stateChanged(QDeclarativeDebugQuery::State);
201
202 protected:
203     QDeclarativeDebugQuery(QObject *);
204
205 private:
206     friend class QDeclarativeEngineDebug;
207     friend class QDeclarativeEngineDebugPrivate;
208     void setState(State);
209     State m_state;
210 };
211
212 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugFileReference 
213 {
214 public:
215     QDeclarativeDebugFileReference();
216     QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &);
217     QDeclarativeDebugFileReference &operator=(const QDeclarativeDebugFileReference &);
218
219     QUrl url() const;
220     void setUrl(const QUrl &);
221     int lineNumber() const;
222     void setLineNumber(int);
223     int columnNumber() const;
224     void setColumnNumber(int);
225
226 private:
227     friend class QDeclarativeEngineDebugPrivate;
228     QUrl m_url;
229     int m_lineNumber;
230     int m_columnNumber;
231 };
232
233 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEngineReference
234 {
235 public:
236     QDeclarativeDebugEngineReference();
237     QDeclarativeDebugEngineReference(int);
238     QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &);
239     QDeclarativeDebugEngineReference &operator=(const QDeclarativeDebugEngineReference &);
240
241     int debugId() const;
242     QString name() const;
243
244 private:
245     friend class QDeclarativeEngineDebugPrivate;
246     int m_debugId;
247     QString m_name;
248 };
249
250 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectReference
251 {
252 public:
253     QDeclarativeDebugObjectReference();
254     QDeclarativeDebugObjectReference(int);
255     QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &);
256     QDeclarativeDebugObjectReference &operator=(const QDeclarativeDebugObjectReference &);
257
258     int debugId() const;
259     QString className() const;
260     QString idString() const;
261     QString name() const;
262
263     QDeclarativeDebugFileReference source() const;
264     int contextDebugId() const;
265
266     QList<QDeclarativeDebugPropertyReference> properties() const;
267     QList<QDeclarativeDebugObjectReference> children() const;
268
269 private:
270     friend class QDeclarativeEngineDebugPrivate;
271     int m_debugId;
272     QString m_class;
273     QString m_idString;
274     QString m_name;
275     QDeclarativeDebugFileReference m_source;
276     int m_contextDebugId;
277     QList<QDeclarativeDebugPropertyReference> m_properties;
278     QList<QDeclarativeDebugObjectReference> m_children;
279 };
280
281 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugContextReference
282 {
283 public:
284     QDeclarativeDebugContextReference();
285     QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &);
286     QDeclarativeDebugContextReference &operator=(const QDeclarativeDebugContextReference &);
287
288     int debugId() const;
289     QString name() const;
290
291     QList<QDeclarativeDebugObjectReference> objects() const;
292     QList<QDeclarativeDebugContextReference> contexts() const;
293
294 private:
295     friend class QDeclarativeEngineDebugPrivate;
296     int m_debugId;
297     QString m_name;
298     QList<QDeclarativeDebugObjectReference> m_objects;
299     QList<QDeclarativeDebugContextReference> m_contexts;
300 };
301
302 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugPropertyReference
303 {
304 public:
305     QDeclarativeDebugPropertyReference();
306     QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &);
307     QDeclarativeDebugPropertyReference &operator=(const QDeclarativeDebugPropertyReference &);
308
309     int objectDebugId() const;
310     QString name() const;
311     QVariant value() const;
312     QString valueTypeName() const;
313     QString binding() const;
314     bool hasNotifySignal() const;
315
316 private:
317     friend class QDeclarativeEngineDebugPrivate;
318     int m_objectDebugId;
319     QString m_name;
320     QVariant m_value;
321     QString m_valueTypeName;
322     QString m_binding;
323     bool m_hasNotifySignal;
324 };
325
326
327 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEnginesQuery : public QDeclarativeDebugQuery
328 {
329     Q_OBJECT
330 public:
331     virtual ~QDeclarativeDebugEnginesQuery();
332     QList<QDeclarativeDebugEngineReference> engines() const;
333 private:
334     friend class QDeclarativeEngineDebug;
335     friend class QDeclarativeEngineDebugPrivate;
336     QDeclarativeDebugEnginesQuery(QObject *);
337     QDeclarativeEngineDebug *m_client;
338     int m_queryId;
339     QList<QDeclarativeDebugEngineReference> m_engines;
340 };
341
342 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugRootContextQuery : public QDeclarativeDebugQuery
343 {
344     Q_OBJECT
345 public:
346     virtual ~QDeclarativeDebugRootContextQuery();
347     QDeclarativeDebugContextReference rootContext() const;
348 private:
349     friend class QDeclarativeEngineDebug;
350     friend class QDeclarativeEngineDebugPrivate;
351     QDeclarativeDebugRootContextQuery(QObject *);
352     QDeclarativeEngineDebug *m_client;
353     int m_queryId;
354     QDeclarativeDebugContextReference m_context;
355 };
356
357 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectQuery : public QDeclarativeDebugQuery
358 {
359     Q_OBJECT
360 public:
361     virtual ~QDeclarativeDebugObjectQuery();
362     QDeclarativeDebugObjectReference object() const;
363 private:
364     friend class QDeclarativeEngineDebug;
365     friend class QDeclarativeEngineDebugPrivate;
366     QDeclarativeDebugObjectQuery(QObject *);
367     QDeclarativeEngineDebug *m_client;
368     int m_queryId;
369     QDeclarativeDebugObjectReference m_object;
370
371 };
372
373 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugExpressionQuery : public QDeclarativeDebugQuery
374 {
375     Q_OBJECT
376 public:
377     virtual ~QDeclarativeDebugExpressionQuery();
378     QVariant expression() const;
379     QVariant result() const;
380 private:
381     friend class QDeclarativeEngineDebug;
382     friend class QDeclarativeEngineDebugPrivate;
383     QDeclarativeDebugExpressionQuery(QObject *);
384     QDeclarativeEngineDebug *m_client;
385     int m_queryId;
386     QVariant m_expr;
387     QVariant m_result;
388 };
389
390 QT_END_NAMESPACE
391
392 Q_DECLARE_METATYPE(QDeclarativeDebugEngineReference)
393 Q_DECLARE_METATYPE(QDeclarativeDebugObjectReference)
394 Q_DECLARE_METATYPE(QDeclarativeDebugContextReference)
395 Q_DECLARE_METATYPE(QDeclarativeDebugPropertyReference)
396
397 QT_END_HEADER
398
399 #endif // QDECLARATIVEENGINEDEBUG_H