In Gwenview sorting is implemented in SortedDirModel::lessThan, which
relies on setting the correct sort column to sort by different criteria
when calling sort in BrowseMainPage::updateSortOrder. In
gwenviewrc and in View → Sort By the Sorting enum is used,
while SortedDirModel has KDirModel::ModelColumns.
Previously mapping between both enums was done implicitly, which
worked because both order and position of the entries matched. However,
this had some caveats:
- Changes to KDirModel could invalidate Gwenview's configuration file, since the mapping might fail afterwards.
- Adding another sort criterion like Rating in D13344 would result in it mapping to the KDirModel::Permissions column, which could lead to surprising sorting results.
By making the mapping explicit and also providing a way to set a sort
role, both potential issues can be avoided.