Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
collection.c File Reference
#include "common/collection.h"
#include "common/debug.h"
#include "common/colorlabels.h"
#include "common/image.h"
#include "common/imageio_rawspeed.h"
#include "common/metadata.h"
#include "common/utility.h"
#include "common/map_locations.h"
#include "common/datetime.h"
#include "common/selection.h"
#include "control/conf.h"
#include "control/control.h"
#include <assert.h>
#include <glib.h>
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+ Include dependency graph for collection.c:

Macros

#define SELECT_QUERY   "SELECT DISTINCT * FROM %s"
 
#define LIMIT_QUERY   "LIMIT ?1, ?2"
 
#define and_operator_initial()   (0)
 
#define or_operator_initial()   (0)
 

Functions

static int _dt_collection_store (const dt_collection_t *collection, gchar *query)
 
static uint32_t _dt_collection_compute_count (dt_collection_t *collection)
 
static int dt_collection_image_offset_with_collection (const dt_collection_t *collection, int32_t imgid)
 
dt_collection_tdt_collection_new ()
 
void dt_collection_free (const dt_collection_t *collection)
 
const dt_collection_params_tdt_collection_params (const dt_collection_t *collection)
 
static char * and_operator (int *term)
 
static char * or_operator (int *term)
 
void dt_collection_memory_update ()
 
static void _dt_collection_set_selq_pre_sort (const dt_collection_t *collection, char **selq_pre)
 
int dt_collection_update (const dt_collection_t *collection)
 
void dt_collection_reset (const dt_collection_t *collection)
 
const gchar * dt_collection_get_query (const dt_collection_t *collection)
 
dt_collection_filter_flag_t dt_collection_get_filter_flags (const dt_collection_t *collection)
 
void dt_collection_set_filter_flags (const dt_collection_t *collection, dt_collection_filter_flag_t flags)
 
char * dt_collection_get_text_filter (const dt_collection_t *collection)
 
void dt_collection_set_text_filter (const dt_collection_t *collection, char *text_filter)
 
dt_collection_query_flags_t dt_collection_get_query_flags (const dt_collection_t *collection)
 
void dt_collection_set_query_flags (const dt_collection_t *collection, dt_collection_query_flags_t flags)
 
gchar * dt_collection_get_extended_where (const dt_collection_t *collection, int exclude)
 
void dt_collection_set_extended_where (const dt_collection_t *collection, gchar **extended_where)
 
void dt_collection_set_tag_id (dt_collection_t *collection, const uint32_t tagid)
 
void dt_collection_set_sort (const dt_collection_t *collection, dt_collection_sort_t sort, gboolean reverse)
 
dt_collection_sort_t dt_collection_get_sort_field (const dt_collection_t *collection)
 
gboolean dt_collection_get_sort_descending (const dt_collection_t *collection)
 
const char * dt_collection_name (dt_collection_properties_t prop)
 
gchar * dt_collection_get_sort_query (const dt_collection_t *collection)
 
uint32_t dt_collection_get_count (const dt_collection_t *collection)
 
GList * dt_collection_get (const dt_collection_t *collection, int limit)
 
GList * dt_collection_get_all (const dt_collection_t *collection, int limit)
 
int dt_collection_get_nth (const dt_collection_t *collection, int nth)
 
void dt_collection_split_operator_number (const gchar *input, char **number1, char **number2, char **operator)
 
static char * _dt_collection_compute_datetime (const char *operator, const char *input)
 
void dt_collection_split_operator_datetime (const gchar *input, char **number1, char **number2, char **operator)
 
void dt_collection_split_operator_exposure (const gchar *input, char **number1, char **number2, char **operator)
 
void dt_collection_get_makermodels (const gchar *filter, GList **sanitized, GList **exif)
 
gchar * dt_collection_get_makermodel (const char *exif_maker, const char *exif_model)
 
static gchar * get_query_string (const dt_collection_properties_t property, const gchar *text)
 
int dt_collection_serialize (char *buf, int bufsize)
 
void dt_collection_deserialize (const char *buf)
 
static void _update_recentcollections ()
 
void dt_collection_update_query (const dt_collection_t *collection, dt_collection_change_t query_change, dt_collection_properties_t changed_property, GList *list)
 
void dt_pop_collection ()
 
