Skip to content

Fix "Open Containing Folder"/item highlighting through DBus

Felix Ernst requested to merge felixernst/dolphin:highlight_through_dbus into master

Steps to reproduce the bug fixed with this MR

  1. Open Dolphin at home in icon view mode
  2. Search in KFind for an item that is in a sub-sub-folder of the home directory e.g. home/kde/src
  3. Use "Open Containing Folder" on the home/kde/src in KFind
  4. Nothing happens without this MR applied. With this MR, a new tab will be opened that shows home/kde/src

So this fixes the reason #33 (closed) was created,


Technical explanation of the fix

Before this commit, even items that are distant children of currently open views were considered selectable. This lead to the bug that items meant to be highlighted through DBus would not be highlighted if any ancestor of the item was open in any view.

This was fixed by only considering items in view if they can be seen by scrolling. Main difficulty here was to make this also work for the details view mode which allows expanding.

Refactorings

To implement this cleanly, some refactoring seemed necessary because the logic to determine if an item is already in view was previously intertwined with the logic to identify already open directories.

This commit contains the following refactorings aiming to make the code more readable:

  • A magic value (-1) is replaced using std::optional.
  • A boolean trap is removed.
  • A QPair is replaced by a struct with named variables.
  • More and improved documentation
Edited by Felix Ernst

Merge request reports