OSDN Git Service

5189028e2580299803beef06801d25e45243a030
[qt-creator-jp/qt-creator-jp.git] / src / plugins / designer / formwindoweditor.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 FORMWINDOWEDITOR_H
35 #define FORMWINDOWEDITOR_H
36
37 #include "designer_export.h"
38 #include <coreplugin/editormanager/ieditor.h>
39
40 QT_BEGIN_NAMESPACE
41 class QDesignerFormWindowInterface;
42 QT_END_NAMESPACE
43
44 namespace Core {
45     class IMode;
46 }
47
48 namespace TextEditor {
49     class BaseTextDocument;
50     class PlainTextEditor;
51 }
52
53 namespace Designer {
54
55 namespace Internal {
56     class DesignerXmlEditor;
57 }
58 struct FormWindowEditorPrivate;
59
60 // The actual Core::IEditor belonging to Qt Designer. Uses FormWindowFile
61 // as the Core::IFile to do the isModified() handling,
62 // which needs to be done by Qt Designer.
63 // However, to make the read-only XML text editor work,
64 // a TextEditor::PlainTextEditorEditable (IEditor) is also required.
65 // It is aggregated and some functions are delegated to it.
66
67 class DESIGNER_EXPORT FormWindowEditor : public Core::IEditor
68 {
69     Q_PROPERTY(QString contents READ contents)
70     Q_OBJECT
71 public:
72     explicit FormWindowEditor(Internal::DesignerXmlEditor *editor,
73                               QDesignerFormWindowInterface *form,
74                               QObject *parent = 0);
75     virtual ~FormWindowEditor();
76
77     // IEditor
78     virtual bool createNew(const QString &contents = QString());
79     virtual bool open(const QString &fileName = QString());
80     virtual Core::IFile *file();
81     virtual QString id() const;
82     virtual QString displayName() const;
83     virtual void setDisplayName(const QString &title);
84
85     virtual bool duplicateSupported() const;
86     virtual IEditor *duplicate(QWidget *parent);
87
88     virtual QByteArray saveState() const;
89     virtual bool restoreState(const QByteArray &state);
90
91     virtual bool isTemporary() const;
92
93     virtual QWidget *toolBar();
94
95     virtual  QString preferredModeType() const;
96
97     // IContext
98     virtual Core::Context context() const;
99     virtual QWidget *widget();
100
101     // For uic code model support
102     QString contents() const;
103
104     TextEditor::BaseTextDocument *textDocument();
105     TextEditor::PlainTextEditor *textEditor();
106
107 public slots:
108     void syncXmlEditor();
109     void configureXmlEditor() const;
110
111 private slots:
112     void slotOpen(const QString &fileName);
113
114 private:
115     void syncXmlEditor(const QString &contents);
116
117     FormWindowEditorPrivate *d;
118 };
119
120 } // namespace Designer
121
122 #endif // FORMWINDOWEDITOR_H