2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-08-25 12:54:20 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-08-25 12:54:20 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-08-25 12:54:20 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-08-25 12:54:20 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-08-25 12:54:20 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-08-25 12:54:20 +02:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2011-08-25 12:54:20 +02:00
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
#include "idocument.h"
|
2011-08-25 12:54:20 +02:00
|
|
|
|
|
|
|
|
#include <utils/textfileformat.h>
|
|
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
|
|
2014-09-26 09:14:03 +02:00
|
|
|
namespace Internal { class TextDocumentPrivate; }
|
2011-08-25 12:54:20 +02:00
|
|
|
|
2014-09-22 18:43:31 +02:00
|
|
|
class CORE_EXPORT BaseTextDocument : public IDocument
|
2011-08-25 12:54:20 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2014-09-22 18:43:31 +02:00
|
|
|
|
2011-08-25 12:54:20 +02:00
|
|
|
public:
|
2018-07-21 21:11:46 +02:00
|
|
|
using ReadResult = Utils::TextFileFormat::ReadResult;
|
2011-08-25 12:54:20 +02:00
|
|
|
|
2018-05-07 17:34:42 +02:00
|
|
|
explicit BaseTextDocument(QObject *parent = nullptr);
|
2015-06-04 15:54:10 +02:00
|
|
|
~BaseTextDocument() override;
|
2011-08-25 12:54:20 +02:00
|
|
|
|
|
|
|
|
Utils::TextFileFormat format() const;
|
|
|
|
|
const QTextCodec *codec() const;
|
|
|
|
|
void setCodec(const QTextCodec *);
|
2012-03-02 08:16:23 +08:00
|
|
|
void switchUtf8Bom();
|
2016-05-30 15:23:52 +02:00
|
|
|
bool supportsUtf8Bom() const;
|
2019-07-13 06:27:17 +02:00
|
|
|
Utils::TextFileFormat::LineTerminationMode lineTerminationMode() const;
|
2011-08-25 12:54:20 +02:00
|
|
|
|
2021-05-18 13:55:23 +02:00
|
|
|
ReadResult read(const Utils::FilePath &filePath, QStringList *plainTextList, QString *errorString);
|
|
|
|
|
ReadResult read(const Utils::FilePath &filePath, QString *plainText, QString *errorString);
|
2011-08-25 12:54:20 +02:00
|
|
|
|
|
|
|
|
bool hasDecodingError() const;
|
|
|
|
|
QByteArray decodingErrorSample() const;
|
|
|
|
|
|
2021-05-18 13:55:23 +02:00
|
|
|
bool write(const Utils::FilePath &filePath, const QString &data, QString *errorMessage) const;
|
|
|
|
|
bool write(const Utils::FilePath &filePath, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const;
|
2011-08-25 12:54:20 +02:00
|
|
|
|
2016-05-30 15:23:52 +02:00
|
|
|
void setSupportsUtf8Bom(bool value);
|
2019-07-13 06:27:17 +02:00
|
|
|
void setLineTerminationMode(Utils::TextFileFormat::LineTerminationMode mode);
|
2016-05-30 15:23:52 +02:00
|
|
|
|
2011-08-25 12:54:20 +02:00
|
|
|
private:
|
2014-09-26 09:14:03 +02:00
|
|
|
Internal::TextDocumentPrivate *d;
|
2011-08-25 12:54:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Core
|