1. Unicode based (AB...ab) 2. Unicode based, case insensitive (aAbB) 2. Locale based This resolves issue #252. Signed-off-by: Vincent Reher <tde@4reher.org>pull/253/head
parent
d59c8ee79f
commit
d4e06b7696
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef KONQ_SORT_CONSTANTS_H
|
||||||
|
#define KONQ_SORT_CONSTANTS_H
|
||||||
|
|
||||||
|
typedef unsigned short TextSortOrder;
|
||||||
|
// Can't use name 'SortOrder' because that's part of TQt
|
||||||
|
|
||||||
|
enum {
|
||||||
|
UNICODE_UNMODIFIED = 0,
|
||||||
|
LOCALE_UNMODIFIED = 1,
|
||||||
|
UNICODE_CASEINSENSITIVE = 2,
|
||||||
|
} TextSortOrders;
|
||||||
|
|
||||||
|
#endif // KONQ_SORT_CONSTANTS_H
|
@ -0,0 +1,51 @@
|
|||||||
|
#ifndef KONQ_STRING_COMPARE_H
|
||||||
|
#define KONQ_STRING_COMPARE_H
|
||||||
|
|
||||||
|
#include "konq_sort_constants.h"
|
||||||
|
|
||||||
|
static inline int stringCompare(
|
||||||
|
const TextSortOrder sortorder,
|
||||||
|
const TQString& a,
|
||||||
|
const TQString& b
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Our caller probably determined sortorder from KonqPropsView::getSortOrder()
|
||||||
|
// but we have a reasonable fallback position for bogus values.
|
||||||
|
|
||||||
|
switch(sortorder) {
|
||||||
|
|
||||||
|
case UNICODE_UNMODIFIED:
|
||||||
|
/*
|
||||||
|
* Strictly character code(point) numeric comparison as defined
|
||||||
|
* by the Unicode Standard that is backward compatible with the
|
||||||
|
* the ASCII standard.
|
||||||
|
. */
|
||||||
|
return a.compare( b );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UNICODE_CASEINSENSITIVE:
|
||||||
|
/*
|
||||||
|
* This is the traditional "case-insensitive" variation on character
|
||||||
|
* code order that ensures that ASCII lowercase and uppercase alphabetic
|
||||||
|
* characters are are grouped together instead of being separated by
|
||||||
|
* non-alphabetic ASCII characters [ \ ] ^ _ `
|
||||||
|
*/
|
||||||
|
return a.lower().compare( b.lower() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LOCALE_UNMODIFIED:
|
||||||
|
/*
|
||||||
|
* This is the pure locale-aware comparison as defined by ICU.
|
||||||
|
* Note: if LC_COLLATE == 'C' or 'Posix', this will produce same
|
||||||
|
* result as UNICODE_UNMODIFIED.
|
||||||
|
*/
|
||||||
|
return a.localeAwareCompare( b );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: // Treat as UNICODE_UNMODIFIED
|
||||||
|
return a.compare( b );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // KONQ_STRING_COMPARE_H
|
Loading…
Reference in new issue