void dt_push_collection ()
 
void dt_selection_to_culling_mode ()
 
void dt_culling_mode_to_selection ()
 
gboolean dt_collection_hint_message_internal (void *message)
 
void dt_collection_hint_message (const dt_collection_t *collection)
 
static void _dt_collection_change_view_after_import (const dt_view_t *current_view, gboolean open_single_image)
 
static gboolean _collection_can_switch_folder (const int32_t imgid, const dt_view_t *current_atelier)
 
void dt_collection_load_filmroll (dt_collection_t *collection, const int32_t imgid, gboolean open_single_image)
 

Macro Definition Documentation

◆ and_operator_initial

#define and_operator_initial ( )    (0)

◆ LIMIT_QUERY

#define LIMIT_QUERY   "LIMIT ?1, ?2"

◆ or_operator_initial

#define or_operator_initial ( )    (0)

◆ SELECT_QUERY

#define SELECT_QUERY   "SELECT DISTINCT * FROM %s"

Function Documentation

◆ _collection_can_switch_folder()

static gboolean _collection_can_switch_folder ( const int32_t  imgid,
const dt_view_t current_atelier 
)
inlinestatic

◆ _dt_collection_change_view_after_import()

static void _dt_collection_change_view_after_import ( const dt_view_t current_view,
gboolean  open_single_image 
)
inlinestatic

◆ _dt_collection_compute_count()

static uint32_t _dt_collection_compute_count ( dt_collection_t collection)
static

◆ _dt_collection_compute_datetime()

static char * _dt_collection_compute_datetime ( const char *  operator,
const char *  input 
)
static

◆ _dt_collection_set_selq_pre_sort()

static void _dt_collection_set_selq_pre_sort ( const dt_collection_t collection,
char **  selq_pre 
)
static

◆ _dt_collection_store()

◆ _update_recentcollections()

◆ and_operator()

static char * and_operator ( int *  term)
static

Referenced by dt_collection_update().

◆ dt_collection_deserialize()

◆ dt_collection_free()

void dt_collection_free ( const dt_collection_t collection)

frees a collection context.

References dt_collection_t::query, and dt_collection_t::where_ext.

Referenced by dt_cleanup().

◆ dt_collection_get()

◆ dt_collection_get_all()

GList * dt_collection_get_all ( const dt_collection_t collection,
int  limit 
)

get all image ids order as current selection. no more than limit many images are returned, <0 == unlimited

References dt_collection_get().

Referenced by _jpg_combobox_changed(), _switch_to_next_picture(), and _switch_to_prev_picture().

◆ dt_collection_get_count()

◆ dt_collection_get_extended_where()

gchar * dt_collection_get_extended_where ( const dt_collection_t collection,
int  exclude 
)

gets an extended where part

References dt_conf_get_int(), dt_util_dstrcat(), and dt_collection_t::where_ext.

Referenced by dt_collection_update(), list_view(), and tree_view().

◆ dt_collection_get_filter_flags()

◆ dt_collection_get_makermodel()

gchar * dt_collection_get_makermodel ( const char *  exif_maker,
const char *  exif_model 
)

get the sanitized makermodel for exif maker/model

References dt_imageio_lookup_makermodel(), maker, and model.

Referenced by dt_collection_get_makermodels(), and list_view().

◆ dt_collection_get_makermodels()

void dt_collection_get_makermodels ( const gchar *  filter,
GList **  sanitized,
GList **  exif 
)

get the filtered map between sanitized makermodel and exif maker/model

References darktable, darktable_t::db, dt_collection_get_makermodel(), dt_database_get(), DT_DEBUG_SQLITE3_PREPARE_V2, FALSE, key, and TRUE.

Referenced by get_query_string().

◆ dt_collection_get_nth()

int dt_collection_get_nth ( const dt_collection_t collection,
int  nth 
)

◆ dt_collection_get_query()

const gchar * dt_collection_get_query ( const dt_collection_t collection)

◆ dt_collection_get_query_flags()

dt_collection_query_flags_t dt_collection_get_query_flags ( const dt_collection_t collection)

get filter flags for collection

References dt_collection_t::params, and dt_collection_params_t::query_flags.

Referenced by dt_collection_update_query().

◆ dt_collection_get_sort_descending()

