Summary: | search should be smarter | ||
---|---|---|---|
Product: | [Applications] kfind | Reporter: | julo |
Component: | general | Assignee: | Eric Coquelle <coquelle> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: | patch for search behaviour |
Description
julo
2002-09-18 11:23:31 UTC
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; }; |