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

List:       kde-commits
Subject:    [calligra/textshape-stylesWidget-PierreSt] libs/kotext: Fix apply characterStyle to caret without se
From:       Pierre Stirnweiss <pstirnweiss () googlemail ! com>
Date:       2012-12-28 20:57:18
Message-ID: 20121228205718.3093DA6091 () git ! kde ! org
[Download RAW message or body]

Git commit c43723909a9e32b5aa03786c46364d94ff3b9d4a by Pierre Stirnweiss.
Committed on 23/12/2012 at 19:46.
Pushed by pstirnweiss into branch 'textshape-stylesWidget-PierreSt'.

Fix apply characterStyle to caret without selection

REVIEW: 107878

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

http://commits.kde.org/calligra/c43723909a9e32b5aa03786c46364d94ff3b9d4a

diff --git a/libs/kotext/KoTextEditor_format.cpp b/libs/kotext/KoTextEditor_format.cpp
index d1f0694..7bd345b 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();
     emit characterStyleApplied(style);

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

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