1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef QMLJSINSPECTOR_H
35 #define QMLJSINSPECTOR_H
37 #include "qmljsprivateapi.h"
39 #include <debugger/debuggerconstants.h>
40 #include <qmlprojectmanager/qmlprojectrunconfiguration.h>
41 #include <utils/fileinprojectfinder.h>
43 #include <qmljs/qmljsdocument.h>
44 #include <qmljs/parser/qmljsastfwd_p.h>
46 #include <QtGui/QAction>
47 #include <QtCore/QObject>
49 namespace ProjectExplorer {
54 namespace TextEditor {
63 class ModelManagerInterface;
66 namespace QmlJSInspector {
69 class QmlInspectorToolbar;
70 class QmlJSObjectTree;
72 class InspectorSettings;
73 class ContextCrumblePath;
74 class QmlJSLiveTextPreview;
76 class InspectorUi : public QObject
83 CppProjectWithQmlEngines,
84 QmlProjectWithCppPlugins
87 InspectorUi(QObject *parent = 0);
88 virtual ~InspectorUi();
90 void saveSettings() const;
91 void restoreSettings();
93 bool showExperimentalWarning();
94 void setShowExperimentalWarning(bool value);
96 static InspectorUi *instance();
98 // returns the project being currently debugged, or 0 if not debugging anything
99 ProjectExplorer::Project *debugProject() const;
100 QString debugProjectBuildDirectory() const;
101 bool isShadowBuildProject() const;
104 bool isConnected() const;
105 void connected(ClientProxy *clientProxy);
107 void setDebuggerEngine(QObject *qmlEngine);
108 QObject *debuggerEngine() const;
111 void statusMessage(const QString &text);
112 void livePreviewActivated(bool isActivated);
115 void reloadQmlViewer();
116 void serverReloaded();
117 void setApplyChangesToQmlObserver(bool applyChanges);
122 void gotoObjectReferenceDefinition(const QDeclarativeDebugObjectReference &obj);
123 void gotoObjectReferenceDefinition(QList<QDeclarativeDebugObjectReference> objectReferences);
124 void changeSelectedItems(const QList<QDeclarativeDebugObjectReference> &objects);
126 void updateEngineList();
129 void removePreviewForEditor(Core::IEditor *newEditor);
130 QmlJSLiveTextPreview *createPreviewForEditor(Core::IEditor *newEditor);
132 void disableLivePreview();
133 void crumblePathElementClicked(int);
135 void currentDebugProjectRemoved();
136 void updatePendingPreviewDocuments(QmlJS::Document::Ptr doc);
137 void showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos);
138 void debugQueryUpdated(QDeclarativeDebugQuery::State);
141 bool addQuotesForData(const QVariant &value) const;
144 void initializeDocuments();
145 void applyChangesToQmlObserverHelper(bool applyChanges);
146 void setupToolbar(bool doConnect);
147 void setupDockWidgets();
148 QString filenameForShadowBuildFile(const QString &filename) const;
151 bool m_listeningToEditorManager;
153 QmlInspectorToolbar *m_toolbar;
154 ContextCrumblePath *m_crumblePath;
155 QmlJSObjectTree *m_objectTreeWidget;
157 InspectorSettings *m_settings;
158 ClientProxy *m_clientProxy;
159 QObject *m_qmlEngine;
160 QDeclarativeDebugExpressionQuery *m_debugQuery;
161 int m_lastSelectedDebugId;
163 // Qml/JS integration
164 QHash<QString, QmlJSLiveTextPreview *> m_textPreviews;
165 QmlJS::Snapshot m_loadedSnapshot; //the snapshot loaded by the viewer
167 // project is needed for matching filenames, esp. with shadow builds.
168 ProjectExplorer::Project *m_debugProject;
169 QString m_debugProjectBuildDir;
171 QStringList m_pendingPreviewDocumentNames;
172 Utils::FileInProjectFinder m_projectFinder;
174 static InspectorUi *m_instance;
180 #endif // QMLJSINSPECTOR_H