summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-08-26 11:39:58 (GMT)
committerMontel Laurent <montel@kde.org>2016-08-26 11:39:58 (GMT)
commit717e316c8da211e9b117d5c0e968ec4c1fc73425 (patch)
tree76cae8dfbb4d5a57e2f19518227deb765e8f00f9
parent5b38184696f93231c99097a79f35a9cc6493f030 (diff)
Implement forceAutocorrect
-rw-r--r--messagecomposer/src/composer-ng/richtextcomposerng.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/messagecomposer/src/composer-ng/richtextcomposerng.cpp b/messagecomposer/src/composer-ng/richtextcomposerng.cpp
index c9fdaf1..3244535 100644
--- a/messagecomposer/src/composer-ng/richtextcomposerng.cpp
+++ b/messagecomposer/src/composer-ng/richtextcomposerng.cpp
@@ -372,6 +372,20 @@ QString RichTextComposerNg::toCleanHtml() const
void RichTextComposerNg::forceAutoCorrection()
{
if (d->autoCorrection && d->autoCorrection->isEnabledAutoCorrection()) {
- //TODO
+ if (!document()->isEmpty()) {
+ const bool richText = (textMode() == RichTextComposer::Rich);
+ const int initialPosition = textCursor().position();
+ QTextCursor cur = textCursor();
+ cur.movePosition(QTextCursor::Start);
+ while(!cur.atEnd()) {
+ cur.movePosition(QTextCursor::NextWord);
+ int cursortPosition = cur.position();
+ d->autoCorrection->autocorrect(richText, *document(), cursortPosition);
+ }
+ if (cur.position() != initialPosition) {
+ cur.setPosition(initialPosition);
+ setTextCursor(cur);
+ }
+ }
}
}