OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / libs / qmljsdebugclient / qdeclarativedebug_p.h
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
10 **
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.
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 ** Other Usage
23 **
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.
26 **
27 ** If you have questions regarding the use of this file, please contact
28 ** Nokia at qt-info@nokia.com.
29 **
30 **************************************************************************/
31
32 #ifndef QDECLARATIVEDEBUG_H
33 #define QDECLARATIVEDEBUG_H
34
35 #include <QtCore/qobject.h>
36 #include <QtCore/qurl.h>
37 #include <QtCore/qvariant.h>
38
39 QT_BEGIN_HEADER
40
41 namespace QmlJsDebugClient {
42
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;
57
58 class QDeclarativeEngineDebug : public QObject
59 {
60 Q_OBJECT
61 public:
62     enum Status { NotConnected, Unavailable, Enabled };
63
64     explicit QDeclarativeEngineDebug(QDeclarativeDebugConnection *, QObject * = 0);
65     ~QDeclarativeEngineDebug();
66
67     Status status() const;
68
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);
79
80     void removeWatch(QDeclarativeDebugWatch *watch);
81
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     bool resetBindingForObject(int objectDebugId, const QString &propertyName);
95     bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody);
96
97 Q_SIGNALS:
98     void newObjects();
99     void statusChanged(Status status);
100
101 private:
102     Q_DECLARE_PRIVATE(QDeclarativeEngineDebug)
103     QScopedPointer<QDeclarativeEngineDebugPrivate> d_ptr;
104 };
105
106 class QDeclarativeDebugWatch : public QObject
107 {
108 Q_OBJECT
109 public:
110     enum State { Waiting, Active, Inactive, Dead };
111
112     QDeclarativeDebugWatch(QObject *);
113     ~QDeclarativeDebugWatch();
114
115     int queryId() const;
116     int objectDebugId() const;
117     State state() const;
118
119 Q_SIGNALS:
120     void stateChanged(QDeclarativeDebugWatch::State);
121     //void objectChanged(int, const QDeclarativeDebugObjectReference &);
122     //void valueChanged(int, const QVariant &);
123
124     // Server sends value as string if it is a user-type variant
125     void valueChanged(const QByteArray &name, const QVariant &value);
126
127 private:
128     friend class QDeclarativeEngineDebug;
129     friend class QDeclarativeEngineDebugPrivate;
130     void setState(State);
131     State m_state;
132     int m_queryId;
133     QDeclarativeEngineDebug *m_client;
134     int m_objectDebugId;
135 };
136
137 class QDeclarativeDebugPropertyWatch : public QDeclarativeDebugWatch
138 {
139     Q_OBJECT
140 public:
141     QDeclarativeDebugPropertyWatch(QObject *parent);
142
143     QString name() const;
144
145 private:
146     friend class QDeclarativeEngineDebug;
147     QString m_name;
148 };
149
150 class QDeclarativeDebugObjectExpressionWatch : public QDeclarativeDebugWatch
151 {
152     Q_OBJECT
153 public:
154     QDeclarativeDebugObjectExpressionWatch(QObject *parent);
155
156     QString expression() const;
157
158 private:
159     friend class QDeclarativeEngineDebug;
160     QString m_expr;
161     int m_debugId;
162 };
163
164 class QDeclarativeDebugQuery : public QObject
165 {
166 Q_OBJECT
167 public:
168     enum State { Waiting, Error, Completed };
169
170     State state() const;
171     bool isWaiting() const;
172
173 //    bool waitUntilCompleted();
174
175 Q_SIGNALS:
176     void stateChanged(QDeclarativeDebugQuery::State);
177
178 protected:
179     QDeclarativeDebugQuery(QObject *);
180
181 private:
182     friend class QDeclarativeEngineDebug;
183     friend class QDeclarativeEngineDebugPrivate;
184     void setState(State);
185     State m_state;
186 };
187
188 class QDeclarativeDebugFileReference
189 {
190 public:
191     QDeclarativeDebugFileReference();
192     QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &);
193     QDeclarativeDebugFileReference &operator=(const QDeclarativeDebugFileReference &);
194
195     QUrl url() const;
196     void setUrl(const QUrl &);
197     int lineNumber() const;
198     void setLineNumber(int);
199     int columnNumber() const;
200     void setColumnNumber(int);
201
202 private:
203     friend class QDeclarativeEngineDebugPrivate;
204     QUrl m_url;
205     int m_lineNumber;
206     int m_columnNumber;
207 };
208
209 class QDeclarativeDebugEngineReference
210 {
211 public:
212     QDeclarativeDebugEngineReference();
213     QDeclarativeDebugEngineReference(int);
214     QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &);
215     QDeclarativeDebugEngineReference &operator=(const QDeclarativeDebugEngineReference &);
216
217     int debugId() const;
218     QString name() const;
219
220 private:
221     friend class QDeclarativeEngineDebugPrivate;
222     int m_debugId;
223     QString m_name;
224 };
225
226 class QDeclarativeDebugObjectReference
227 {
228 public:
229     QDeclarativeDebugObjectReference();
230     QDeclarativeDebugObjectReference(int);
231     QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &);
232     QDeclarativeDebugObjectReference &operator=(const QDeclarativeDebugObjectReference &);
233
234     int debugId() const;
235     QString className() const;
236     QString idString() const;
237     QString name() const;
238
239     QDeclarativeDebugFileReference source() const;
240     int contextDebugId() const;
241
242     QList<QDeclarativeDebugPropertyReference> properties() const;
243     QList<QDeclarativeDebugObjectReference> children() const;
244
245 private:
246     friend class QDeclarativeEngineDebugPrivate;
247     int m_debugId;
248     QString m_class;
249     QString m_idString;
250     QString m_name;
251     QDeclarativeDebugFileReference m_source;
252     int m_contextDebugId;
253     QList<QDeclarativeDebugPropertyReference> m_properties;
254     QList<QDeclarativeDebugObjectReference> m_children;
255 };
256
257 class QDeclarativeDebugContextReference
258 {
259 public:
260     QDeclarativeDebugContextReference();
261     QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &);
262     QDeclarativeDebugContextReference &operator=(const QDeclarativeDebugContextReference &);
263
264     int debugId() const;
265     QString name() const;
266
267     QList<QDeclarativeDebugObjectReference> objects() const;
268     QList<QDeclarativeDebugContextReference> contexts() const;
269
270 private:
271     friend class QDeclarativeEngineDebugPrivate;
272     int m_debugId;
273     QString m_name;
274     QList<QDeclarativeDebugObjectReference> m_objects;
275     QList<QDeclarativeDebugContextReference> m_contexts;
276 };
277
278 class QDeclarativeDebugPropertyReference
279 {
280 public:
281     QDeclarativeDebugPropertyReference();
282     QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &);
283     QDeclarativeDebugPropertyReference &operator=(const QDeclarativeDebugPropertyReference &);
284
285     int objectDebugId() const;
286     QString name() const;
287     QVariant value() const;
288     QString valueTypeName() const;
289     QString binding() const;
290     bool hasNotifySignal() const;
291
292 private:
293     friend class QDeclarativeEngineDebugPrivate;
294     int m_objectDebugId;
295     QString m_name;
296     QVariant m_value;
297     QString m_valueTypeName;
298     QString m_binding;
299     bool m_hasNotifySignal;
300 };
301
302
303 class QDeclarativeDebugEnginesQuery : public QDeclarativeDebugQuery
304 {
305 Q_OBJECT
306 public:
307     virtual ~QDeclarativeDebugEnginesQuery();
308     QList<QDeclarativeDebugEngineReference> engines() const;
309 private:
310     friend class QDeclarativeEngineDebug;
311     friend class QDeclarativeEngineDebugPrivate;
312     QDeclarativeDebugEnginesQuery(QObject *);
313     QDeclarativeEngineDebug *m_client;
314     int m_queryId;
315     QList<QDeclarativeDebugEngineReference> m_engines;
316 };
317
318 class QDeclarativeDebugRootContextQuery : public QDeclarativeDebugQuery
319 {
320 Q_OBJECT
321 public:
322     virtual ~QDeclarativeDebugRootContextQuery();
323     QDeclarativeDebugContextReference rootContext() const;
324 private:
325     friend class QDeclarativeEngineDebug;
326     friend class QDeclarativeEngineDebugPrivate;
327     QDeclarativeDebugRootContextQuery(QObject *);
328     QDeclarativeEngineDebug *m_client;
329     int m_queryId;
330     QDeclarativeDebugContextReference m_context;
331 };
332
333 class QDeclarativeDebugObjectQuery : public QDeclarativeDebugQuery
334 {
335 Q_OBJECT
336 public:
337     virtual ~QDeclarativeDebugObjectQuery();
338     QDeclarativeDebugObjectReference object() const;
339 private:
340     friend class QDeclarativeEngineDebug;
341     friend class QDeclarativeEngineDebugPrivate;
342     QDeclarativeDebugObjectQuery(QObject *);
343     QDeclarativeEngineDebug *m_client;
344     int m_queryId;
345     QDeclarativeDebugObjectReference m_object;
346
347 };
348
349 class QDeclarativeDebugExpressionQuery : public QDeclarativeDebugQuery
350 {
351 Q_OBJECT
352 public:
353     virtual ~QDeclarativeDebugExpressionQuery();
354     QVariant expression() const;
355     QVariant result() const;
356 private:
357     friend class QDeclarativeEngineDebug;
358     friend class QDeclarativeEngineDebugPrivate;
359     QDeclarativeDebugExpressionQuery(QObject *);
360     QDeclarativeEngineDebug *m_client;
361     int m_queryId;
362     QVariant m_expr;
363     QVariant m_result;
364 };
365
366 }
367
368 Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugEngineReference)
369 Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugObjectReference)
370 Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugContextReference)
371 Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugPropertyReference)
372
373
374 #endif // QDECLARATIVEDEBUG_H