basetextdocument.h 3.71 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2 3 4
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
Eike Ziller's avatar
Eike Ziller committed
7
** Contact: http://www.qt-project.org/
con's avatar
con committed
8
**
9
**
10
** GNU Lesser General Public License Usage
11
**
hjk's avatar
hjk committed
12 13 14 15 16 17
** 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.
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21 22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23 24 25 26 27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
con's avatar
con committed
28
**
29
**************************************************************************/
hjk's avatar
hjk committed
30

con's avatar
con committed
31 32 33 34 35
#ifndef BASETEXTDOCUMENT_H
#define BASETEXTDOCUMENT_H

#include "texteditor_global.h"

36
#include <coreplugin/textdocument.h>
37

con's avatar
con committed
38 39 40 41 42 43 44
QT_BEGIN_NAMESPACE
class QTextCursor;
class QTextDocument;
QT_END_NAMESPACE

namespace TextEditor {

45
class ITextMarkable;
Jarek Kobus's avatar
Jarek Kobus committed
46
class TypingSettings;
47 48
class StorageSettings;
class TabSettings;
49
class ExtraEncodingSettings;
50
class SyntaxHighlighter;
51
class BaseTextDocumentPrivate;
con's avatar
con committed
52

53
class TEXTEDITOR_EXPORT BaseTextDocument : public Core::TextDocument
con's avatar
con committed
54 55 56 57 58
{
    Q_OBJECT

public:
    BaseTextDocument();
59
    virtual ~BaseTextDocument();
con's avatar
con committed
60

Jarek Kobus's avatar
Jarek Kobus committed
61
    void setTypingSettings(const TypingSettings &typingSettings);
62 63
    void setStorageSettings(const StorageSettings &storageSettings);
    void setTabSettings(const TabSettings &tabSettings);
64
    void setExtraEncodingSettings(const ExtraEncodingSettings &extraEncodingSettings);
con's avatar
con committed
65

Jarek Kobus's avatar
Jarek Kobus committed
66
    const TypingSettings &typingSettings() const;
67 68
    const StorageSettings &storageSettings() const;
    const TabSettings &tabSettings() const;
69
    const ExtraEncodingSettings &extraEncodingSettings() const;
70 71

    ITextMarkable *documentMarker() const;
con's avatar
con committed
72

73
    // IDocument implementation.
74
    virtual bool save(QString *errorString, const QString &fileName, bool autoSave);
75
    virtual QString fileName() const;
76
    virtual bool shouldAutoSave() const;
77
    virtual bool isFileReadOnly() const;
con's avatar
con committed
78
    virtual bool isModified() const;
79
    virtual bool isSaveAsAllowed() const;
80
    virtual void checkPermissions();
81
    bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
con's avatar
con committed
82 83
    virtual QString mimeType() const;
    void setMimeType(const QString &mt);
dt's avatar
dt committed
84
    virtual void rename(const QString &newName);
con's avatar
con committed
85

86 87
    virtual QString defaultPath() const;
    virtual QString suggestedFileName() const;
con's avatar
con committed
88

89 90
    void setDefaultPath(const QString &defaultPath);
    void setSuggestedFileName(const QString &suggestedFileName);
con's avatar
con committed
91

92
    virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName);
93
    virtual bool reload(QString *errorString);
con's avatar
con committed
94

95
    QTextDocument *document() const;
96
    void setSyntaxHighlighter(SyntaxHighlighter *highlighter);
97
    SyntaxHighlighter *syntaxHighlighter() const;
con's avatar
con committed
98

99
    bool reload(QString *errorString, QTextCodec *codec);
100
    void cleanWhitespace(const QTextCursor &cursor);
101

102 103 104
    bool hasHighlightWarning() const;
    void setHighlightWarning(bool has);

con's avatar
con committed
105 106 107 108
signals:
    void titleChanged(QString title);

private:
hjk's avatar
hjk committed
109 110
    void cleanWhitespace(QTextCursor &cursor, bool cleanIndentation, bool inEntireDocument);
    void ensureFinalNewLine(QTextCursor &cursor);
111 112

    BaseTextDocumentPrivate *d;
con's avatar
con committed
113 114 115 116
};

} // namespace TextEditor

hjk's avatar
hjk committed
117
#endif // BASETEXTDOCUMENT_H