gboolean dt_collection_get_sort_descending ( const dt_collection_t collection)

get if the collection must be shown in descending order

References dt_collection_params_t::descending, and dt_collection_t::params.

Referenced by gui_init().

◆ dt_collection_get_sort_field()

dt_collection_sort_t dt_collection_get_sort_field ( const dt_collection_t collection)

get the sort field used

References dt_collection_t::params, and dt_collection_params_t::sort.

Referenced by gui_init().

◆ dt_collection_get_sort_query()

◆ dt_collection_get_text_filter()

char * dt_collection_get_text_filter ( const dt_collection_t collection)

get text filter for collection

References dt_collection_t::params, and dt_collection_params_t::text_filter.

Referenced by _text_entry_changed_wait(), and gui_init().

◆ dt_collection_hint_message()

◆ dt_collection_hint_message_internal()

gboolean dt_collection_hint_message_internal ( void message)

◆ dt_collection_image_offset_with_collection()

static int dt_collection_image_offset_with_collection ( const dt_collection_t collection,
int32_t  imgid 
)
static

◆ dt_collection_load_filmroll()

◆ dt_collection_memory_update()

◆ dt_collection_name()

◆ dt_collection_new()

dt_collection_t * dt_collection_new ( )

instantiates a collection context

References dt_collection_reset().

Referenced by dt_init().

◆ dt_collection_params()

const dt_collection_params_t * dt_collection_params ( const dt_collection_t collection)

fetch params for collection for storing.

References dt_collection_t::params.

◆ dt_collection_reset()

◆ dt_collection_serialize()

int dt_collection_serialize ( char *  buf,
int  bufsize 
)

◆ dt_collection_set_extended_where()

void dt_collection_set_extended_where ( const dt_collection_t collection,
gchar **  extended_where 
)

sets an extended where part

References dt_collection_t::where_ext.

Referenced by dt_collection_update_query().

◆ dt_collection_set_filter_flags()

void dt_collection_set_filter_flags ( const dt_collection_t collection,
dt_collection_filter_flag_t  flags 
)

◆ dt_collection_set_query_flags()

void dt_collection_set_query_flags ( const dt_collection_t collection,
dt_collection_query_flags_t  flags 
)

set filter flags for collection

References flags, and dt_collection_t::params.

Referenced by _lib_filter_update_query(), dt_collection_update_query(), and gui_reset().

◆ dt_collection_set_sort()

void dt_collection_set_sort ( const dt_collection_t collection,
dt_collection_sort_t  sort,
gboolean  reverse 
)

◆ dt_collection_set_tag_id()

void dt_collection_set_tag_id ( dt_collection_t collection,
const uint32_t  tagid 
)

set the tagid of collection

References dt_collection_t::tagid.

Referenced by row_activated_with_event().

◆ dt_collection_set_text_filter()

void dt_collection_set_text_filter ( const dt_collection_t collection,
char *  text_filter 
)

set text filter for collection

References dt_collection_t::params.

Referenced by _reset_text_filter(), _text_entry_changed_wait(), and gui_cleanup().

◆ dt_collection_split_operator_datetime()

void dt_collection_split_operator_datetime ( const gchar *  input,
char **  number1,
char **  number2,
char **  operator 
)

◆ dt_collection_split_operator_exposure()

void dt_collection_split_operator_exposure ( const gchar *  input,
char **  number1,
char **  number2,
char **  operator 
)

Referenced by get_query_string().

◆ dt_collection_split_operator_number()

void dt_collection_split_operator_number ( const gchar *  input,
char **  number1,
char **  number2,
char **  operator 
)

◆ dt_collection_update()

int dt_collection_update ( const dt_collection_t collection)

updates sql query for a collection.

Returns
1 if query changed.

