OSDN Git Service

It's 2011 now.
[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 <debugger/debuggerconstants.h>
40 #include <qmlprojectmanager/qmlprojectrunconfiguration.h>
41 #include <utils/fileinprojectfinder.h>
42
43 #include <qmljs/qmljsdocument.h>
44 #include <qmljs/parser/qmljsastfwd_p.h>
45
46 #include <QtGui/QAction>
47 #include <QtCore/QObject>
48
49 namespace ProjectExplorer {
50     class Project;
51     class Environment;
52 }
53
54 namespace TextEditor {
55     class ITextEditor;
56 }
57
58 namespace Core {
59     class IContext;
60 }
61
62 namespace QmlJS {
63     class ModelManagerInterface;
64 }
65
66 namespace QmlJSInspector {
67 namespace Internal {
68
69 class QmlInspectorToolbar;
70 class QmlJSObjectTree;
71 class ClientProxy;
72 class InspectorSettings;
73 class ContextCrumblePath;
74 class QmlJSLiveTextPreview;
75
76 class InspectorUi : public QObject
77 {
78     Q_OBJECT
79
80 public:
81     enum DebugMode {
82         StandaloneMode,
83         CppProjectWithQmlEngines,
84         QmlProjectWithCppPlugins
85     };
86 public:
87     InspectorUi(QObject *parent = 0);
88     virtual ~InspectorUi();
89
90     void saveSettings() const;
91     void restoreSettings();
92
93     bool showExperimentalWarning();
94     void setShowExperimentalWarning(bool value);
95
96     static InspectorUi *instance();
97
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;
102
103     void setupUi();
104     bool isConnected() const;
105     void connected(ClientProxy *clientProxy);
106     void disconnected();
107     void setDebuggerEngine(QObject *qmlEngine);
108     QObject *debuggerEngine() const;
109
110 signals:
111     void statusMessage(const QString &text);
112     void livePreviewActivated(bool isActivated);
113
114 public slots:
115     void reloadQmlViewer();
116     void serverReloaded();
117     void setApplyChangesToQmlObserver(bool applyChanges);
118
119 private slots:
120     void enable();
121     void disable();
122     void gotoObjectReferenceDefinition(const QDeclarativeDebugObjectReference &obj);
123     void gotoObjectReferenceDefinition(QList<QDeclarativeDebugObjectReference> objectReferences);
124     void changeSelectedItems(const QList<QDeclarativeDebugObjectReference> &objects);
125
126     void updateEngineList();
127
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 setupToolbar(bool doConnect);
147     void setupDockWidgets();
148     QString filenameForShadowBuildFile(const QString &filename) const;
149
150 private:
151     bool m_listeningToEditorManager;
152
153     QmlInspectorToolbar *m_toolbar;
154     ContextCrumblePath *m_crumblePath;
155     QmlJSObjectTree *m_objectTreeWidget;
156
157     InspectorSettings *m_settings;
158     ClientProxy *m_clientProxy;
159     QObject *m_qmlEngine;
160     QDeclarativeDebugExpressionQuery *m_debugQuery;
161     int m_lastSelectedDebugId;
162
163     // Qml/JS integration
164     QHash<QString, QmlJSLiveTextPreview *> m_textPreviews;
165     QmlJS::Snapshot m_loadedSnapshot; //the snapshot loaded by the viewer
166
167     // project is needed for matching filenames, esp. with shadow builds.
168     ProjectExplorer::Project *m_debugProject;
169     QString m_debugProjectBuildDir;
170
171     QStringList m_pendingPreviewDocumentNames;
172     Utils::FileInProjectFinder m_projectFinder;
173
174     static InspectorUi *m_instance;
175 };
176
177 } // Internal
178 } // QmlJSInspector
179
180 #endif // QMLJSINSPECTOR_H