1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
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 ** If you are unsure which license is appropriate for your use, please
26 ** contact the sales department at http://qt.nokia.com/contact.
28 **************************************************************************/
30 #ifndef DESIGNMODEWIDGET_H
31 #define DESIGNMODEWIDGET_H
33 #include <coreplugin/minisplitter.h>
34 #include <coreplugin/editormanager/ieditor.h>
35 #include <texteditor/itexteditor.h>
37 #include <integrationcore.h>
39 #include <allpropertiesbox.h>
40 #include <designdocumentcontroller.h>
41 #include <itemlibrary.h>
42 #include <navigatorwidget.h>
43 #include <stateseditorwidget.h>
44 #include <modelnode.h>
47 #include <QWeakPointer>
48 #include <QDeclarativeError>
49 #include <QtCore/QHash>
50 #include <QtGui/QWidget>
51 #include <QtGui/QToolBar>
52 #include <QtGui/QComboBox>
53 #include <QtGui/QLabel>
64 class OpenEditorsModel;
65 class DesignModeToolBar;
68 namespace QmlDesigner {
74 class DesignModeWidget;
76 class DocumentWarningWidget : public QFrame
79 Q_DISABLE_COPY(DocumentWarningWidget)
81 explicit DocumentWarningWidget(DocumentWidget *documentWidget, QWidget *parent = 0);
83 void setError(const RewriterView::Error &error);
89 QLabel *m_errorMessage;
91 DocumentWidget *m_documentWidget;
92 RewriterView::Error m_error;
95 class DocumentWidget : public QWidget
98 Q_DISABLE_COPY(DocumentWidget)
100 explicit DocumentWidget(TextEditor::ITextEditor *textEditor, QPlainTextEdit *textEdit, QmlDesigner::DesignDocumentController *document, DesignModeWidget *mainWidget);
103 QmlDesigner::DesignDocumentController *document() const;
104 TextEditor::ITextEditor *textEditor() const;
106 void setAutoSynchronization(bool sync);
112 void resizeEvent(QResizeEvent *event);
116 void disable(const QList<RewriterView::Error> &errors);
117 void updateErrorStatus(const QList<RewriterView::Error> &errors);
122 bool isInNodeDefinition(int nodeOffset, int nodeLength, int cursorPos) const;
123 QmlDesigner::ModelNode nodeForPosition(int cursorPos) const;
125 TextEditor::ITextEditor *m_textEditor;
126 QWeakPointer<QPlainTextEdit> m_textBuffer;
127 QmlDesigner::DesignDocumentController *m_document;
128 DesignModeWidget *m_mainWidget;
129 QSplitter *m_mainSplitter;
130 Core::SideBar *m_leftSideBar;
131 Core::SideBar *m_rightSideBar;
133 QToolBar *m_designToolBar;
134 Core::DesignModeToolBar *m_fakeToolBar;
137 DocumentWarningWidget *m_warningWidget;
140 class DesignModeWidget : public QWidget
143 Q_DISABLE_COPY(DesignModeWidget)
145 explicit DesignModeWidget(QWidget *parent = 0);
148 // void syncWithTextEdit(bool sync);
150 void showEditor(Core::IEditor *editor);
151 void closeEditors(const QList<Core::IEditor*> editors);
152 QString contextHelpId() const;
154 QAction *undoAction() const;
155 QAction *redoAction() const;
156 QAction *deleteAction() const;
157 QAction *cutAction() const;
158 QAction *copyAction() const;
159 QAction *pasteAction() const;
160 QAction *selectAllAction() const;
165 void deleteSelected();
171 void undoAvailable(bool isAvailable);
172 void redoAvailable(bool isAvailable);
175 void setCurrentDocumentWidget(DocumentWidget *newDocumentWidget);
177 QStackedWidget *m_documentWidgetStack;
178 QHash<QPlainTextEdit*,DocumentWidget*> m_documentHash;
179 DocumentWidget *m_currentDocumentWidget;
180 QPlainTextEdit *m_currentTextEdit;
182 QAction *m_undoAction;
183 QAction *m_redoAction;
184 QAction *m_deleteAction;
185 QAction *m_cutAction;
186 QAction *m_copyAction;
187 QAction *m_pasteAction;
188 QAction *m_selectAllAction;
190 bool m_syncWithTextEdit;
193 } // namespace Internal
194 } // namespace Designer
196 #endif // DESIGNMODEWIDGET_H