basetextdocument.h 3.91 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22 23 24 25
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
hjk's avatar
hjk committed
29

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

#include "texteditor_global.h"

35
#include <coreplugin/textdocument.h>
36

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

namespace TextEditor {

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

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

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

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

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

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

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

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

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

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

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

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

con's avatar
con committed
101 102 103 104
signals:
    void titleChanged(QString title);

private:
hjk's avatar
hjk committed
105 106
    void cleanWhitespace(QTextCursor &cursor, bool cleanIndentation, bool inEntireDocument);
    void ensureFinalNewLine(QTextCursor &cursor);
107 108

    BaseTextDocumentPrivate *d;
con's avatar
con committed
109 110 111 112
};

} // namespace TextEditor

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