Commit 75aa1d26 authored by Ulf Hermann's avatar Ulf Hermann
Browse files

TextEditor: Support contents() and contentsChanged()

Change-Id: Ia1957d489b8bf2b42c69f739913b50e52e488a69
Reviewed-by: default avatarEike Ziller <>
parent 7129cb0b
......@@ -237,7 +237,7 @@ TextDocument::TextDocument(Id id)
connect(&d->m_document, &QTextDocument::contentsChanged,
this, &TextDocument::contentsChanged);
this, &Core::IDocument::contentsChanged);
connect(&d->m_document, &QTextDocument::contentsChange,
this, &TextDocument::contentsChangedWithPosition);
......@@ -551,6 +551,11 @@ bool TextDocument::save(QString *errorString, const QString &saveFileName, bool
return true;
QByteArray TextDocument::contents() const
return plainText().toUtf8();
bool TextDocument::setContents(const QByteArray &contents)
return setPlainText(QString::fromUtf8(contents));
......@@ -104,6 +104,7 @@ public:
// IDocument implementation.
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QByteArray contents() const override;
bool setContents(const QByteArray &contents) override;
bool shouldAutoSave() const override;
bool isFileReadOnly() const override;
......@@ -142,7 +143,6 @@ public:
void aboutToOpen(const QString &fileName, const QString &realFileName);
void openFinishedSuccessfully();
void contentsChanged();
void contentsChangedWithPosition(int position, int charsRemoved, int charsAdded);
void tabSettingsChanged();
void fontSettingsChanged();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment