diff options
Diffstat (limited to 'framework/src/domain/textdocumenthandler.cpp')
-rw-r--r-- | framework/src/domain/textdocumenthandler.cpp | 34 |
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 | ||
35 | bool 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 | |||
35 | void TextDocumentHandler::resetFormat() | 63 | void 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 | } |