r20088 by jghali - backport fix for #4844: cursor placement issue on return to SE
scribus-commit
scribus-commit at lists.scribus.net
Sat May 16 12:09:30 UTC 2015
Author: jghali
Date: Sat May 16 12:09:30 2015
New Revision: 20088
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20088
Log:
backport fix for #4844: cursor placement issue on return to SE
Modified:
branches/Version14x/Scribus/scribus/storyeditor.cpp
Modified: branches/Version14x/Scribus/scribus/storyeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20088&path=/branches/Version14x/Scribus/scribus/storyeditor.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/storyeditor.cpp (original)
+++ branches/Version14x/Scribus/scribus/storyeditor.cpp Sat May 16 12:09:30 2015
@@ -504,15 +504,16 @@
void SEditor::focusOutEvent(QFocusEvent *e)
{
- if (textCursor().hasSelection())
- {
- SelParaStart = textCursor().selectionStart();
- SelParaEnd = textCursor().selectionEnd();
+ QTextCursor tc(textCursor());
+ if (tc.hasSelection())
+ {
+ SelParaStart = tc.selectionStart();
+ SelParaEnd = tc.selectionEnd();
StoredSel = true;
}
else
{
- SelParaStart = textCursor().position();
+ SelParaStart = tc.position();
StoredSel = false;
}
QTextEdit::focusOutEvent(e);
@@ -520,18 +521,18 @@
void SEditor::focusInEvent(QFocusEvent *e)
{
+ QTextCursor tc(textCursor());
if (StoredSel)
{
- textCursor().setPosition(SelParaStart);
- textCursor().setPosition(SelParaEnd, QTextCursor::KeepAnchor);
+ tc.setPosition(SelParaStart);
+ tc.setPosition(SelParaEnd, QTextCursor::KeepAnchor);
StoredSel = false;
}
else
{
- textCursor().setPosition(SelParaStart);
- StoredSel = false;
- }
-
+ tc.setPosition(qMin(SelParaStart, StyledText.length()));
+ }
+ setTextCursor(tc);
QTextEdit::focusInEvent(e);
}
@@ -673,18 +674,17 @@
StyledText.append(currItem->itemText);
updateAll();
int npars = currItem->itemText.nrOfParagraphs();
- SelParaStart = 0;
- while (currItem->itemText.cursorPosition() >= (SelCharStart = currItem->itemText.endOfParagraph(SelParaStart))
- && SelParaStart < npars)
- ++SelParaStart;
+ int newSelParaStart = 0;
+ while (currItem->itemText.cursorPosition() >= (SelCharStart = currItem->itemText.endOfParagraph(newSelParaStart)) && newSelParaStart < npars)
+ ++newSelParaStart;
if (currItem->itemText.cursorPosition() < SelCharStart)
SelCharStart = currItem->itemText.cursorPosition();
- SelCharStart -= currItem->itemText.startOfParagraph(SelParaStart);
+ SelCharStart -= currItem->itemText.startOfParagraph(newSelParaStart);
StoredSel = false;
//qDebug() << "SE::loadItemText: cursor";
// setCursorPosition(SelParaStart, SelCharStart);
- emit setProps(SelParaStart, SelCharStart);
- SelParaStart = 0;
+ emit setProps(newSelParaStart, SelCharStart);
+ //SelParaStart = 0;
}
void SEditor::loadText(QString tx, PageItem *currItem)
@@ -2225,7 +2225,7 @@
// Editor->getCursorPosition(&CurrPara, &CurrChar);
updateStatus();
textChanged = false;
- Editor->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
+ //Editor->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
Editor->repaint();
EditorBar->offs = 0;
// EditorBar->doMove(0, Editor->contentsY());
More information about the scribus-commit
mailing list