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

TextEditor: Support contents() and contentsChanged()

Change-Id: Ia1957d489b8bf2b42c69f739913b50e52e488a69
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 7129cb0b
...@@ -237,7 +237,7 @@ TextDocument::TextDocument(Id id) ...@@ -237,7 +237,7 @@ TextDocument::TextDocument(Id id)
}); });
connect(&d->m_document, &QTextDocument::contentsChanged, connect(&d->m_document, &QTextDocument::contentsChanged,
this, &TextDocument::contentsChanged); this, &Core::IDocument::contentsChanged);
connect(&d->m_document, &QTextDocument::contentsChange, connect(&d->m_document, &QTextDocument::contentsChange,
this, &TextDocument::contentsChangedWithPosition); this, &TextDocument::contentsChangedWithPosition);
...@@ -551,6 +551,11 @@ bool TextDocument::save(QString *errorString, const QString &saveFileName, bool ...@@ -551,6 +551,11 @@ bool TextDocument::save(QString *errorString, const QString &saveFileName, bool
return true; return true;
} }
QByteArray TextDocument::contents() const
{
return plainText().toUtf8();
}
bool TextDocument::setContents(const QByteArray &contents) bool TextDocument::setContents(const QByteArray &contents)
{ {
return setPlainText(QString::fromUtf8(contents)); return setPlainText(QString::fromUtf8(contents));
......
...@@ -104,6 +104,7 @@ public: ...@@ -104,6 +104,7 @@ public:
// IDocument implementation. // IDocument implementation.
bool save(QString *errorString, const QString &fileName, bool autoSave) override; bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QByteArray contents() const override;
bool setContents(const QByteArray &contents) override; bool setContents(const QByteArray &contents) override;
bool shouldAutoSave() const override; bool shouldAutoSave() const override;
bool isFileReadOnly() const override; bool isFileReadOnly() const override;
...@@ -142,7 +143,6 @@ public: ...@@ -142,7 +143,6 @@ public:
signals: signals:
void aboutToOpen(const QString &fileName, const QString &realFileName); void aboutToOpen(const QString &fileName, const QString &realFileName);
void openFinishedSuccessfully(); void openFinishedSuccessfully();
void contentsChanged();
void contentsChangedWithPosition(int position, int charsRemoved, int charsAdded); void contentsChangedWithPosition(int position, int charsRemoved, int charsAdded);
void tabSettingsChanged(); void tabSettingsChanged();
void fontSettingsChanged(); 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