OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / texteditor / basetextdocument.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 BASETEXTDOCUMENT_H
34 #define BASETEXTDOCUMENT_H
35
36 #include "texteditor_global.h"
37
38 #include <coreplugin/ifile.h>
39
40 QT_BEGIN_NAMESPACE
41 class QTextCursor;
42 class QTextDocument;
43 QT_END_NAMESPACE
44
45 namespace TextEditor {
46
47 class ITextMarkable;
48 class StorageSettings;
49 class TabSettings;
50 class ExtraEncodingSettings;
51 class SyntaxHighlighter;
52 class BaseTextDocumentPrivate;
53
54 class TEXTEDITOR_EXPORT BaseTextDocument : public Core::IFile
55 {
56     Q_OBJECT
57
58 public:
59     BaseTextDocument();
60     virtual ~BaseTextDocument();
61
62     void setStorageSettings(const StorageSettings &storageSettings);
63     void setTabSettings(const TabSettings &tabSettings);
64     void setExtraEncodingSettings(const ExtraEncodingSettings &extraEncodingSettings);
65
66     const StorageSettings &storageSettings() const;
67     const TabSettings &tabSettings() const;
68     const ExtraEncodingSettings &extraEncodingSettings() const;
69
70     ITextMarkable *documentMarker() const;
71
72     // IFile implementation.
73     virtual bool save(const QString &fileName = QString());
74     virtual QString fileName() const;
75     virtual bool isReadOnly() const;
76     virtual bool isModified() const;
77     virtual bool isSaveAsAllowed() const;
78     virtual void checkPermissions();
79     ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
80     void reload(ReloadFlag flag, ChangeType type);
81     virtual QString mimeType() const;
82     void setMimeType(const QString &mt);
83     virtual void rename(const QString &newName);
84
85     virtual QString defaultPath() const;
86     virtual QString suggestedFileName() const;
87
88     void setDefaultPath(const QString &defaultPath);
89     void setSuggestedFileName(const QString &suggestedFileName);
90
91     virtual bool open(const QString &fileName = QString());
92     virtual void reload();
93
94     QTextDocument *document() const;
95     void setSyntaxHighlighter(SyntaxHighlighter *highlighter);
96     SyntaxHighlighter *syntaxHighlighter() const;
97
98     bool hasDecodingError() const;
99     QTextCodec *codec() const;
100     void setCodec(QTextCodec *c);
101     QByteArray decodingErrorSample() const;
102
103     void reload(QTextCodec *codec);
104     void cleanWhitespace(const QTextCursor &cursor);
105
106 signals:
107     void titleChanged(QString title);
108
109 private:
110     void cleanWhitespace(QTextCursor &cursor, bool cleanIndentation, bool inEntireDocument);
111     void ensureFinalNewLine(QTextCursor &cursor);
112     void documentClosing();
113
114     BaseTextDocumentPrivate *d;
115 };
116
117 } // namespace TextEditor
118
119 #endif // BASETEXTDOCUMENT_H