[PATCH] naturalCompare case sensitivity (and QString limitation)

Aurélien Gâteau aurelien.gateau at free.fr
Fri Apr 4 13:56:43 BST 2008


Hello,

Some time ago, I was pointed out by Oswald Buddenhagen that using 
QString::toLower() to implement case insensitive sorting with 
KCategorizedSortFilterProxyModel::naturalCompare() was highly suboptimal 
and it would be better to add a Qt::CaseSensitivity parameter to this 
function.

We also agreed that KCategorizedSortFilterProxyModel was not the ideal 
place for this function, KStringHandler would be more suitable.

I finally had a look at this today, but hit a wall: naturalCompare() 
uses QString::localeAwareCompare(), which does not accept a 
Qt::CaseSensitivity parameter. Nevertheless I send attached patch to the 
list for review. The patch does two things:
- It moves naturalCompare() to KStringHandler and marks 
KCategorizedSortFilterProxyModel::naturalCompare() as deprecated
- As suggested by Peter Penz, it adds a Qt::CaseSensitivity parameter to 
KStringHandler, which is internally implemented using 
QString::toLower(), but now the API is ready for a more optimized 
version whenever Qt allows that.

What do you think about this? Is it ok to commit?

Aurélien
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kstringhandler_naturalcompare.diff
Type: text/x-diff
Size: 11480 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080404/87cb8bc0/attachment.diff>


More information about the kde-core-devel mailing list