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 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>
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 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
);
100 void statusChanged(Status status
);
103 Q_DECLARE_PRIVATE(QDeclarativeEngineDebug
)
104 QScopedPointer
<QDeclarativeEngineDebugPrivate
> d_ptr
;
107 class QDeclarativeDebugWatch
: public QObject
111 enum State
{ Waiting
, Active
, Inactive
, Dead
};
113 QDeclarativeDebugWatch(QObject
*);
114 ~QDeclarativeDebugWatch();
117 int objectDebugId() const;
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
);
129 friend class QDeclarativeEngineDebug
;
130 friend class QDeclarativeEngineDebugPrivate
;
131 void setState(State
);
134 QDeclarativeEngineDebug
*m_client
;
138 class QDeclarativeDebugPropertyWatch
: public QDeclarativeDebugWatch
142 QDeclarativeDebugPropertyWatch(QObject
*parent
);
144 QString
name() const;
147 friend class QDeclarativeEngineDebug
;
151 class QDeclarativeDebugObjectExpressionWatch
: public QDeclarativeDebugWatch
155 QDeclarativeDebugObjectExpressionWatch(QObject
*parent
);
157 QString
expression() const;
160 friend class QDeclarativeEngineDebug
;
165 class QDeclarativeDebugQuery
: public QObject
169 enum State
{ Waiting
, Error
, Completed
};
172 bool isWaiting() const;
174 // bool waitUntilCompleted();
177 void stateChanged(QDeclarativeDebugQuery::State
);
180 QDeclarativeDebugQuery(QObject
*);
183 friend class QDeclarativeEngineDebug
;
184 friend class QDeclarativeEngineDebugPrivate
;
185 void setState(State
);
189 class QDeclarativeDebugFileReference
192 QDeclarativeDebugFileReference();
193 QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference
&);
194 QDeclarativeDebugFileReference
&operator=(const QDeclarativeDebugFileReference
&);
197 void setUrl(const QUrl
&);
198 int lineNumber() const;
199 void setLineNumber(int);
200 int columnNumber() const;
201 void setColumnNumber(int);
204 friend class QDeclarativeEngineDebugPrivate
;
210 class QDeclarativeDebugEngineReference
213 QDeclarativeDebugEngineReference();
214 QDeclarativeDebugEngineReference(int);
215 QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference
&);
216 QDeclarativeDebugEngineReference
&operator=(const QDeclarativeDebugEngineReference
&);
219 QString
name() const;
222 friend class QDeclarativeEngineDebugPrivate
;
227 class QDeclarativeDebugObjectReference
230 QDeclarativeDebugObjectReference();
231 QDeclarativeDebugObjectReference(int);
232 QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference
&);
233 QDeclarativeDebugObjectReference
&operator=(const QDeclarativeDebugObjectReference
&);
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;
247 friend class QDeclarativeEngineDebugPrivate
;
252 QDeclarativeDebugFileReference m_source
;
253 int m_contextDebugId
;
254 QList
<QDeclarativeDebugPropertyReference
> m_properties
;
255 QList
<QDeclarativeDebugObjectReference
> m_children
;
258 class QDeclarativeDebugContextReference
261 QDeclarativeDebugContextReference();
262 QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference
&);
263 QDeclarativeDebugContextReference
&operator=(const QDeclarativeDebugContextReference
&);
266 QString
name() const;
268 QList
<QDeclarativeDebugObjectReference
> objects() const;
269 QList
<QDeclarativeDebugContextReference
> contexts() const;
272 friend class QDeclarativeEngineDebugPrivate
;
275 QList
<QDeclarativeDebugObjectReference
> m_objects
;
276 QList
<QDeclarativeDebugContextReference
> m_contexts
;
279 class QDeclarativeDebugPropertyReference
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;
294 friend class QDeclarativeEngineDebugPrivate
;
298 QString m_valueTypeName
;
300 bool m_hasNotifySignal
;
304 class QDeclarativeDebugEnginesQuery
: public QDeclarativeDebugQuery
308 virtual ~QDeclarativeDebugEnginesQuery();
309 QList
<QDeclarativeDebugEngineReference
> engines() const;
311 friend class QDeclarativeEngineDebug
;
312 friend class QDeclarativeEngineDebugPrivate
;
313 QDeclarativeDebugEnginesQuery(QObject
*);
314 QDeclarativeEngineDebug
*m_client
;
316 QList
<QDeclarativeDebugEngineReference
> m_engines
;
319 class QDeclarativeDebugRootContextQuery
: public QDeclarativeDebugQuery
323 virtual ~QDeclarativeDebugRootContextQuery();
324 QDeclarativeDebugContextReference
rootContext() const;
326 friend class QDeclarativeEngineDebug
;
327 friend class QDeclarativeEngineDebugPrivate
;
328 QDeclarativeDebugRootContextQuery(QObject
*);
329 QDeclarativeEngineDebug
*m_client
;
331 QDeclarativeDebugContextReference m_context
;
334 class QDeclarativeDebugObjectQuery
: public QDeclarativeDebugQuery
338 virtual ~QDeclarativeDebugObjectQuery();
339 QDeclarativeDebugObjectReference
object() const;
341 friend class QDeclarativeEngineDebug
;
342 friend class QDeclarativeEngineDebugPrivate
;
343 QDeclarativeDebugObjectQuery(QObject
*);
344 QDeclarativeEngineDebug
*m_client
;
346 QDeclarativeDebugObjectReference m_object
;
350 class QDeclarativeDebugExpressionQuery
: public QDeclarativeDebugQuery
354 virtual ~QDeclarativeDebugExpressionQuery();
355 QVariant
expression() const;
356 QVariant
result() const;
358 friend class QDeclarativeEngineDebug
;
359 friend class QDeclarativeEngineDebugPrivate
;
360 QDeclarativeDebugExpressionQuery(QObject
*);
361 QDeclarativeEngineDebug
*m_client
;
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