Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
4.7.2
-
None
Description
QStandardItem's operator < sorts numerically for numeric types, but alphabetically (via QString::compare) for textual types. This means that numeric items will sort
{1, 2, 10, 20}however textual items will sort
{"1", "10", "2", "20"}.
All modern GUIs use "natural sort" (http://www.codinghorror.com/blog/2007/12/sorting-for-humans-natural-sort-order.html) for lists of text-containing-numbers, however QStandardItem's default behaviour makes QTreeView (and similar views) look incorrect.
QStandardItem should use a natural sort when comparing textual items, and ideally QString would expose this as an improved compare() interface.
This could be done by replacing Qt::CaseSensitivity with a more general bitfield which could support:
- Case sensitivity
- Natural sort order
- Locale aware
Combinations that didn't make sense could trip an assert in debug builds, however this would prevent the need to add a new 'naturalCompare' on top of 'compare' and 'localeAwareCompare'.