OSDN Git Service

b752ddb37fa86f0ab5803ddf6896614496cb7a6d
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qmljsinspector / qmljsinspector.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 (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
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
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
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.
24 **
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.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef QMLJSINSPECTOR_H
35 #define QMLJSINSPECTOR_H
36
37 #include "qmljsprivateapi.h"
38
39 #include <qmlprojectmanager/qmlprojectrunconfiguration.h>
40 #include <utils/fileinprojectfinder.h>
41
42 #include <qmljs/qmljsdocument.h>
43 #include <qmljs/parser/qmljsastfwd_p.h>
44
45 #include <QtGui/QAction>
46 #include <QtCore/QObject>
47
48 QT_FORWARD_DECLARE_CLASS(QLineEdit)
49
50 namespace ProjectExplorer {
51 class Project;
52 class Environment;
53 }
54
55 namespace TextEditor {
56 class ITextEditor;
57 }
58
59 namespace Core {
60 class IContext;
61 }
62
63 namespace QmlJS {
64 class ModelManagerInterface;
65 }
66
67 namespace QmlJSInspector {
68 namespace Internal {
69
70 class QmlInspectorToolBar;
71 class QmlJSPropertyInspector;
72 class ClientProxy;
73 class InspectorSettings;
74 class ContextCrumblePath;
75 class QmlJSLiveTextPreview;
76
77 class InspectorUi : public QObject
78 {
79     Q_OBJECT
80
81 public:
82     enum DebugMode {
83         StandaloneMode,
84         CppProjectWithQmlEngines,
85         QmlProjectWithCppPlugins
86     };
87
88     InspectorUi(QObject *parent = 0);
89     virtual ~InspectorUi();
90
91     void saveSettings() const;
92     void restoreSettings();
93
94     bool showExperimentalWarning();
95     void setShowExperimentalWarning(bool value);
96
97     static InspectorUi *instance();
98
99     QString findFileInProject(const QString &file) const;
100
101     void setupUi();
102     bool isConnected() const;
103     void connected(ClientProxy *clientProxy);
104     void disconnected();
105     void setDebuggerEngine(QObject *qmlEngine);
106     QObject *debuggerEngine() const;
107
108 signals:
109     void statusMessage(const QString &text);
110     void livePreviewActivated(bool isActivated);
111
112 public slots:
113     void reloadQmlViewer();
114     void serverReloaded();
115     void setApplyChangesToQmlObserver(bool applyChanges);
116
117 private slots:
118     void enable();
119     void disable();
120     void gotoObjectReferenceDefinition(const QDeclarativeDebugObjectReference &obj);
121     void selectItems(const QList<QDeclarativeDebugObjectReference> &objectReferences);
122     void selectItems(const QList<int> &objectIds);
123     void changeSelectedItems(const QList<QDeclarativeDebugObjectReference> &objects);
124     void changePropertyValue(int debugId,const QString &propertyName, const QString &valueExpression);
125     void objectTreeReady();
126
127     void updateEngineList();
128
129     void removePreviewForEditor(Core::IEditor *newEditor);
130     QmlJSLiveTextPreview *createPreviewForEditor(Core::IEditor *newEditor);
131
132     void disableLivePreview();
133     void crumblePathElementClicked(int);
134
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);
139
140 private:
141     bool addQuotesForData(const QVariant &value) const;
142     void resetViews();
143
144     void initializeDocuments();
145     void applyChangesToQmlObserverHelper(bool applyChanges);
146     void setupDockWidgets();
147     QString filenameForShadowBuildFile(const QString &filename) const;
148     void populateCrumblePath(const QDeclarativeDebugObjectReference &objRef);
149     bool isRoot(const QDeclarativeDebugObjectReference &obj) const;
150     QDeclarativeDebugObjectReference objectReferenceForLocation(const QString &fileName, int cursorPosition=-1) const;
151
152     void connectSignals();
153     void disconnectSignals();
154
155 private:
156     bool m_listeningToEditorManager;
157     QmlInspectorToolBar *m_toolBar;
158     ContextCrumblePath *m_crumblePath;
159     QLineEdit *m_filterExp;
160     QmlJSPropertyInspector *m_propertyInspector;
161
162     InspectorSettings *m_settings;
163     ClientProxy *m_clientProxy;
164     QObject *m_qmlEngine;
165     QDeclarativeDebugExpressionQuery *m_debugQuery;
166
167     // Qml/JS integration
168     QHash<QString, QmlJSLiveTextPreview *> m_textPreviews;
169     QmlJS::Snapshot m_loadedSnapshot; //the snapshot loaded by the viewer
170
171     // project is needed for matching filenames, esp. with shadow builds.
172     ProjectExplorer::Project *m_debugProject;
173
174     QStringList m_pendingPreviewDocumentNames;
175     Utils::FileInProjectFinder m_projectFinder;
176
177     static InspectorUi *m_instance;
178     bool m_selectionCallbackExpected;
179     bool m_cursorPositionChangedExternally;
180 };
181
182 } // Internal
183 } // QmlJSInspector
184
185 #endif // QMLJSINSPECTOR_H