diff options
author | Vincent Reher <[email protected]> | 2022-03-05 15:14:32 -0800 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2022-07-02 16:02:09 +0900 |
commit | d4e06b76962198eb64e6c2826d4695248102037c (patch) | |
tree | 2ab32e02df377eb96cc5ba0dc04729ae61c047e9 /libkonq/konq_string_compare.h | |
parent | d59c8ee79f91d41d0979bd09c5e50cc43916330c (diff) | |
download | tdebase-d4e06b76962198eb64e6c2826d4695248102037c.tar.gz tdebase-d4e06b76962198eb64e6c2826d4695248102037c.zip |
Replace listview's binary "Case Insensitive Sort" option with 3 mutually exclusive options:
1. Unicode based (AB...ab)
2. Unicode based, case insensitive (aAbB)
2. Locale based
This resolves issue #252.
Signed-off-by: Vincent Reher <[email protected]>
Diffstat (limited to 'libkonq/konq_string_compare.h')
-rw-r--r-- | libkonq/konq_string_compare.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/libkonq/konq_string_compare.h b/libkonq/konq_string_compare.h new file mode 100644 index 000000000..8d17d409f --- /dev/null +++ b/libkonq/konq_string_compare.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 |