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

Go to the source code of this file.

Data Structures

struct  dt_iop_name_row_t
 One module's identity, for the rule that searches by module name. More...
 
struct  dt_collection_values_request_t
 

Typedefs

typedef int(* dt_collection_query_order_resolver_t) (const char *text)
 
typedef struct dt_iop_name_row_t dt_iop_name_row_t
 One module's identity, for the rule that searches by module name.
 
typedef struct dt_collection_values_request_t dt_collection_values_request_t
 

Functions

void dt_collection_query_set_order_resolver (dt_collection_query_order_resolver_t fn)
 
void dt_collection_query_set_order_names (const char *const *names, const int count)
 
int dt_collection_query_set_rules (const dt_collection_params_t *params, const dt_collection_rule_t *rules, const int n_rules, const uint32_t tagid)
 
int dt_collection_query_recompose (void)
 
void dt_collection_query_refresh_memory_table (void)
 
uint32_t dt_collection_query_count (void)
 
uint64_t dt_collection_query_get_generation (void)
 
void dt_collection_query_set_iop_names (const dt_iop_name_row_t *rows, const size_t count)
 Fill memory.darktable_iop_names, the table the module-name rules join against.
 
GListdt_collection_query_get_images (const uint32_t limit)
 
int32_t dt_collection_query_get_nth (const int nth)
 
int dt_collection_query_image_offset (const int32_t imgid)
 
void dt_collection_query_push (void)
 
void dt_collection_query_pop (void)
 
void dt_collection_query_restrict_to_selection (void)
 
GListdt_collection_query_get_group_members (const int32_t group_id, const int32_t exclude_imgid)
 
GListdt_collection_query_get_property_values (const dt_collection_values_request_t *req)
 
void dt_collection_query_get_makermodels (const gchar *filter, GList **sanitized, GList **exif)
 
GListdt_collection_query_get_images_for_rule (const dt_collection_properties_t property, const char *text, gboolean recursive)
 
int32_t dt_collection_query_find_neighbour (GList *imgids)
 
void dt_collection_query_cleanup (void)
 

Typedef Documentation

◆ dt_collection_query_order_resolver_t

typedef int(* dt_collection_query_order_resolver_t) (const char *text)

The collection query: which images the lighttable is currently showing, and in what order.

This is the one place in the tree that COMPOSES SQL rather than merely running it, and that is why it lives here. Rules arrive as rules – a dt_collection_params_t and an array of dt_collection_rule_t – never as SQL. Turning each rule into a WHERE, joining them with their conjunctions and assembling the query is this module's job, and none of that text leaves the file. Callers ask for ids, counts and offsets.

Reading the user's rules out of conf stays in common/collection.c: this module reads no configuration, which is what lets it be reused against a different database. For the same reason anything presentational – translating a module-order name, deciding whether a metadata field is hidden – is resolved by the caller and handed in.

There is no handle. dt_collection_new() has a single call site, so the collection is a singleton in practice and an argument no caller chooses is not a parameter. Resolve a user-visible module-order name to the version id stored in main.module_order, or -1 when it names none.

Matching a LOCALISED string is presentation, and this module has no business doing it – but the "module order" collection rule is expressed that way. The caller installs a resolver.

Definition at line 57 of file collection_query.h.

◆ dt_collection_values_request_t

What to list, and every preference the answer depends on, resolved by the caller.

Each of these was a conf read inside the query builder. They are display decisions – which rule excludes itself, whether a metadata field is hidden, how film rolls are ordered – and this module reads no configuration.

◆ dt_iop_name_row_t

One module's identity, for the rule that searches by module name.

Function Documentation

◆ dt_collection_query_cleanup()

void dt_collection_query_cleanup ( void  )

Finalise the cached statements and release the stored rules. Must run before the connection closes.

Definition at line 1595 of file collection_query.c.

References _params, _query, _where_ext, dt_free, L, and dt_collection_params_t::text_filter.

Referenced by dt_collection_free(), and testdb_teardown().

◆ dt_collection_query_count()

uint32_t dt_collection_query_count ( void  )

How many images the collection currently holds.

Definition at line 1132 of file collection_query.c.

References _count.

Referenced by dt_collection_get_count(), and dt_collection_query_get_nth().

◆ dt_collection_query_find_neighbour()

int32_t dt_collection_query_find_neighbour ( GList imgids)

The first collected image that is not in imgids, looked for after the list and then before it; -1 if there is none.

Definition at line 1529 of file collection_query.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, dt_util_dstrcat(), i, IS_NULL_PTR, and L.

Referenced by dt_collection_update_query().

◆ dt_collection_query_get_generation()

uint64_t dt_collection_query_get_generation ( void  )

A number that advances on every recomposition.

Callers that need to notice "the collection changed" compare this. It replaces hashing the query string, which required the text to leave the module.

Definition at line 1161 of file collection_query.c.

References _generation.

Referenced by _dt_collection_get_hash().

◆ dt_collection_query_get_group_members()

GList * dt_collection_query_get_group_members ( const int32_t  group_id,
const int32_t  exclude_imgid 
)

