summaryrefslogtreecommitdiffstats
path: root/framework/src/domain/textdocumenthandler.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-07-30 18:06:31 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-07-30 18:06:31 +0200
commit2bf195a1f5cbf5f473cbbcc929ad64d675e829cb (patch)
treef5070a61bb505fb66413a95c817a952367ffc08d /framework/src/domain/textdocumenthandler.cpp
parent8dc99625d54dbe15816b4b4d0f6c87850289d30d (diff)
downloadkube-2bf195a1f5cbf5f473cbbcc929ad64d675e829cb.tar.gz
kube-2bf195a1f5cbf5f473cbbcc929ad64d675e829cb.zip
Removed the html switch.
Instead of having a switch we're going to always use an html editor, and simply send as plaintext if there is no formatting. To easily remove all formatting a button is added.
Diffstat (limited to 'framework/src/domain/textdocumenthandler.cpp')
-rw-r--r--framework/src/domain/textdocumenthandler.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/framework/src/domain/textdocumenthandler.cpp b/framework/src/domain/textdocumenthandler.cpp
index ea312282..f0cde10d 100644
--- a/framework/src/domain/textdocumenthandler.cpp
+++ b/framework/src/domain/textdocumenthandler.cpp
@@ -32,13 +32,37 @@ TextDocumentHandler::TextDocumentHandler(QObject *parent)
32{ 32{
33} 33}
34 34
35bool TextDocumentHandler::containsFormatting()
36{
37 if (mDocument) {
38 for (const auto &format : mDocument->textDocument()->allFormats()) {
39 switch(format.type()) {
40 case QTextFormat::CharFormat: {
41 const auto charFormat = format.toCharFormat();
42 if (charFormat.fontWeight() != QFont::Normal) {
43 return true;
44 }
45 if (charFormat.fontItalic()) {
46 return true;
47 }
48 if (charFormat.fontUnderline()) {
49 return true;
50 }
51 break;
52 }
53 case QTextFormat::BlockFormat:
54 case QTextFormat::FrameFormat:
55 default:
56 break;
57 }
58 }
59 }
60 return false;
61}
62
35void TextDocumentHandler::resetFormat() 63void TextDocumentHandler::resetFormat()
36{ 64{
37 //Clear all formatting from the document. 65 mDocument->textDocument()->setPlainText(mDocument->textDocument()->toPlainText());
38 auto cursor = textCursor();
39 cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
40 cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
41 cursor.setCharFormat({});
42 mCachedTextFormat = {}; 66 mCachedTextFormat = {};
43 reset(); 67 reset();
44} 68}