aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quickcontrols2/texteditor/documenthandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quickcontrols2/texteditor/documenthandler.cpp')
-rw-r--r--examples/quickcontrols2/texteditor/documenthandler.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/examples/quickcontrols2/texteditor/documenthandler.cpp b/examples/quickcontrols2/texteditor/documenthandler.cpp
index 25a83592..5def1b61 100644
--- a/examples/quickcontrols2/texteditor/documenthandler.cpp
+++ b/examples/quickcontrols2/texteditor/documenthandler.cpp
@@ -80,7 +80,11 @@ void DocumentHandler::setDocument(QQuickTextDocument *document)
if (document == m_document)
return;
+ if (m_document)
+ m_document->textDocument()->disconnect(this);
m_document = document;
+ if (m_document)
+ connect(m_document->textDocument(), &QTextDocument::modificationChanged, this, &DocumentHandler::modifiedChanged);
emit documentChanged();
}
@@ -370,3 +374,14 @@ void DocumentHandler::mergeFormatOnWordOrSelection(const QTextCharFormat &format
cursor.select(QTextCursor::WordUnderCursor);
cursor.mergeCharFormat(format);
}
+
+bool DocumentHandler::modified() const
+{
+ return m_document && m_document->textDocument()->isModified();
+}
+
+void DocumentHandler::setModified(bool m)
+{
+ if (m_document)
+ m_document->textDocument()->setModified(m);
+}