Members of image group group_id that are IN the current collection, exclude_imgid left out. Lives here rather than in image_repository because it is scoped by the collection query, and that text does not leave this file.

Definition at line 1168 of file collection_query.c.

References _ensure_query(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, IS_NULL_PTR, and L.

Referenced by dt_grouping_add_grouped_images().

◆ dt_collection_query_get_images()

GList * dt_collection_query_get_images ( const uint32_t  limit)

The first limit image ids of the collection, in collection order (-1 for all of them).

Definition at line 1648 of file collection_query.c.

References _ensure_query(), _params, COLLECTION_QUERY_USE_LIMIT, dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, L, and dt_collection_params_t::query_flags.

Referenced by dt_collection_get().

◆ dt_collection_query_get_images_for_rule()

GList * dt_collection_query_get_images_for_rule ( const dt_collection_properties_t  property,
const char *  text,
gboolean  recursive 
)

Image ids matching ONE rule, independent of the active collection – what batch operations enumerate over.

Definition at line 1503 of file collection_query.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, get_query_string(), IS_NULL_PTR, and L.

Referenced by dt_collection_get_images_for_rule().

◆ dt_collection_query_get_makermodels()

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

Camera maker/model pairs present in the library, sanitised and as EXIF recorded them.

Definition at line 1442 of file collection_query.c.

References dt_collection_get_makermodel(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, FALSE, IS_NULL_PTR, key, L, and TRUE.

Referenced by dt_collection_get_makermodels().

◆ dt_collection_query_get_nth()

int32_t dt_collection_query_get_nth ( const int  nth)

◆ dt_collection_query_get_property_values()

◆ dt_collection_query_image_offset()

int dt_collection_query_image_offset ( const int32_t  imgid)

The position of imgid within the collection, or 0 if it is not in it – the original's convention, which callers use to land at the start rather than error out.

Definition at line 1694 of file collection_query.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_PREPARE_V2, FALSE, IS_NULL_PTR, L, TRUE, and UNKNOWN_IMAGE.

Referenced by dt_collection_image_offset_with_collection().

◆ dt_collection_query_pop()

void dt_collection_query_pop ( void  )

Definition at line 1723 of file collection_query.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_EXEC, and L.

Referenced by dt_pop_collection().

◆ dt_collection_query_push()

void dt_collection_query_push ( void  )

Save / restore memory.collected_images, for code that needs to collect something else for a moment and put the user's collection back afterwards.

Definition at line 1732 of file collection_query.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_EXEC, and L.

Referenced by dt_push_collection().

◆ dt_collection_query_recompose()

int dt_collection_query_recompose ( void  )

Recompose from the rules already held – what a caller does after changing something the query text depends on without changing the rules themselves.

Definition at line 1127 of file collection_query.c.

References _recompose().

◆ dt_collection_query_refresh_memory_table()

void dt_collection_query_refresh_memory_table ( void  )

◆ dt_collection_query_restrict_to_selection()

void dt_collection_query_restrict_to_selection ( void  )

Drop from memory.collected_images everything that is not in main.selected_images.

Definition at line 1741 of file collection_query.c.

References _compute_count(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_EXEC, and L.

Referenced by dt_selection_to_culling_mode().

◆ dt_collection_query_set_iop_names()

void dt_collection_query_set_iop_names ( const dt_iop_name_row_t rows,
const size_t  count 
)

Fill memory.darktable_iop_names, the table the module-name rules join against.

Must run before any collection query naming a module. The table lives here because these queries are its only readers; the localised names come from the module objects, which the caller owns.

Definition at line 1137 of file collection_query.c.

References dt_database_get_sqlite3_global(), dt_database_release_transaction, dt_database_start_transaction, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, i, IS_NULL_PTR, L, and name.

Referenced by dt_iop_set_darktable_iop_table().

◆ dt_collection_query_set_order_names()

void dt_collection_query_set_order_names ( const char *const names,
const int  count 
)

Supply the user-visible module-order names, index-aligned with the versions stored in main.module_order. The value list for that property interpolates them into its query, so the module needs the strings themselves – but not the ability to translate. Borrowed.

Definition at line 96 of file collection_query.c.

References _order_names, _order_names_count, and L.

Referenced by dt_collection_new().

◆ dt_collection_query_set_order_resolver()

void dt_collection_query_set_order_resolver ( dt_collection_query_order_resolver_t  fn)

Definition at line 91 of file collection_query.c.

References _order_resolver, and L.

Referenced by dt_collection_new().

◆ dt_collection_query_set_rules()

int dt_collection_query_set_rules ( const dt_collection_params_t params,
const dt_collection_rule_t rules,
const int  n_rules,
const uint32_t  tagid 
)

Replace the rules and recompose.

The rules arrive as rules – property, mode, text – not as SQL. Turning them into WHERE fragments and assembling the query is this module's whole job. Everything is copied, so the caller keeps ownership of what it passed.

Definition at line 1109 of file collection_query.c.

References _compose_where_ext(), _params, _recompose(), _tagid, _where_ext, dt_free, IS_NULL_PTR, L, and dt_collection_params_t::text_filter.

Referenced by dt_collection_update().