r20501 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Tue Oct 27 12:49:20 UTC 2015


Author: jghali
Date: Tue Oct 27 12:49:20 2015
New Revision: 20501

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20501
Log:
backport #12091: Leave text cursor at search position in Story Editor when closing search dialog

Modified:
    branches/Version14x/Scribus/scribus/search.cpp
    branches/Version14x/Scribus/scribus/search.h
    branches/Version14x/Scribus/scribus/storyeditor.cpp
    branches/Version14x/Scribus/scribus/storyeditor.h

Modified: branches/Version14x/Scribus/scribus/search.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20501&path=/branches/Version14x/Scribus/scribus/search.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/search.cpp	(original)
+++ branches/Version14x/Scribus/scribus/search.cpp	Tue Oct 27 12:49:20 2015
@@ -41,14 +41,16 @@
 	: QDialog( parent ),
 	matchesFound(0)
 {
-	setModal(true);
-	setWindowTitle( tr( "Search/Replace" ) );
-	setWindowIcon(QIcon(loadIcon ( "AppIcon.png" )));
-	ColorList::Iterator it;
 	Item = ite;
 	Doc = doc;
 	NotFound = false;
 	SMode = mode;
+	m_firstMatchPosition = -1;
+
+	setModal(true);
+	setWindowTitle( tr( "Search/Replace" ) );
+	setWindowIcon(QIcon(loadIcon ( "AppIcon.png" )));
+	
 	SearchReplaceLayout = new QVBoxLayout( this );
 	SearchReplaceLayout->setMargin(10);
 	SearchReplaceLayout->setSpacing(5);
@@ -638,6 +640,7 @@
 				AllReplace->setEnabled(true);
 			}
 			matchesFound++;
+			m_firstMatchPosition = storyTextEdit->textCursor().selectionStart();
 		}
 		else
 		{
@@ -799,6 +802,11 @@
 	DoReplace->setEnabled(false);
 	AllReplace->setEnabled(false);
 	slotDoSearch();
+}
+
+int SearchReplace::firstMatchCursorPosition()
+{
+	return m_firstMatchPosition;
 }
 
 void SearchReplace::slotReplaceAll()

Modified: branches/Version14x/Scribus/scribus/search.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20501&path=/branches/Version14x/Scribus/scribus/search.h
==============================================================================
--- branches/Version14x/Scribus/scribus/search.h	(original)
+++ branches/Version14x/Scribus/scribus/search.h	Tue Oct 27 12:49:20 2015
@@ -37,6 +37,7 @@
 	~SearchReplace() {};
 	virtual void slotDoSearch();
 	virtual void slotDoReplace();
+	int firstMatchCursorPosition();
 
 	QLabel* SText1;
 	QLabel* RText1;
@@ -138,6 +139,7 @@
 
 	/// Number of matches found thus far in a search
 	int matchesFound;
+	int m_firstMatchPosition;
 
 };
 

Modified: branches/Version14x/Scribus/scribus/storyeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20501&path=/branches/Version14x/Scribus/scribus/storyeditor.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/storyeditor.cpp	(original)
+++ branches/Version14x/Scribus/scribus/storyeditor.cpp	Tue Oct 27 12:49:20 2015
@@ -1543,8 +1543,8 @@
 	textChanged(false),
 	firstSet(false),
 	blockUpdate(false),
-	CurrPara(0),
-	CurrChar(0),
+//	CurrPara(0),
+//	CurrChar(0),
 	charSelect(NULL),
 	charSelectUsed(false)
 {
@@ -2981,6 +2981,13 @@
 	EditorBar->setRepaint(false);
 	SearchReplace* dia = new SearchReplace(this, currDoc, currItem, false);
 	dia->exec();
+	int pos = dia->firstMatchCursorPosition();
+	if (pos>=0)
+	{
+		QTextCursor tCursor = Editor->textCursor();
+		tCursor.setPosition(pos);
+		Editor->setTextCursor(tCursor);
+	}
 	delete dia;
 	qApp->processEvents();
 	blockUpdate = false;

Modified: branches/Version14x/Scribus/scribus/storyeditor.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20501&path=/branches/Version14x/Scribus/scribus/storyeditor.h
==============================================================================
--- branches/Version14x/Scribus/scribus/storyeditor.h	(original)
+++ branches/Version14x/Scribus/scribus/storyeditor.h	Tue Oct 27 12:49:20 2015
@@ -428,8 +428,8 @@
 	bool firstSet;
 
 	bool blockUpdate;
-	int CurrPara;
-	int CurrChar;
+	//int CurrPara;
+	//int CurrChar;
 
 protected slots:
 	void setBackPref();




More information about the scribus-commit mailing list