Make determining the mime type faster for directories
Review Request #111830 - Created Aug. 1, 2013 and submitted
Christoph noted in https://bugs.kde.org/show_bug.cgi?id=321710#c2 that "Sort by Type" sometimes does not work perfectly even in directories with a rather small number of sub-directories inside. I think that this is because we always call KFileItem::determineMimeType() before getting the type, which also tries to load the .directory files inside the directories to load the icon. We could improve this by not calling KFileItem::determineMimeType() for directories, but assign the type based on what KFileItem::isDir() returns. The "folder" mime type could be cached in a static QString, such that we only have to do the expensive things once for directories before the sorting can begin. Christoph, it would be nice if you could test it!
Seems to work nicely for me.
Review request changed
Updated the patch according to Emmanuel's suggestions. I'll push it to KDE/4.11 because it's not extremely intrusive, and it makes the "Sort by Type" experience much better in directories with many sub-folders.
Revision 2 (+12 -1)