naturalCompare Qt5 task

Frank Reininghaus frank78ac at googlemail.com
Fri Jul 19 11:27:11 UTC 2013


Hi,

2013/7/19 Aleix Pol:
> Hi,
> I was looking at that task in the Qt5 epics list and I didn't understand it
> fully.
>
> contribute natural-comparison to Qt5 (see KStringHandler). In Qt there is
> naturalCompare function but private and not as good as from KStringHandler.
> Thiago says: add the feature to QCollator.

Could you explain why KStringHandler::naturalCompare() is better than
what QCollator offers?

QCollator has the very nice feature

QByteArray QCollator::sortKey(const QString &string)

which allows to calculate the 'sortKey' for each string once, and then
use these for the sorting. This means that we could sort a large list
of strings with O(N*log(N)) cheap comparisons of QByteArrays, rather
than the same amount of very expensive
KStringHandler::naturalCompare() calls.

At the moment, KStringHandler::naturalCompare() is the major
bottleneck in Dolphin when you open a very large directory. If we
could use QCollator, that problem could be solved quite easily.

Cheers,
Frank


More information about the Kde-frameworks-devel mailing list