designmodewidget.h 5.23 KB
Newer Older
1
2
3
4
/**************************************************************************
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/

#ifndef DESIGNMODEWIDGET_H
#define DESIGNMODEWIDGET_H

#include <coreplugin/minisplitter.h>
#include <coreplugin/editormanager/ieditor.h>
#include <texteditor/itexteditor.h>

#include <integrationcore.h>

#include <allpropertiesbox.h>
#include <designdocumentcontroller.h>
#include <itemlibrary.h>
#include <navigatorwidget.h>
43
#include <navigatorview.h>
44
45
#include <stateseditorwidget.h>
#include <modelnode.h>
46
#include <formeditorview.h>
47
48
49


#include <QWeakPointer>
50
#include <QDeclarativeError>
51
52
53
54
55
56
#include <QtCore/QHash>
#include <QtGui/QWidget>
#include <QtGui/QToolBar>
#include <QtGui/QComboBox>
#include <QtGui/QLabel>

57
QT_BEGIN_NAMESPACE
58
59
60
61
class QStackedWidget;
class QTabWidget;
class QVBoxLayout;
class QToolButton;
62
QT_END_NAMESPACE
63
64
65
66

namespace Core {
    class SideBar;
    class OpenEditorsModel;
Lasse Holmstedt's avatar
Lasse Holmstedt committed
67
    class EditorToolBar;
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
}

namespace QmlDesigner {

namespace Internal {

class DesignMode;
class DocumentWidget;
class DesignModeWidget;

class DocumentWarningWidget : public QFrame
{
    Q_OBJECT
    Q_DISABLE_COPY(DocumentWarningWidget)
public:
83
    explicit DocumentWarningWidget(DesignModeWidget *parent = 0);
84
85
86
87
88
89
90
91
92
93

    void setError(const RewriterView::Error &error);

private slots:
    void goToError();

private:
    QLabel *m_errorMessage;
    QLabel *m_goToError;
    RewriterView::Error m_error;
94
    DesignModeWidget *m_designModeWidget;
95
96
97
98
99
100
101
};

class DesignModeWidget : public QWidget
{
    Q_OBJECT
    Q_DISABLE_COPY(DesignModeWidget)
public:
Lasse Holmstedt's avatar
Lasse Holmstedt committed
102
    explicit DesignModeWidget(QWidget *parent = 0);
103
104
105
106
    ~DesignModeWidget();

    void showEditor(Core::IEditor *editor);
    void closeEditors(const QList<Core::IEditor*> editors);
107
    QString contextHelpId() const;
108
109
110
111
112
113
114

    QAction *undoAction() const;
    QAction *redoAction() const;
    QAction *deleteAction() const;
    QAction *cutAction() const;
    QAction *copyAction() const;
    QAction *pasteAction() const;
115
    QAction *selectAllAction() const;
116

117
118
119
120
121
122
    void readSettings();
    void saveSettings();
    void setAutoSynchronization(bool sync);

    TextEditor::ITextEditor *textEditor() const {return m_textEditor; }

123
124
125
126
127
128
129
private slots:
    void undo();
    void redo();
    void deleteSelected();
    void cutSelected();
    void copySelected();
    void paste();
130
    void selectAll();
131
    void closeCurrentEditor();
132
133
134
135

    void undoAvailable(bool isAvailable);
    void redoAvailable(bool isAvailable);

136
137
138
139
140
141
142
    void enable();
    void disable(const QList<RewriterView::Error> &errors);
    void updateErrorStatus(const QList<RewriterView::Error> &errors);

protected:
    void resizeEvent(QResizeEvent *event);

143
private:
144
145
    DesignDocumentController *currentDesignDocumentController() const {return m_currentDesignDocumentController.data(); }
    void setCurrentDocument(DesignDocumentController *newDesignDocumentController);
146

147
148
149
150
    //QStackedWidget *m_documentWidgetStack;
    QHash<QPlainTextEdit*,QWeakPointer<DesignDocumentController> > m_documentHash;
    QWeakPointer<DesignDocumentController> m_currentDesignDocumentController;
    QWeakPointer<QPlainTextEdit> m_currentTextEdit;
151
152
153
154
155
156
157

    QAction *m_undoAction;
    QAction *m_redoAction;
    QAction *m_deleteAction;
    QAction *m_cutAction;
    QAction *m_copyAction;
    QAction *m_pasteAction;
158
    QAction *m_selectAllAction;
159

160
161
162
163
164
165
    QWeakPointer<ItemLibrary> m_itemLibrary;
    QWeakPointer<NavigatorView> m_navigator;
    QWeakPointer<AllPropertiesBox> m_allPropertiesBox;
    QWeakPointer<StatesEditorWidget> m_statesEditorWidget;
    QWeakPointer<FormEditorView> m_formEditorView;

166
    bool m_syncWithTextEdit;
167
168
169
170
171
172
173
174
175
176
177
178
179

    void setup();
    bool isInNodeDefinition(int nodeOffset, int nodeLength, int cursorPos) const;
    QmlDesigner::ModelNode nodeForPosition(int cursorPos) const;

    TextEditor::ITextEditor *m_textEditor;

    QSplitter *m_mainSplitter;
    Core::SideBar *m_leftSideBar;
    Core::SideBar *m_rightSideBar;
    Core::EditorToolBar *m_fakeToolBar;

    bool m_isDisabled;
Kai Koehne's avatar
Kai Koehne committed
180
181
182
183

    enum InitializeStatus { NotInitialized, Initializing, Initialized };
    InitializeStatus m_initStatus;

184
    DocumentWarningWidget *m_warningWidget;
185
186
187
188
189
190
};

} // namespace Internal
} // namespace Designer

#endif // DESIGNMODEWIDGET_H