References _dt_collection_set_selq_pre_sort(), _dt_collection_store(), and_operator(), COLLECTION_FILTER_0_STAR, COLLECTION_FILTER_1_STAR, COLLECTION_FILTER_2_STAR, COLLECTION_FILTER_3_STAR, COLLECTION_FILTER_4_STAR, COLLECTION_FILTER_5_STAR, COLLECTION_FILTER_ALTERED, COLLECTION_FILTER_BLUE, COLLECTION_FILTER_GREEN, COLLECTION_FILTER_MAGENTA, COLLECTION_FILTER_NONE, COLLECTION_FILTER_RED, COLLECTION_FILTER_REJECTED, COLLECTION_FILTER_UNALTERED, COLLECTION_FILTER_WHITE, COLLECTION_FILTER_YELLOW, COLLECTION_QUERY_USE_LIMIT, COLLECTION_QUERY_USE_ONLY_WHERE_EXT, COLLECTION_QUERY_USE_SORT, COLLECTION_QUERY_USE_WHERE_EXT, dt_collection_get_extended_where(), dt_collection_get_sort_query(), DT_COLLECTION_SORT_COLOR, DT_COLLECTION_SORT_PATH, DT_COLLECTION_SORT_TITLE, DT_COLORLABELS_BLUE, DT_COLORLABELS_GREEN, DT_COLORLABELS_PURPLE, DT_COLORLABELS_RED, DT_COLORLABELS_YELLOW, DT_IMAGE_REJECTED, DT_IMAGE_REMOVE, DT_METADATA_XMP_DC_TITLE, dt_util_dstrcat(), DT_VIEW_DESERT, DT_VIEW_STAR_1, DT_VIEW_STAR_2, DT_VIEW_STAR_3, DT_VIEW_STAR_4, DT_VIEW_STAR_5, dt_collection_params_t::filter_flags, LIMIT_QUERY, or_operator(), or_operator_initial, dt_collection_t::params, dt_collection_params_t::query_flags, dt_collection_params_t::sort, dt_collection_t::tagid, and dt_collection_params_t::text_filter.

Referenced by dt_collection_get_query(), dt_collection_update_query(), dt_control_delete_images_job_run(), and dt_control_remove_images_job_run().

◆ dt_collection_update_query()

void dt_collection_update_query ( const dt_collection_t collection,
dt_collection_change_t  query_change,
dt_collection_properties_t  changed_property,
GList *  list 
)

update query by conf vars

References _update_recentcollections(), COLLECTION_QUERY_USE_WHERE_EXT, darktable, darktable_t::db, dt_collection_get_query_flags(), dt_collection_memory_update(), dt_collection_set_extended_where(), dt_collection_set_query_flags(), dt_collection_update(), dt_conf_get_int(), dt_conf_get_string(), dt_database_get(), DT_DEBUG_CONTROL_SIGNAL_RAISE, DT_DEBUG_SQLITE3_PREPARE_V2, DT_SIGNAL_COLLECTION_CHANGED, dt_util_dstrcat(), get_query_string(), and darktable_t::signals.

Referenced by _control_import_job_run(), _culling_mode(), _film_import1(), _generic_dt_control_fileop_images_job_run(), _image_duplicate_with_version(), _lib_duplicate_delete(), _lib_filter_update_query(), _menuitem_preferences(), _refresh_collection_callback(), _reset_text_entry(), collapse_grouped_callback(), combo_changed(), dt_collection_deserialize(), dt_collection_load_filmroll(), dt_collection_reset(), dt_control_delete_images_job_run(), dt_control_duplicate_images_job_run(), dt_control_local_copy_images_job_run(), dt_control_merge_hdr_job_run(), dt_control_monochrome_images_job_run(), dt_control_refresh_exif_run(), dt_control_remove_images_job_run(), dt_film_set_query(), dt_image_copy_rename(), dt_image_read_duplicates(), enter(), entry_activated(), geotag_changed(), group_images_callback(), gui_reset(), import_images(), menuitem_clear(), menuitem_mode(), menuitem_mode_change(), metadata_changed(), preferences_changed(), row_activated_with_event(), set_params(), tag_changed(), and ungroup_images_callback().

◆ dt_culling_mode_to_selection()

void dt_culling_mode_to_selection ( )

restore initial collection and selection when exiting culling mode

References darktable, dt_pop_collection(), dt_selection_pop(), and darktable_t::selection.

Referenced by _culling_mode(), dt_cleanup(), and dt_collection_memory_update().

◆ dt_pop_collection()

◆ dt_push_collection()

void dt_push_collection ( )

◆ dt_selection_to_culling_mode()

void dt_selection_to_culling_mode ( )

◆ get_query_string()

◆ or_operator()

static char * or_operator ( int *  term)
static

Referenced by dt_collection_update().