Version: (using KDE KDE 3.0.7) Installed from: Compiled From Sources I think the default behaviour of kfind isn't really well thought. For example, if you have a file that you remember contains the word "project", just typing "project" in kfind's text field will return files strictly named "project". First, the default option should NOT be case sensitive because you often don't remember whether the file you search for has capital letters or not. Then, the default behaviour should be to search for "project", "*project", "project*" and "*project*" automatically because if you don't know how to use regular expressions, you have to search for those 4 possibilities in order to find a file whose name contains "project". I think that's the way Windows works and that's IMO the good way to go.
Me too! I think the ideal would be to make it like the Kate find dialog. By default it would find filenames containing the text entered. However there would also be a regular expression option with a button to use the graphical regular expression editor.
Created attachment 953 [details] patch for search behaviour With the patch, the search will be sloppy (i.e. find 'patch.diff' if 'patch' is the search-word) and do an exact match if a wildcard is used (i.e. does not find 'patch.diff' if '*patch' is the search-word). Since this wish pops up every now and again I think this patch should be applied, thanks. This version of the patch is pretty runtime efficient since it caches the information wether a search pattern contains a wildcard.
Subject: kdebase/kfind CVS commit by kalass: CCMAIL: 48009-done@bugs.kde.org better default search behaviour, approved by the kfind maintainer Eric Coquelle M +15 -8 kquery.cpp 1.16 M +1 -0 kquery.h 1.8 --- kdebase/kfind/kquery.cpp #1.15:1.16 @@ -75,10 +75,10 @@ void KQuery::slotListEntries( KIO::Job * bool matched=false; - - for ( filename_match = m_regexps.first(); !matched && filename_match; filename_match = m_regexps.next() ) + QValueList<bool>::iterator m_regexpsContainsGlobsIterator = m_regexpsContainsGlobs.begin(); + for ( filename_match = m_regexps.first(); !matched && filename_match && m_regexpsContainsGlobsIterator != m_regexpsContainsGlobs.end(); filename_match = m_regexps.next(), m_regexpsContainsGlobsIterator++ ) { - - matched |= filename_match->isEmpty() || - (filename_match->exactMatch( file->url().fileName( true ) ) ); + matched = (*m_regexpsContainsGlobsIterator) + ? filename_match->exactMatch( file->url().fileName( true ) ) + : filename_match->search(file->url().fileName( true )) > -1; } if (!matched) @@ -276,9 +276,16 @@ void KQuery::setGroupname(QString groupn void KQuery::setRegExp(const QString ®exp, bool caseSensitive) { + QRegExp *regExp; QRegExp sep(";"); QStringList strList=QStringList::split( sep, regexp, false); + QRegExp globChars ("[\\*\\?\\[\\]]", TRUE, FALSE); + m_regexps.clear(); - for ( QStringList::Iterator it = strList.begin(); it != strList.end(); ++it ) - m_regexps.append(new QRegExp((*it),caseSensitive,true)); + m_regexpsContainsGlobs.clear(); + for ( QStringList::Iterator it = strList.begin(); it != strList.end(); ++it ) { + regExp = new QRegExp((*it),caseSensitive,true); + m_regexpsContainsGlobs.append(regExp->pattern().contains(globChars)); + m_regexps.append(regExp); + } } --- kdebase/kfind/kquery.h #1.7:1.8 @@ -65,4 +65,5 @@ class KQuery : public QObject bool m_regexpForContent; QPtrList<QRegExp> m_regexps;// regexps for file name + QValueList<bool> m_regexpsContainsGlobs; KIO::ListJob *job; };