KIO::listRecursive() with filters

David Faure faure at kde.org
Thu Oct 29 23:35:46 GMT 2009


On Thursday 09 July 2009, Milian Wolff wrote:
> Hi all!
> 
> I'm one of the guys hacking on KDevelop and ported the generic project
>  manager to KIO to make it work for remote projects (think web projects on
>  some server or similar).
> 
> I decided to use KIO::listRecursive() which works wonderfully. One big sore
> thumb I have with it, is performance. Perse it's wonderful, but users
> might/want/will filter what is considered part of their project. By default
> e.g. I filter hidden files and .svn|.git|CVS folders. One could think of a
>  lot more.
> 
> Right now, I have to filter what KIO::listRecursive() gives me. But this is
> potentially a lot of unwanted stuff since the list job recurses into
>  filtered directories. Hence my sore thumb regarding performance...
> 
> How do you suggest should I fix this? Since listRecursive essentially just
> creates a ListJobPrivate I'd need to change that one. Esp.
>  slotListEntries() if I see it correctly. Thing is: It's private, hence I
>  can't simply overload it...

I can think of two solutions. 
1) The simple one, adding a KIO::ListJob::setExcludedFilenames(const 
QStringList&)

2) The more flexible one, adding a "hook" where the application can define which 
files to exclude. Actually... thanks to Carsten Pfeiffer I have some class
doing this kind of stuff on my harddisk... Attached. Needs to be integrated 
into ListJob and then tested, of course ;)
IIRC he wrote it for kde3, but it was never used anywhere, so it was cleaned 
up for kde4, but I kept a copy for a day like today.

(Note that KDirLister has this kind of functionality already, with a virtual 
bool matchesFilter, but this won't help the fact that the listjob recurses 
into unwanted directories; the dirlister filtering happens after the fact).

In fact, Carsten's idea was to port KDirLister to that KFileFilter class (but 
given the virtual stuff, that's for KDE5 now, I guess). At least this gives a 
good plan ahead: in KDE5 we can use that filter class from both ListJob
and KDirLister (doing it in the listjob isn't enough for the kdirlister use 
case, since it lets the user change the filter at runtime, e.g. when 
showing/hiding dot files in the file dialog, and we don't want to re-list the 
directory at that point, so I think both uses are needed).

Looking forward to your patch that will make KIO::ListJob use KFileFilter :-)

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Sponsored by Nokia to work on KDE, incl. Konqueror (http://www.konqueror.org).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kfilefilter.cpp
Type: text/x-c++src
Size: 3991 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20091030/9c2d6a69/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kfilefilter.h
Type: text/x-chdr
Size: 4770 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20091030/9c2d6a69/attachment.h>


More information about the kde-core-devel mailing list