2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef BASETEXTDOCUMENT_H
|
|
|
|
|
#define BASETEXTDOCUMENT_H
|
|
|
|
|
|
|
|
|
|
#include "texteditor_global.h"
|
|
|
|
|
|
2011-08-25 12:54:20 +02:00
|
|
|
#include <coreplugin/textfile.h>
|
2009-10-01 16:38:08 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QTextCursor;
|
|
|
|
|
class QTextDocument;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
namespace TextEditor {
|
|
|
|
|
|
2010-10-29 15:20:10 +02:00
|
|
|
class ITextMarkable;
|
2011-08-16 10:45:23 +02:00
|
|
|
class TypingSettings;
|
2010-10-29 15:20:10 +02:00
|
|
|
class StorageSettings;
|
|
|
|
|
class TabSettings;
|
2011-02-01 14:13:54 +01:00
|
|
|
class ExtraEncodingSettings;
|
2010-07-09 14:47:18 +02:00
|
|
|
class SyntaxHighlighter;
|
2010-10-29 15:20:10 +02:00
|
|
|
class BaseTextDocumentPrivate;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-08-25 12:54:20 +02:00
|
|
|
class TEXTEDITOR_EXPORT BaseTextDocument : public Core::TextFile
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
BaseTextDocument();
|
2010-10-29 15:20:10 +02:00
|
|
|
virtual ~BaseTextDocument();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
void setTypingSettings(const TypingSettings &typingSettings);
|
2010-10-29 15:20:10 +02:00
|
|
|
void setStorageSettings(const StorageSettings &storageSettings);
|
|
|
|
|
void setTabSettings(const TabSettings &tabSettings);
|
2011-02-01 14:13:54 +01:00
|
|
|
void setExtraEncodingSettings(const ExtraEncodingSettings &extraEncodingSettings);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
const TypingSettings &typingSettings() const;
|
2010-10-29 15:20:10 +02:00
|
|
|
const StorageSettings &storageSettings() const;
|
|
|
|
|
const TabSettings &tabSettings() const;
|
2011-02-01 14:13:54 +01:00
|
|
|
const ExtraEncodingSettings &extraEncodingSettings() const;
|
2010-10-29 15:20:10 +02:00
|
|
|
|
|
|
|
|
ITextMarkable *documentMarker() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-02-21 19:56:51 +01:00
|
|
|
// IFile implementation.
|
2011-05-10 20:43:03 +02:00
|
|
|
virtual bool save(QString *errorString, const QString &fileName, bool autoSave);
|
2010-10-29 15:20:10 +02:00
|
|
|
virtual QString fileName() const;
|
2011-05-10 20:43:03 +02:00
|
|
|
virtual bool shouldAutoSave() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual bool isReadOnly() const;
|
|
|
|
|
virtual bool isModified() const;
|
2010-10-29 15:20:10 +02:00
|
|
|
virtual bool isSaveAsAllowed() const;
|
2009-05-08 15:48:00 +02:00
|
|
|
virtual void checkPermissions();
|
2011-04-04 15:24:13 +02:00
|
|
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual QString mimeType() const;
|
|
|
|
|
void setMimeType(const QString &mt);
|
2010-05-11 14:13:38 +02:00
|
|
|
virtual void rename(const QString &newName);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-10-29 15:20:10 +02:00
|
|
|
virtual QString defaultPath() const;
|
|
|
|
|
virtual QString suggestedFileName() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-10-29 15:20:10 +02:00
|
|
|
void setDefaultPath(const QString &defaultPath);
|
|
|
|
|
void setSuggestedFileName(const QString &suggestedFileName);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-05-10 20:43:03 +02:00
|
|
|
virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
2011-04-04 15:24:13 +02:00
|
|
|
virtual bool reload(QString *errorString);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-10-29 15:20:10 +02:00
|
|
|
QTextDocument *document() const;
|
2010-07-09 14:47:18 +02:00
|
|
|
void setSyntaxHighlighter(SyntaxHighlighter *highlighter);
|
2010-10-29 15:20:10 +02:00
|
|
|
SyntaxHighlighter *syntaxHighlighter() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-04-04 15:24:13 +02:00
|
|
|
bool reload(QString *errorString, QTextCodec *codec);
|
2009-09-09 16:37:09 +02:00
|
|
|
void cleanWhitespace(const QTextCursor &cursor);
|
2008-12-09 17:43:31 +01:00
|
|
|
|
2011-05-20 11:27:07 +02:00
|
|
|
bool hasHighlightWarning() const;
|
|
|
|
|
void setHighlightWarning(bool has);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
signals:
|
|
|
|
|
void titleChanged(QString title);
|
|
|
|
|
|
|
|
|
|
private:
|
2011-02-21 19:56:51 +01:00
|
|
|
void cleanWhitespace(QTextCursor &cursor, bool cleanIndentation, bool inEntireDocument);
|
|
|
|
|
void ensureFinalNewLine(QTextCursor &cursor);
|
2010-05-28 14:06:57 +02:00
|
|
|
void documentClosing();
|
2010-10-29 15:20:10 +02:00
|
|
|
|
|
|
|
|
BaseTextDocumentPrivate *d;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace TextEditor
|
|
|
|
|
|
2008-12-02 16:19:05 +01:00
|
|
|
#endif // BASETEXTDOCUMENT_H
|