![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
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)) |
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:
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()
#define dt_selection_reload_from_database | ( | selection | ) | DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_SQL, dt_selection_reload_from_database_real, (selection)) |
void dt_selection_clear | ( | struct dt_selection_t * | selection | ) |
clears the selection
References _reset_ids_list(), _update_gui(), darktable, darktable_t::db, dt_database_get(), and DT_DEBUG_SQLITE3_EXEC.
Referenced by _selection_cb(), clear_selection_callback(), dt_image_read_duplicates(), dt_selection_select_single(), dt_selection_to_culling_mode(), enter(), and view_popup_menu_onRemove().
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().
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().
void dt_selection_free | ( | struct dt_selection_t * | selection | ) |
References _selection_update_collection(), darktable, DT_DEBUG_CONTROL_SIGNAL_DISCONNECT, dt_selection_t::ids, and darktable_t::signals.
Referenced by dt_cleanup().
int32_t dt_selection_get_first_id | ( | struct dt_selection_t * | selection | ) |
Get the first imgid of a selection
References dt_selection_t::last_single_id.
Referenced by _culling_mode(), _metadata_view_update_values(), copy_callback(), copy_parts_callback(), dt_act_on_get_first_image(), dt_thumbtable_key_pressed_grid(), dt_thumbtable_scroll_to_selection(), enter(), and try_enter().
int dt_selection_get_length | ( | struct dt_selection_t * | selection | ) |
get the length of the current selection (number of items)
References dt_selection_t::ids, and dt_selection_t::length.
Referenced by _init_treeview(), _metadata_view_update_values(), clear_selection_sensitive_callback(), copy_callback(), copy_parts_callback(), dt_act_on_get_first_image(), dt_act_on_get_images(), dt_act_on_get_images_nb(), dt_collection_hint_message(), dt_tag_get_attached(), dt_tag_get_suggestions(), dt_tag_get_with_usage(), has_selection(), preload_image_cache(), select_all_sensitive_callback(), and try_enter().
GList * dt_selection_get_list | ( | struct dt_selection_t * | selection | ) |
get the list of selected images. Warning: returns a copy, the caller owns it and needs to free it.
References dt_selection_t::ids.
Referenced by _new_button_clicked(), _selection_cb(), _write_metadata(), clear_image_cache(), copy_callback(), copy_parts_callback(), dt_act_on_get_images(), dt_collection_hint_message(), dt_thumbtable_invert_selection(), dt_thumbtable_select_range(), load_xmp_callback(), paste_all_callback(), paste_parts_callback(), and preload_image_cache().
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().
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().
struct dt_selection_t * dt_selection_new | ( | ) |
References _selection_update_collection(), darktable, DT_DEBUG_CONTROL_SIGNAL_CONNECT, dt_selection_reload_from_database, DT_SIGNAL_COLLECTION_CHANGED, and darktable_t::signals.
Referenced by dt_init().
void dt_selection_pop | ( | struct dt_selection_t * | selection | ) |
restore the previous selection from a temp memory database table
References _update_gui(), darktable, darktable_t::db, dt_database_get(), DT_DEBUG_SQLITE3_EXEC, dt_selection_reload_from_database, FALSE, darktable_t::gui, and dt_gui_gtk_t::selection_stacked.
Referenced by dt_culling_mode_to_selection().
void dt_selection_push | ( | struct dt_selection_t * | selection | ) |
backup the current selection to a temp memory database table
References _update_gui(), darktable, darktable_t::db, dt_database_get(), DT_DEBUG_SQLITE3_EXEC, dt_selection_reload_from_database, darktable_t::gui, dt_gui_gtk_t::selection_stacked, and TRUE.
Referenced by dt_selection_to_culling_mode().
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.
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().
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().
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().
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().