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)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
32 #ifndef QMLJSCLIENTPROXY_H
33 #define QMLJSCLIENTPROXY_H
35 #include "qmljsinspectorplugin.h"
36 #include "qmljsprivateapi.h"
37 #include <QtCore/QObject>
39 QT_FORWARD_DECLARE_CLASS(QUrl)
45 namespace QmlJSInspector {
47 //map <filename, editorRevision> -> <lineNumber, columnNumber> -> debugIds
48 typedef QHash<QPair<QString, int>, QHash<QPair<int, int>, QList<int> > > DebugIdHash;
52 class InspectorPlugin;
53 class QmlJSObserverClient;
55 class ClientProxy : public QObject
60 explicit ClientProxy(Debugger::QmlAdapter *adapter, QObject *parent = 0);
62 bool setBindingForObject(int objectDebugId,
63 const QString &propertyName,
64 const QVariant &value,
67 bool setMethodBodyForObject(int objectDebugId, const QString &methodName, const QString &methodBody);
68 bool resetBindingForObject(int objectDebugId, const QString &propertyName);
69 QDeclarativeDebugExpressionQuery *queryExpressionResult(int objectDebugId, const QString &expr);
70 void clearComponentCache();
72 bool addObjectWatch(int objectDebugId);
73 bool removeObjectWatch(int objectDebugId);
74 void removeAllObjectWatches();
76 // returns the object references
77 QList<QDeclarativeDebugObjectReference> objectReferences() const;
78 QDeclarativeDebugObjectReference objectReferenceForId(int debugId) const;
79 QDeclarativeDebugObjectReference objectReferenceForId(const QString &objectId) const;
80 QDeclarativeDebugObjectReference objectReferenceForLocation(const int line, const int column) const;
81 QList<QDeclarativeDebugObjectReference> rootObjectReference() const;
82 DebugIdHash debugIdHash() const { return m_debugIdHash; }
84 bool isConnected() const;
86 void setSelectedItemsByObjectId(const QList<QDeclarativeDebugObjectReference> &objectRefs);
88 QList<QDeclarativeDebugEngineReference> engines() const;
90 Debugger::QmlAdapter *qmlAdapter() const;
93 void objectTreeUpdated();
94 void connectionStatusMessage(const QString &text);
96 void aboutToReloadEngines();
97 void enginesChanged();
99 void selectedItemsChanged(const QList<QDeclarativeDebugObjectReference> &selectedItems);
104 void colorPickerActivated();
105 void selectToolActivated();
106 void selectMarqueeToolActivated();
107 void zoomToolActivated();
108 void animationSpeedChanged(qreal slowDownFactor);
109 void animationPausedChanged(bool paused);
110 void designModeBehaviorChanged(bool inDesignMode);
111 void showAppOnTopChanged(bool showAppOnTop);
112 void serverReloaded();
113 void selectedColorChanged(const QColor &color);
114 void contextPathUpdated(const QStringList &contextPath);
115 void propertyChanged(int debugId, const QByteArray &propertyName, const QVariant &propertyValue);
118 void refreshObjectTree();
119 void queryEngineContext(int id);
120 void reloadQmlViewer();
122 void setDesignModeBehavior(bool inDesignMode);
123 void setAnimationSpeed(qreal slowDownFactor);
124 void setAnimationPaused(bool paused);
125 void changeToColorPickerTool();
126 void changeToZoomTool();
127 void changeToSelectTool();
128 void changeToSelectMarqueeTool();
129 void showAppOnTop(bool showOnTop);
130 void createQmlObject(const QString &qmlText, int parentDebugId,
131 const QStringList &imports, const QString &filename = QString());
132 void destroyQmlObject(int debugId);
133 void reparentQmlObject(int debugId, int newParent);
134 void setContextPathIndex(int contextIndex);
137 void connectToServer();
138 void clientStatusChanged(QDeclarativeDebugClient::Status status);
140 void contextChanged();
142 void onCurrentObjectsChanged(const QList<int> &debugIds, bool requestIfNeeded = true);
143 void updateEngineList();
144 void objectTreeFetched(QDeclarativeDebugQuery::State state = QDeclarativeDebugQuery::Completed);
145 void fetchContextObjectRecursive(const QmlJsDebugClient::QDeclarativeDebugContextReference& context);
147 void objectWatchTriggered(const QByteArray &propertyName, const QVariant &propertyValue);
150 void updateConnected();
151 void reloadEngines();
153 QList<QDeclarativeDebugObjectReference> objectReferences(const QDeclarativeDebugObjectReference &objectRef) const;
154 QDeclarativeDebugObjectReference objectReferenceForId(int debugId, const QDeclarativeDebugObjectReference &ref) const;
160 void log(LogDirection direction, const QString &message);
164 Q_DISABLE_COPY(ClientProxy)
165 void buildDebugIdHashRecursive(const QDeclarativeDebugObjectReference &ref);
167 Debugger::QmlAdapter *m_adapter;
168 QDeclarativeEngineDebug *m_engineClient;
169 QmlJSObserverClient *m_observerClient;
171 QDeclarativeDebugEnginesQuery *m_engineQuery;
172 QDeclarativeDebugRootContextQuery *m_contextQuery;
173 QList<QDeclarativeDebugObjectQuery *> m_objectTreeQuery;
175 QList<QDeclarativeDebugObjectReference> m_rootObjects;
176 QList<QDeclarativeDebugEngineReference> m_engines;
177 QTimer m_requestObjectsTimer;
178 DebugIdHash m_debugIdHash;
180 QHash<int, QDeclarativeDebugWatch *> m_objectWatches;
185 } // namespace Internal
186 } // namespace QmlJSInspector
188 #endif // QMLJSCLIENTPROXY_H