[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/textshape-stylesWidget-PierreSt] libs/kotext: Fix merge style to caret without selection
From: Pierre Stirnweiss <pstirnweiss () googlemail ! com>
Date: 2013-02-03 21:41:38
Message-ID: 20130203214138.64FE0A6091 () git ! kde ! org
[Download RAW message or body]
Git commit f63718a89e24abad7a83655f061cafa3b147d1bc by Pierre Stirnweiss.
Committed on 13/01/2013 at 10:42.
Pushed by pstirnweiss into branch 'textshape-stylesWidget-PierreSt'.
Fix merge style to caret without selection
The style was not properly merged to the caret if there was no selected
text.
REVIEW: 108379
M +21 -0 libs/kotext/KoTextEditor_format.cpp
http://commits.kde.org/calligra/f63718a89e24abad7a83655f061cafa3b147d1bc
diff --git a/libs/kotext/KoTextEditor_format.cpp \
b/libs/kotext/KoTextEditor_format.cpp index 5a35fe8..25e91ae 100644
--- a/libs/kotext/KoTextEditor_format.cpp
+++ b/libs/kotext/KoTextEditor_format.cpp
@@ -564,10 +564,20 @@ void KoTextEditor::mergeAutoStyle(const QTextCharFormat \
&deltaCharFormat) {
d->updateState(KoTextEditor::Private::Custom, "Formatting");
+ int caretAnchor = d->caret.anchor();
+ int caretPosition = d->caret.position();
MergeAutoCharacterStyleVisitor visitor(this, deltaCharFormat);
recursivelyVisitSelection(d->document->rootFrame()->begin(), visitor);
+ if (!isEditProtected() && caretAnchor == caretPosition) { //if there is no \
selection, it can happen that the caret does not get the proper style applied \
(begining of a block). We need to force it. + \
d->caret.mergeCharFormat(deltaCharFormat); + }
+ else {
+ d->caret.setPosition(caretAnchor);
+ d->caret.setPosition(caretPosition, QTextCursor::KeepAnchor);
+ }
+
d->updateState(KoTextEditor::Private::NoOp);
emit textFormatChanged();
}
@@ -627,10 +637,21 @@ void KoTextEditor::mergeAutoStyle(const QTextCharFormat \
&deltaCharFormat, const {
d->updateState(KoTextEditor::Private::Custom, "Formatting");
+ int caretAnchor = d->caret.anchor();
+ int caretPosition = d->caret.position();
MergeAutoParagraphStyleVisitor visitor(this, deltaCharFormat, deltaBlockFormat);
recursivelyVisitSelection(d->document->rootFrame()->begin(), visitor);
+ if (!isEditProtected() && caretAnchor == caretPosition) { //if there is no \
selection, it can happen that the caret does not get the proper style applied \
(begining of a block). We need to force it. + \
d->caret.mergeBlockFormat(deltaBlockFormat); + \
d->caret.mergeBlockCharFormat(deltaCharFormat); + }
+ 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