OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qmldesigner / designmodewidget.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 **
10 ** GNU Lesser General Public License Usage
11 **
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.
18 **
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.
22 **
23 ** Other Usage
24 **
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.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef DESIGNMODEWIDGET_H
34 #define DESIGNMODEWIDGET_H
35
36 #include <coreplugin/minisplitter.h>
37 #include <coreplugin/editormanager/ieditor.h>
38 #include <utils/faketooltip.h>
39 #include <texteditor/itexteditor.h>
40
41 #include <integrationcore.h>
42
43 #include <allpropertiesbox.h>
44 #include <designdocumentcontroller.h>
45 #include <itemlibraryview.h>
46 #include <navigatorwidget.h>
47 #include <navigatorview.h>
48 #include <stateseditorview.h>
49 #include <modelnode.h>
50 #include <formeditorview.h>
51
52 #include <QWeakPointer>
53 #include <QDeclarativeError>
54 #include <QtCore/QHash>
55 #include <QtGui/QWidget>
56 #include <QtGui/QToolBar>
57 #include <QtGui/QComboBox>
58 #include <QtGui/QLabel>
59
60 QT_BEGIN_NAMESPACE
61 class QStackedWidget;
62 class QTabWidget;
63 class QVBoxLayout;
64 class QToolButton;
65 QT_END_NAMESPACE
66
67 namespace Core {
68     class SideBar;
69     class SideBarItem;
70     class OpenEditorsModel;
71     class EditorToolBar;
72     class OutputPanePlaceHolder;
73 }
74
75 namespace QmlDesigner {
76
77 class ItemLibraryWidget;
78
79 namespace Internal {
80
81 class DesignMode;
82 class DocumentWidget;
83 class DesignModeWidget;
84
85 class DocumentWarningWidget : public  Utils::FakeToolTip
86 {
87     Q_OBJECT
88     Q_DISABLE_COPY(DocumentWarningWidget)
89 public:
90     explicit DocumentWarningWidget(DesignModeWidget *parent = 0);
91
92     void setError(const RewriterView::Error &error);
93
94 private slots:
95     void goToError();
96
97 private:
98     QLabel *m_errorMessage;
99     QLabel *m_goToError;
100     RewriterView::Error m_error;
101     DesignModeWidget *m_designModeWidget;
102 };
103
104 class DesignModeWidget : public QWidget
105 {
106     Q_OBJECT
107     Q_DISABLE_COPY(DesignModeWidget)
108 public:
109     explicit DesignModeWidget(QWidget *parent = 0);
110     ~DesignModeWidget();
111
112     void showEditor(Core::IEditor *editor);
113     void closeEditors(const QList<Core::IEditor*> editors);
114     QString contextHelpId() const;
115
116     QAction *undoAction() const;
117     QAction *redoAction() const;
118     QAction *deleteAction() const;
119     QAction *cutAction() const;
120     QAction *copyAction() const;
121     QAction *pasteAction() const;
122     QAction *selectAllAction() const;
123     QAction *hideSidebarsAction() const;
124     QAction *toggleLeftSidebarAction() const;
125     QAction *toggleRightSidebarAction() const;
126     QAction *restoreDefaultViewAction() const;
127
128     void readSettings();
129     void saveSettings();
130     void setAutoSynchronization(bool sync);
131
132     TextEditor::ITextEditor *textEditor() const {return m_textEditor; }
133
134 private slots:
135     void undo();
136     void redo();
137     void deleteSelected();
138     void cutSelected();
139     void copySelected();
140     void paste();
141     void selectAll();
142     void closeCurrentEditor();
143     void toggleSidebars();
144     void toggleLeftSidebar();
145     void toggleRightSidebar();
146     void restoreDefaultView();
147     void undoAvailable(bool isAvailable);
148     void redoAvailable(bool isAvailable);
149
150     void enable();
151     void disable(const QList<RewriterView::Error> &errors);
152     void updateErrorStatus(const QList<RewriterView::Error> &errors);
153     void updateAvailableSidebarItemsLeft();
154     void updateAvailableSidebarItemsRight();
155
156     void deleteSidebarWidgets();
157
158 protected:
159     void resizeEvent(QResizeEvent *event);
160
161 private:
162     DesignDocumentController *currentDesignDocumentController() const {return m_currentDesignDocumentController.data(); }
163     void setCurrentDocument(DesignDocumentController *newDesignDocumentController);
164
165     //QStackedWidget *m_documentWidgetStack;
166     QHash<QPlainTextEdit*,QWeakPointer<DesignDocumentController> > m_documentHash;
167     QWeakPointer<DesignDocumentController> m_currentDesignDocumentController;
168     QWeakPointer<QPlainTextEdit> m_currentTextEdit;
169
170     QAction *m_undoAction;
171     QAction *m_redoAction;
172     QAction *m_deleteAction;
173     QAction *m_cutAction;
174     QAction *m_copyAction;
175     QAction *m_pasteAction;
176     QAction *m_selectAllAction;
177     QAction *m_hideSidebarsAction;
178     QAction *m_restoreDefaultViewAction;
179     QAction *m_toggleLeftSidebarAction;
180     QAction *m_toggleRightSidebarAction;
181
182     QWeakPointer<ItemLibraryView> m_itemLibraryView;
183     QWeakPointer<NavigatorView> m_navigator;
184     QWeakPointer<AllPropertiesBox> m_allPropertiesBox;
185     QWeakPointer<StatesEditorView> m_statesEditorView;
186     QWeakPointer<FormEditorView> m_formEditorView;
187     QWeakPointer<NodeInstanceView> m_nodeInstanceView;
188
189     bool m_syncWithTextEdit;
190
191     void setup();
192     bool isInNodeDefinition(int nodeOffset, int nodeLength, int cursorPos) const;
193     QmlDesigner::ModelNode nodeForPosition(int cursorPos) const;
194
195     TextEditor::ITextEditor *m_textEditor;
196
197     QSplitter *m_mainSplitter;
198     Core::SideBar *m_leftSideBar;
199     Core::SideBar *m_rightSideBar;
200     Core::EditorToolBar *m_fakeToolBar;
201     Core::OutputPanePlaceHolder *m_outputPanePlaceholder;
202     Core::MiniSplitter *m_outputPlaceholderSplitter;
203     QList<Core::SideBarItem*> m_sideBarItems;
204     bool m_isDisabled;
205     bool m_showSidebars;
206
207     enum InitializeStatus { NotInitialized, Initializing, Initialized };
208     InitializeStatus m_initStatus;
209
210     DocumentWarningWidget *m_warningWidget;
211 };
212
213 } // namespace Internal
214 } // namespace Designer
215
216 #endif // DESIGNMODEWIDGET_H