r19886 by craig - #4884: Potential fix for long standing cursor placement issue on return to SE

scribus-commit scribus-commit at lists.scribus.net
Thu Feb 26 22:49:36 UTC 2015


Author: craig
Date: Thu Feb 26 22:49:36 2015
New Revision: 19886

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19886
Log:
#4884: Potential fix for long standing cursor placement issue on return to SE

Modified:
    trunk/Scribus/scribus/ui/storyeditor.cpp

Modified: trunk/Scribus/scribus/ui/storyeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19886&path=/trunk/Scribus/scribus/ui/storyeditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/storyeditor.cpp (original)
+++ trunk/Scribus/scribus/ui/storyeditor.cpp Thu Feb 26 22:49:36 2015
@@ -516,18 +516,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);
 }
 
@@ -679,18 +679,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)
@@ -2240,7 +2239,7 @@
 	//				Editor->getCursorPosition(&m_currPara, &m_currChar);
 					updateStatus();
 					m_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