Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
selection.h File Reference
#include <glib.h>
#include <inttypes.h>
#include "common/debug.h"
+ Include dependency graph for selection.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define dt_selection_reload_from_database(selection)   DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_SQL, dt_selection_reload_from_database_real, (selection))
 

Functions

struct dt_selection_tdt_selection_new ()
 
void dt_selection_free (struct dt_selection_t *selection)
 
int32_t dt_selection_get_first_id (struct dt_selection_t *selection)
 
void dt_selection_clear (struct dt_selection_t *selection)
 
void dt_selection_select (struct dt_selection_t *selection, int32_t imgid)
 
void dt_selection_deselect (struct dt_selection_t *selection, int32_t imgid)
 
void dt_selection_select_single (struct dt_selection_t *selection, int32_t imgid)
 
void dt_selection_toggle (struct dt_selection_t *selection, int32_t imgid)
 
void dt_selection_select_list (struct dt_selection_t *selection, const GList *list)
 
void dt_selection_deselect_list (struct dt_selection_t *selection, const GList *list)
 
GList * dt_selection_get_list (struct dt_selection_t *selection)
 
void dt_selection_push (struct dt_selection_t *selection)
 
void dt_selection_pop (struct dt_selection_t *selection)
 
int dt_selection_get_length (struct dt_selection_t *selection)
 
gchar * dt_selection_ids_to_string (struct dt_selection_t *selection)
 
gboolean dt_selection_is_id_selected (struct dt_selection_t *selection, int32_t imgid)
 
void dt_selection_reload_from_database_real (struct dt_selection_t *selection)
 

Detailed Description

The old design built selections from collections, through SQL, to ensure selections were always a subset of collections. That didn't work well with the GUI option to show/hide grouped images, because then, every SQL query needed to be modified according to a GUI parameter, which was complicated, hard to debug, tiring to maintain.

Collections now are immune to GUI parameters. It is in the thumbtable that we decide to show/hide the thumbnail widgets of grouped images, and collections contain all of them. In order to select grouped images depending on whether they are shown or not, it is also from the thumbtable that batch selection events need to be dispatched, using visible images. It is assumed that users expect selections to include everything visible but only what's visible and nothing more.

Because the thumbtable is populated from collections, we know it contains only valid imgid, and contains at most the whole current collection. So we can safely assume any imgid coming from the thumbtable is a valid image ID with regard to the current collection, without additional checks.

We synchronize here 2 representations of the selections:

  • a memory DB table: memory.selected_images, that is saved to be restored between reboots,
  • a GList of imgid, selection->ids, cached, that allows us direct access from C loops.

Selections subscribe to the COLLECTION_CHANGED signal to ensure the selected imgids are a subset of the current collection at all time. But that doesn't deal with images that might be hidden from GUI, for example image group members.

It is up to the thumbtable code (aka GUI) to resync selection imgids with visible widgets.

No insertions or deletions should be made into the main.selected_images database table, outside of selection.c. Interactions with selections should use the public API here.

SELECT imgid FROM main.seleted_images should be reserved to SQL JOIN, when fetching metadata from DB for the list of IDs. All other cases should iterate over the GList of imgids returned by dt_selection_get_list()

Macro Definition Documentation

◆ dt_selection_reload_from_database

#define dt_selection_reload_from_database (   selection)    DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_SQL, dt_selection_reload_from_database_real, (selection))

Function Documentation

◆ dt_selection_clear()

◆ dt_selection_deselect()

void dt_selection_deselect ( struct dt_selection_t selection,
int32_t  imgid 
)

removes a single imgid from the current selection. use the optimized dt_selection_deselect_list() to process batches.

References _remove_id_link(), _selection_deselect(), _update_gui(), and UNKNOWN_IMAGE.

Referenced by _dt_collection_lut(), and dt_selection_toggle().

◆ dt_selection_deselect_list()

void dt_selection_deselect_list ( struct dt_selection_t selection,
const GList *  list 
)

deselects a set of images from a list in a fast, optimized fashion. the list is unaltered

References _list_iterate(), _update_gui(), darktable, darktable_t::db, dt_database_get(), DT_DEBUG_SQLITE3_EXEC, dt_util_dstrcat(), and FALSE.

Referenced by dt_thumbtable_invert_selection().

◆ dt_selection_free()

◆ dt_selection_get_first_id()

◆ dt_selection_get_length()

◆ dt_selection_get_list()

◆ dt_selection_ids_to_string()

gchar * dt_selection_ids_to_string ( struct dt_selection_t selection)

concatenate all image ids from the selection as a string, separated with coma, for SQL queries

References dt_selection_t::ids, and dt_selection_t::length.

Referenced by _concatenate_multiple_images(), _tag_get_tags(), _update(), and dt_tag_get_attached().

◆ dt_selection_is_id_selected()

gboolean dt_selection_is_id_selected ( struct dt_selection_t selection,
int32_t  imgid 
)

see if the imgid is known from the selection

References FALSE, and dt_selection_t::ids.

Referenced by _add_thumbnail_at_rowid(), _dt_selection_changed_callback(), and dt_thumbnail_new().

◆ dt_selection_new()

◆ dt_selection_pop()

void dt_selection_pop ( struct dt_selection_t selection)

◆ dt_selection_push()

void dt_selection_push ( struct dt_selection_t selection)

◆ dt_selection_reload_from_database_real()

void dt_selection_reload_from_database_real ( struct dt_selection_t selection)

call this right after the selection got changed directly in memory database, to resync the GList representation of the selection

References _reset_ids_list(), _selection_database_to_glist(), _update_last_ids(), dt_selection_t::ids, and dt_selection_t::length.

◆ dt_selection_select()

void dt_selection_select ( struct dt_selection_t selection,
int32_t  imgid 
)

adds a single imgid to the current selection. use the optimized dt_selection_select_list() to process batches.

References _add_id_link(), _selection_select(), _update_gui(), and UNKNOWN_IMAGE.

Referenced by dt_collection_load_filmroll(), dt_selection_select_single(), and dt_selection_toggle().

◆ dt_selection_select_list()

void dt_selection_select_list ( struct dt_selection_t selection,
const GList *  list 
)

selects a set of images from a list in a fast, optimized fashion. the list is unaltered

References _list_iterate(), _update_gui(), darktable, darktable_t::db, dt_database_get(), DT_DEBUG_SQLITE3_EXEC, dt_util_dstrcat(), and TRUE.

Referenced by _selection_cb(), dt_thumbtable_select_all(), and dt_thumbtable_select_range().

◆ dt_selection_select_single()

void dt_selection_select_single ( struct dt_selection_t selection,
int32_t  imgid 
)

clears current selection and adds a single imgid

References dt_selection_clear(), dt_selection_select(), and UNKNOWN_IMAGE.

Referenced by _event_main_release(), _film_strip_activated(), dt_thumbtable_key_pressed_grid(), and leave().

◆ dt_selection_toggle()

void dt_selection_toggle ( struct dt_selection_t selection,
int32_t  imgid 
)

toggles selection of a single image in the current selection

References dt_selection_deselect(), dt_selection_select(), dt_selection_t::ids, and UNKNOWN_IMAGE.

Referenced by _event_main_release(), and dt_thumbtable_key_pressed_grid().