searchText implementation in QEditorPart

Ahn, Duk J. adjj22 at kornet.net
Sun Feb 1 08:55:08 UTC 2004


I implemented searchText( uint, uint, QString, ...... )

Try to apply this patch to the 
(top build dir)/editors/qeditor/qeditor_part.cpp file

I tested it with many situation and it doesn't have any problem.
See the attachment file.

--- qeditor_part.cpp.orig	2004-02-01 16:44:48.000000000 +0900
+++ qeditor_part.cpp	2004-02-01 16:21:47.000000000 +0900
@@ -607,6 +607,7 @@
                               const QString &text, unsigned int *foundAtLine, 
unsigned int *foundAtCol,
                               unsigned int *matchLen, bool casesensitive, 
bool backwards )
 {
+	/*
     Q_UNUSED( startLine );
     Q_UNUSED( startCol );
     Q_UNUSED( text );
@@ -615,10 +616,66 @@
     Q_UNUSED( matchLen );
     Q_UNUSED( casesensitive );
     Q_UNUSED( backwards );
-
-#warning "TODO: QEditorPart::searchText()"
-    kdDebug(9032) << "TODO: QEditorPart::searchText()" << endl;
-    return false;
+	*/
+	if( text.isEmpty() ){
+		return false;
+	}
+
+	unsigned int tmpline = startLine;
+	int foundCol;
+	QString oneline;
+	bool firstTestedLine=true;
+
+	if( !backwards ){
+		while( tmpline <= numLines() ){
+			//int oneLineLen = lineLength( tmpline-1 );
+			oneline = textLine( tmpline );
+			kdDebug()<<oneline<<endl;
+
+			// test one line by one line
+			if( firstTestedLine ){
+				int index = (int)startCol;
+				foundCol = oneline.find( text, index, casesensitive );
+				firstTestedLine = false;
+			}else{
+				foundCol = oneline.find( text, 0, casesensitive );
+			}
+			//case of found..
+			if( foundCol != -1 ){
+				(*foundAtLine) = tmpline;
+				(*foundAtCol) = foundCol;
+				(*matchLen) = text.length();
+				return true;
+			}
+			//case of not found..
+			tmpline++;
+		}
+
+		return false;
+
+	}else{
+		while( tmpline != 0 ){
+			oneline = textLine( tmpline );
+			kdDebug()<<oneline<<endl;
+			if( firstTestedLine ){
+				int index = (int)startCol;
+				foundCol = oneline.findRev( text, index, casesensitive );
+				firstTestedLine = false;
+			}else{
+				foundCol = oneline.findRev( text, -1, casesensitive );
+			}
+
+			// case of found..
+			if( foundCol != -1 ){
+				(*foundAtLine) = tmpline;
+				(*foundAtCol) = foundCol;
+				(*matchLen) = text.length();
+				return true;
+			}
+			tmpline--;
+		}
+		return false;
+	}
 }
 
 bool QEditorPart::searchText (unsigned int startLine, unsigned int startCol,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qeditor_part.cpp-searchText.diff
Type: text/x-diff
Size: 2099 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20040201/82216b36/attachment.bin>


More information about the KDevelop-devel mailing list