[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra/calligra/2.6] libs/kotext: Fix apply characterStyle to caret without selection
From:       Pierre Stirnweiss <pstirnweiss () googlemail ! com>
Date:       2012-12-23 18:54:47
Message-ID: 20121223185447.53DBDA6091 () git ! kde ! org
[Download RAW message or body]

Git commit 3f7135c290b03a198f84a3cd981141e90b511373 by Pierre Stirnweiss.
Committed on 23/12/2012 at 19:46.
Pushed by pstirnweiss into branch 'calligra/2.6'.

Fix apply characterStyle to caret without selection

REVIEW: 107878

M  +12   -0    libs/kotext/KoTextEditor_format.cpp

http://commits.kde.org/calligra/3f7135c290b03a198f84a3cd981141e90b511373

diff --git a/libs/kotext/KoTextEditor_format.cpp b/libs/kotext/KoTextEditor_format.cpp
index ad766c5..c8e3c3c 100644
--- a/libs/kotext/KoTextEditor_format.cpp
+++ b/libs/kotext/KoTextEditor_format.cpp
@@ -440,9 +440,21 @@ void KoTextEditor::setStyle(KoCharacterStyle *style)
     Q_ASSERT(style);
     d->updateState(KoTextEditor::Private::Custom, i18nc("(qtundo-format)", "Set Character Style"));
 
+    int caretAnchor = d->caret.anchor();
+    int caretPosition = d->caret.position();
+
     SetCharacterStyleVisitor visitor(this, style);
 
     recursivelyVisitSelection(d->document->rootFrame()->begin(), visitor);
+
+    if (!isEditProtected() && caretAnchor == caretPosition) {
+        style->applyStyle(&(d->caret));
+    }
+    else {
+        d->caret.setPosition(caretAnchor);
+        d->caret.setPosition(caretPosition, QTextCursor::KeepAnchor);
+    }
+
     d->updateState(KoTextEditor::Private::NoOp);
     emit textFormatChanged();
 }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic