Skip to content

Separate criteria for grouping and sorting (like Explorer and Finder do)

Overview

This MR decouples grouping criteria from sorting criteria and makes groups usable for secondary sorting, like in Windows Explorer or macOS Finder. I see it as a fix for BUG: 416134

Screenshots image
Group by modified, group order applicable Screenshot_20240617_110318
Grouping follows sorting, group order not applicable Screenshot_20240617_110346
Video explanation (mic on) 8mb.video-8kT-g1et8dt6

Some implementation details

  • No changes to visual representation of groups, as it is already usable for this feature.

  • New "Group by" context menu with actions, slots, signals, etc. matching "Sort by" when applicable.

  • Grouping is handled separately from sorting, but in many cases grouping-related actions also trigger sorting-related actions by design (because resorting also has to happen)

  • Two-level sort (grouping criteria -> sorting criteria) is implemented in existing KFileItemModel::lessThan method with a second comparator.

  • Code called from KFileItemModel::groups is reused. Group assignment is a single-threaded action while sorting is multi-threaded, so code is modified to fix some nasty bugs.

  • All sorting criteria are also supported for grouping. Two options (1. "No grouping", which is the default, and 2. "Follow sorting") are included to 1. disable grouping and 2. replicate old Dolphin behavior of "Grouped sorting" enabled.

Bugs and TODO

  • Sometimes group headers do not update when they are changed until they are scrolled out of view and back. A visual bug

  • First Dolphin startup (no config) not tested thoroughly.

  • No unit tests yet.

This is my first attempt to contribute to Dolphin and I welcome any kind of review. If you consider this MR promising, share what I need to finally polish this thing up.

Edited by Zakhar Afonin

Merge request reports

Loading