file name wildcard match

Erik Sjölund erik.sjolund at home.se
Tue Apr 9 23:01:27 BST 2002


I installed konqueror from the KDE_3_0_BRANCH cvstag.

If I write /home/erik/*wav in the urlbar
no directories are hidden by the filter,
just file names not having the substring wav 
are hidden.

For example foobar.wav.ews is shown.

This was a bit of a surprise to me as
I expected a shell like behaviour that 
you have on the command line. 

Looking at the kdelibs/kio/kio/kdirlister.cpp
I recognized that a QRegExp::search was done.
Changing that to QRegExp::exactMatch seems
to hide just the file names ending with
wav. 
And then I looked at the directory exception
to file name globbering. I think it's more 
straightforward to treat directory names the 
same way as ordinary file names. So I also 
tried to find that place in the source 
code and make a little change (see attachment). 
But I am really new to this code so I don't 
have an overview of how such changes affect 
other things.

just some thoughts,

Erik Sjölund


-------------- next part --------------
--- kdirlister.cpp.original	Tue Apr  9 15:59:16 2002
+++ kdirlister.cpp	Tue Apr  9 16:01:15 2002
@@ -1710,7 +1710,7 @@
   if ( !d->isShowingDotFiles && item->text()[0] == '.' )
     return false;
 
-  if ( item->isDir() || d->lstFilters.isEmpty() )
+  if ( d->lstFilters.isEmpty() )
     return true;
 
   return matchesFilter( item->text() );
@@ -1725,7 +1725,7 @@
 bool KDirLister::doNameFilter( const QString& name, const QPtrList<QRegExp>& filters ) const
 {
   for ( QPtrListIterator<QRegExp> it( filters ); it.current(); ++it )
-    if ( it.current()->search( name ) != -1 )
+    if ( it.current()->exactMatch( name ) )
       return true;
 
   return false;


More information about the kfm-devel mailing list