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 **************************************************************************/
33 #ifndef DESIGNMODEWIDGET_H
34 #define DESIGNMODEWIDGET_H
36 #include <coreplugin/minisplitter.h>
37 #include <coreplugin/editormanager/ieditor.h>
38 #include <utils/faketooltip.h>
39 #include <texteditor/itexteditor.h>
41 #include <integrationcore.h>
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>
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>
70 class OpenEditorsModel;
72 class OutputPanePlaceHolder;
75 namespace QmlDesigner {
77 class ItemLibraryWidget;
83 class DesignModeWidget;
85 class DocumentWarningWidget : public Utils::FakeToolTip
88 Q_DISABLE_COPY(DocumentWarningWidget)
90 explicit DocumentWarningWidget(DesignModeWidget *parent = 0);
92 void setError(const RewriterView::Error &error);
98 QLabel *m_errorMessage;
100 RewriterView::Error m_error;
101 DesignModeWidget *m_designModeWidget;
104 class DesignModeWidget : public QWidget
107 Q_DISABLE_COPY(DesignModeWidget)
109 explicit DesignModeWidget(QWidget *parent = 0);
112 void showEditor(Core::IEditor *editor);
113 void closeEditors(const QList<Core::IEditor*> editors);
114 QString contextHelpId() const;
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;
130 void setAutoSynchronization(bool sync);
132 TextEditor::ITextEditor *textEditor() const {return m_textEditor; }
137 void deleteSelected();
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);
151 void disable(const QList<RewriterView::Error> &errors);
152 void updateErrorStatus(const QList<RewriterView::Error> &errors);
153 void updateAvailableSidebarItemsLeft();
154 void updateAvailableSidebarItemsRight();
156 void deleteSidebarWidgets();
159 void resizeEvent(QResizeEvent *event);
162 DesignDocumentController *currentDesignDocumentController() const {return m_currentDesignDocumentController.data(); }
163 void setCurrentDocument(DesignDocumentController *newDesignDocumentController);
165 //QStackedWidget *m_documentWidgetStack;
166 QHash<QPlainTextEdit*,QWeakPointer<DesignDocumentController> > m_documentHash;
167 QWeakPointer<DesignDocumentController> m_currentDesignDocumentController;
168 QWeakPointer<QPlainTextEdit> m_currentTextEdit;
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;
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;
189 bool m_syncWithTextEdit;
192 bool isInNodeDefinition(int nodeOffset, int nodeLength, int cursorPos) const;
193 QmlDesigner::ModelNode nodeForPosition(int cursorPos) const;
195 TextEditor::ITextEditor *m_textEditor;
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;
207 enum InitializeStatus { NotInitialized, Initializing, Initialized };
208 InitializeStatus m_initStatus;
210 DocumentWarningWidget *m_warningWidget;
213 } // namespace Internal
214 } // namespace Designer
216 #endif // DESIGNMODEWIDGET_H