Skip to content

Improvements to collection navigation.#21398

Open
masterpiga wants to merge 1 commit into
darktable-org:masterfrom
masterpiga:filmroll
Open

Improvements to collection navigation.#21398
masterpiga wants to merge 1 commit into
darktable-org:masterfrom
masterpiga:filmroll

Conversation

@masterpiga

Copy link
Copy Markdown
Collaborator

TL;DR

The collections module previously discarded your current selection in several situations, forcing you to re-navigate the film roll/folder tree from the root. This PR makes the selection stable across two scenarios:

  1. Switching between the film roll and folders views now carries the current selection over.
  2. Moving / deleting / erasing images no longer collapses the selector back to the tree root when the selected film roll or folder is affected.

All changes are contained in src/libs/collect.c.

Screen.Recording.2026-06-22.at.20.42.59.mp4

Motivation

Both the film roll and folders collection rules store the full folder path as their value, and for an exact path they build the identical query (film_id IN (SELECT id FROM film_rolls WHERE folder LIKE '<path>')). Despite this, switching the combobox between the two views cleared the entry, throwing away the selection. Likewise, after a filesystem operation that emptied (and thus removed) the selected film roll, the stored path matched nothing on rebuild, so the tree collapsed to the root and the lighttable went blank — you had to find your way back manually.

The unifying principle: changing modality, or operating on files, should keep you where you were — or as close to it as still exists.

What changed

1. Film roll ⇄ folders view switch (combo_changed)

  • Film roll → folders: the path is kept verbatim. Because both produce the same exact-match query, the displayed collection is unchanged and the folders tree opens directly at the film roll's directory.
  • Folders → film roll: the folder is resolved to the closest film roll. If there's no 1:1 mapping, it falls back to the nearest containing (ancestor) film roll, then the nearest contained (descendant) one — so you land near where you were instead of at the root.

2. Selection stability across move/delete/erase (collection_updated)

A new _fixup_stale_selection() runs before the tree is rebuilt:

  • If the selected film roll/folder still exists, nothing changes (folders survive as long as any film roll lives at or under them).
  • If it was removed by the operation, the rule is repointed to the closest survivor using the same exact → nearest-containing → nearest-contained criteria, respecting the active view (a folder path in folders view, a film roll in film roll view). The collection query is then re-run so the lighttable follows the new selection.

Supporting helpers added:

  • _filmroll_for_folder() — resolves a path to the best-matching film roll (exact → ancestor → descendant).
  • _folder_exists() — checks whether a folder node still backs any film roll.
  • _folder_plain_path() — strips folders-collection suffixes (*, |%, trailing separator/%) to recover a plain path; shared by the view-switch and fixup logic.

Scope

When you move all images out of the current collection, darktable already intentionally jumps the collection to the destination folder (control_jobs.c, dt_collection_deserialize). That happens before the fixup, so this PR leaves that long-standing behavior intact rather than redirecting to the "closest to source." All other cases (delete, erase, remove-from-library, and moves where the source film roll survives) are covered.

Co-authored with Claude.

@masterpiga masterpiga added this to the 5.8 milestone Jun 22, 2026
@masterpiga masterpiga added feature: enhancement current features to improve difficulty: trivial some changes in a couple of functions scope: UI user interface and interactions labels Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

difficulty: trivial some changes in a couple of functions feature: enhancement current features to improve scope: UI user interface and interactions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant