diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-09-13 11:12:30 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-09-13 11:12:30 +0200 |
commit | 5e9d12d1d9793afe0099fc8b68eeae1b8bbe8098 (patch) | |
tree | f6e8e526e82885ee7d50878d9b43c6907e73baa8 /framework/src/domain/documenthandler.cpp | |
parent | 8edb362d96ed740cf5f387649d760c17c7c17d31 (diff) | |
download | kube-5e9d12d1d9793afe0099fc8b68eeae1b8bbe8098.tar.gz kube-5e9d12d1d9793afe0099fc8b68eeae1b8bbe8098.zip |
Extract html or plaintext depending on setting
Diffstat (limited to 'framework/src/domain/documenthandler.cpp')
-rw-r--r-- | framework/src/domain/documenthandler.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/framework/src/domain/documenthandler.cpp b/framework/src/domain/documenthandler.cpp index 0f949da8..3589fc9f 100644 --- a/framework/src/domain/documenthandler.cpp +++ b/framework/src/domain/documenthandler.cpp | |||
@@ -79,10 +79,36 @@ void DocumentHandler::setDocument(QQuickTextDocument *document) | |||
79 | { | 79 | { |
80 | if (document != m_document) { | 80 | if (document != m_document) { |
81 | m_document = document; | 81 | m_document = document; |
82 | connect(m_document->textDocument(), &QTextDocument::contentsChanged, this, [this] () { | ||
83 | emit textChanged(); | ||
84 | }); | ||
82 | emit documentChanged(); | 85 | emit documentChanged(); |
83 | } | 86 | } |
84 | } | 87 | } |
85 | 88 | ||
89 | static QString stripInvisibleChars(const QString &s) | ||
90 | { | ||
91 | auto text = s; | ||
92 | text.replace("\u2063", ""); | ||
93 | return text; | ||
94 | } | ||
95 | |||
96 | QString DocumentHandler::plainText() const | ||
97 | { | ||
98 | if (m_document) { | ||
99 | return stripInvisibleChars(m_document->textDocument()->toPlainText()); | ||
100 | } | ||
101 | return {}; | ||
102 | } | ||
103 | |||
104 | QString DocumentHandler::htmlText() const | ||
105 | { | ||
106 | if (m_document) { | ||
107 | return stripInvisibleChars(m_document->textDocument()->toHtml()); | ||
108 | } | ||
109 | return {}; | ||
110 | } | ||
111 | |||
86 | int DocumentHandler::cursorPosition() const | 112 | int DocumentHandler::cursorPosition() const |
87 | { | 113 | { |
88 | return m_cursorPosition; | 114 | return m_cursorPosition; |