Imported Upstream version 1.0.1
[gammaray-debian.git] / qmldebugcontrol / qmljsdebugclient / qdeclarativedebug.h
blobdcb5396c7cc190d112dc2a629f98a11b340f93f4
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
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.
22 ** Other Usage
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 info@qt.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>
39 QT_BEGIN_HEADER
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
60 Q_OBJECT
61 public:
62 enum Status { NotConnected, Unavailable, Enabled };
64 explicit QDeclarativeEngineDebug(QDeclarativeDebugConnection *, QObject * = 0);
65 ~QDeclarativeEngineDebug();
67 Status status() const;
69 QDeclarativeDebugPropertyWatch *addWatch(const QDeclarativeDebugPropertyReference &,
70 QObject *parent = 0);
71 QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugContextReference &, const QString &,
72 QObject *parent = 0);
73 QDeclarativeDebugObjectExpressionWatch *addWatch(const QDeclarativeDebugObjectReference &, const QString &,
74 QObject *parent = 0);
75 QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugObjectReference &,
76 QObject *parent = 0);
77 QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugFileReference &,
78 QObject *parent = 0);
80 void removeWatch(QDeclarativeDebugWatch *watch);
82 QDeclarativeDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0);
83 QDeclarativeDebugRootContextQuery *queryRootContexts(const QDeclarativeDebugEngineReference &,
84 QObject *parent = 0);
85 QDeclarativeDebugObjectQuery *queryObject(const QDeclarativeDebugObjectReference &,
86 QObject *parent = 0);
87 QDeclarativeDebugObjectQuery *queryObjectRecursive(const QDeclarativeDebugObjectReference &,
88 QObject *parent = 0);
89 QDeclarativeDebugExpressionQuery *queryExpressionResult(int objectDebugId,
90 const QString &expr,
91 QObject *parent = 0);
92 bool setBindingForObject(int objectDebugId, const QString &propertyName,
93 const QVariant &bindingExpression, bool isLiteralValue,
94 QString source = QString(), int line = -1);
95 bool resetBindingForObject(int objectDebugId, const QString &propertyName);
96 bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody);
98 Q_SIGNALS:
99 void newObjects();
100 void statusChanged(Status status);
102 private:
103 Q_DECLARE_PRIVATE(QDeclarativeEngineDebug)
104 QScopedPointer<QDeclarativeEngineDebugPrivate> d_ptr;
107 class QDeclarativeDebugWatch : public QObject
109 Q_OBJECT
110 public:
111 enum State { Waiting, Active, Inactive, Dead };
113 QDeclarativeDebugWatch(QObject *);
114 ~QDeclarativeDebugWatch();
116 int queryId() const;
117 int objectDebugId() const;
118 State state() const;
120 Q_SIGNALS:
121 void stateChanged(QDeclarativeDebugWatch::State);
122 //void objectChanged(int, const QDeclarativeDebugObjectReference &);
123 //void valueChanged(int, const QVariant &);
125 // Server sends value as string if it is a user-type variant
126 void valueChanged(const QByteArray &name, const QVariant &value);
128 private:
129 friend class QDeclarativeEngineDebug;
130 friend class QDeclarativeEngineDebugPrivate;
131 void setState(State);
132 State m_state;
133 int m_queryId;
134 QDeclarativeEngineDebug *m_client;
135 int m_objectDebugId;
138 class QDeclarativeDebugPropertyWatch : public QDeclarativeDebugWatch
140 Q_OBJECT
141 public:
142 QDeclarativeDebugPropertyWatch(QObject *parent);
144 QString name() const;
146 private:
147 friend class QDeclarativeEngineDebug;
148 QString m_name;
151 class QDeclarativeDebugObjectExpressionWatch : public QDeclarativeDebugWatch
153 Q_OBJECT
154 public:
155 QDeclarativeDebugObjectExpressionWatch(QObject *parent);
157 QString expression() const;
159 private:
160 friend class QDeclarativeEngineDebug;
161 QString m_expr;
162 int m_debugId;
165 class QDeclarativeDebugQuery : public QObject
167 Q_OBJECT
168 public:
169 enum State { Waiting, Error, Completed };
171 State state() const;
172 bool isWaiting() const;
174 // bool waitUntilCompleted();
176 Q_SIGNALS:
177 void stateChanged(QDeclarativeDebugQuery::State);
179 protected:
180 QDeclarativeDebugQuery(QObject *);
182 private:
183 friend class QDeclarativeEngineDebug;
184 friend class QDeclarativeEngineDebugPrivate;
185 void setState(State);
186 State m_state;
189 class QDeclarativeDebugFileReference
191 public:
192 QDeclarativeDebugFileReference();
193 QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &);
194 QDeclarativeDebugFileReference &operator=(const QDeclarativeDebugFileReference &);
196 QUrl url() const;
197 void setUrl(const QUrl &);
198 int lineNumber() const;
199 void setLineNumber(int);
200 int columnNumber() const;
201 void setColumnNumber(int);
203 private:
204 friend class QDeclarativeEngineDebugPrivate;
205 QUrl m_url;
206 int m_lineNumber;
207 int m_columnNumber;
210 class QDeclarativeDebugEngineReference
212 public:
213 QDeclarativeDebugEngineReference();
214 QDeclarativeDebugEngineReference(int);
215 QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &);
216 QDeclarativeDebugEngineReference &operator=(const QDeclarativeDebugEngineReference &);
218 int debugId() const;
219 QString name() const;
221 private:
222 friend class QDeclarativeEngineDebugPrivate;
223 int m_debugId;
224 QString m_name;
227 class QDeclarativeDebugObjectReference
229 public:
230 QDeclarativeDebugObjectReference();
231 QDeclarativeDebugObjectReference(int);
232 QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &);
233 QDeclarativeDebugObjectReference &operator=(const QDeclarativeDebugObjectReference &);
235 int debugId() const;
236 QString className() const;
237 QString idString() const;
238 QString name() const;
240 QDeclarativeDebugFileReference source() const;
241 int contextDebugId() const;
243 QList<QDeclarativeDebugPropertyReference> properties() const;
244 QList<QDeclarativeDebugObjectReference> children() const;
246 private:
247 friend class QDeclarativeEngineDebugPrivate;
248 int m_debugId;
249 QString m_class;
250 QString m_idString;
251 QString m_name;
252 QDeclarativeDebugFileReference m_source;
253 int m_contextDebugId;
254 QList<QDeclarativeDebugPropertyReference> m_properties;
255 QList<QDeclarativeDebugObjectReference> m_children;
258 class QDeclarativeDebugContextReference
260 public:
261 QDeclarativeDebugContextReference();
262 QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &);
263 QDeclarativeDebugContextReference &operator=(const QDeclarativeDebugContextReference &);
265 int debugId() const;
266 QString name() const;
268 QList<QDeclarativeDebugObjectReference> objects() const;
269 QList<QDeclarativeDebugContextReference> contexts() const;
271 private:
272 friend class QDeclarativeEngineDebugPrivate;
273 int m_debugId;
274 QString m_name;
275 QList<QDeclarativeDebugObjectReference> m_objects;
276 QList<QDeclarativeDebugContextReference> m_contexts;
279 class QDeclarativeDebugPropertyReference
281 public:
282 QDeclarativeDebugPropertyReference();
283 QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &);
284 QDeclarativeDebugPropertyReference &operator=(const QDeclarativeDebugPropertyReference &);
286 int objectDebugId() const;
287 QString name() const;
288 QVariant value() const;
289 QString valueTypeName() const;
290 QString binding() const;
291 bool hasNotifySignal() const;
293 private:
294 friend class QDeclarativeEngineDebugPrivate;
295 int m_objectDebugId;
296 QString m_name;
297 QVariant m_value;
298 QString m_valueTypeName;
299 QString m_binding;
300 bool m_hasNotifySignal;
304 class QDeclarativeDebugEnginesQuery : public QDeclarativeDebugQuery
306 Q_OBJECT
307 public:
308 virtual ~QDeclarativeDebugEnginesQuery();
309 QList<QDeclarativeDebugEngineReference> engines() const;
310 private:
311 friend class QDeclarativeEngineDebug;
312 friend class QDeclarativeEngineDebugPrivate;
313 QDeclarativeDebugEnginesQuery(QObject *);
314 QDeclarativeEngineDebug *m_client;
315 int m_queryId;
316 QList<QDeclarativeDebugEngineReference> m_engines;
319 class QDeclarativeDebugRootContextQuery : public QDeclarativeDebugQuery
321 Q_OBJECT
322 public:
323 virtual ~QDeclarativeDebugRootContextQuery();
324 QDeclarativeDebugContextReference rootContext() const;
325 private:
326 friend class QDeclarativeEngineDebug;
327 friend class QDeclarativeEngineDebugPrivate;
328 QDeclarativeDebugRootContextQuery(QObject *);
329 QDeclarativeEngineDebug *m_client;
330 int m_queryId;
331 QDeclarativeDebugContextReference m_context;
334 class QDeclarativeDebugObjectQuery : public QDeclarativeDebugQuery
336 Q_OBJECT
337 public:
338 virtual ~QDeclarativeDebugObjectQuery();
339 QDeclarativeDebugObjectReference object() const;
340 private:
341 friend class QDeclarativeEngineDebug;
342 friend class QDeclarativeEngineDebugPrivate;
343 QDeclarativeDebugObjectQuery(QObject *);
344 QDeclarativeEngineDebug *m_client;
345 int m_queryId;
346 QDeclarativeDebugObjectReference m_object;
350 class QDeclarativeDebugExpressionQuery : public QDeclarativeDebugQuery
352 Q_OBJECT
353 public:
354 virtual ~QDeclarativeDebugExpressionQuery();
355 QVariant expression() const;
356 QVariant result() const;
357 private:
358 friend class QDeclarativeEngineDebug;
359 friend class QDeclarativeEngineDebugPrivate;
360 QDeclarativeDebugExpressionQuery(QObject *);
361 QDeclarativeEngineDebug *m_client;
362 int m_queryId;
363 QVariant m_expr;
364 QVariant m_result;
369 Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugEngineReference)
370 Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugObjectReference)
371 Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugContextReference)
372 Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugPropertyReference)
375 #endif // QDECLARATIVEDEBUG_H