[kio] Imported the filenamesearch ioslave from Dolphin
Review Request #120460 - Created Oct. 2, 2014 and submitted
The filenamesearch ioslave lists all files/folders which match with the given search query.
Made some small adjustments:
Ported the ioslave to Qt5/KF5
Got rid of cleanup() and member variables
Use lambda function validators instead of some weird if + assert things in searchDirectory/contentContainsPattern
Immediately return when the search string is empty
OK this wasn't too long, I reviewed it directly. It's even better, I can complain about all the non-satisfactory code, whether it was just ported or it was that way already :-)
item.text() would probably be better, for these special cases where text != name (name is internal, text is what the user sees in a directory listing)
Can this url parameter be a local path?
With its name I would expect a full URL - in which case QUrl(...) should be enough.
No, this should be toLocalFile()
(it makes a difference on Windows)
Wow, won't this be really slow? which "remote" protocols is it typically used with? Any? Well, if it's an explicit request from the user I guess that's OK...
This code is keeping the filename of a file that is about to be deleted (by the QTemporaryFile destructor). So the reading will fail for sure. Sounds like this wasn't properly tested :-)
For small files, KIO::get would even be better (contents in memory). But OK, if the files can be huge, I guess a tempfile is better.
One easy solution is to move the QTemporaryFile to the method scope, so it keeps existing until the end of the method. Given that the ctor doesn't do much (only assembling the tempfile template name) the performance penalty would probably be not too bad. Alternatively, move the QFile+QTextStream code to a helper function and call it in each of the two cases (local or remote) separately. Would be better for performance.