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 BASETEXTDOCUMENT_H
34 #define BASETEXTDOCUMENT_H
36 #include "texteditor_global.h"
38 #include <coreplugin/ifile.h>
45 namespace TextEditor {
48 class StorageSettings;
50 class ExtraEncodingSettings;
51 class SyntaxHighlighter;
52 class BaseTextDocumentPrivate;
54 class TEXTEDITOR_EXPORT BaseTextDocument : public Core::IFile
60 virtual ~BaseTextDocument();
62 void setStorageSettings(const StorageSettings &storageSettings);
63 void setTabSettings(const TabSettings &tabSettings);
64 void setExtraEncodingSettings(const ExtraEncodingSettings &extraEncodingSettings);
66 const StorageSettings &storageSettings() const;
67 const TabSettings &tabSettings() const;
68 const ExtraEncodingSettings &extraEncodingSettings() const;
70 ITextMarkable *documentMarker() const;
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);
85 virtual QString defaultPath() const;
86 virtual QString suggestedFileName() const;
88 void setDefaultPath(const QString &defaultPath);
89 void setSuggestedFileName(const QString &suggestedFileName);
91 virtual bool open(const QString &fileName = QString());
92 virtual void reload();
94 QTextDocument *document() const;
95 void setSyntaxHighlighter(SyntaxHighlighter *highlighter);
96 SyntaxHighlighter *syntaxHighlighter() const;
98 bool hasDecodingError() const;
99 QTextCodec *codec() const;
100 void setCodec(QTextCodec *c);
101 QByteArray decodingErrorSample() const;
103 void reload(QTextCodec *codec);
104 void cleanWhitespace(const QTextCursor &cursor);
107 void titleChanged(QString title);
110 void cleanWhitespace(QTextCursor &cursor, bool cleanIndentation, bool inEntireDocument);
111 void ensureFinalNewLine(QTextCursor &cursor);
112 void documentClosing();
114 BaseTextDocumentPrivate *d;
117 } // namespace TextEditor
119 #endif // BASETEXTDOCUMENT_H