![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#include <string.h>#include "database/collection_query.h"#include "database/database.h"#include "database/sql_debug.h"#include "metadata/colorlabels.h"#include "common/datetime.h"#include "metadata/map_locations.h"#include "common/image.h"#include "common/utility.h"#include "system/dtpthread.h"#include "system/macros.h"#include "system/mem_alloc.h"
Include dependency graph for collection_query.c:Go to the source code of this file.
Macros | |
| #define | LIMIT_QUERY "LIMIT ?1, ?2" |
| #define | and_operator_initial() (0) |
| #define | or_operator_initial() (0) |
Variables | |
| static dt_collection_params_t | _params |
| static gchar ** | _where_ext = NULL |
| static uint32_t | _tagid = 0 |
| static gchar * | _query = NULL |
| static uint32_t | _count = 0 |
| static uint64_t | _generation = 0 |
| static dt_collection_query_order_resolver_t | _order_resolver = NULL |
| static const char *const * | _order_names = NULL |
| static int | _order_names_count = 0 |
| #define and_operator_initial | ( | ) | (0) |
Definition at line 57 of file collection_query.c.
| #define LIMIT_QUERY "LIMIT ?1, ?2" |
Definition at line 53 of file collection_query.c.
| #define or_operator_initial | ( | ) | (0) |
Definition at line 74 of file collection_query.c.
|
static |
Turn the rules into the array of WHERE fragments the query is built from.
One fragment per rule, each prefixed by its conjunction, exactly as the caller used to assemble them before handing the array over. An empty rule contributes " OR 1=1" in OR mode and nothing otherwise, which is what makes a blank OR row mean "everything".
Definition at line 1085 of file collection_query.c.
References dt_free, get_query_string(), i, IS_NULL_PTR, L, and r.
Referenced by dt_collection_query_set_rules().
Definition at line 1060 of file collection_query.c.
References _count, dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, and L.
Referenced by dt_collection_query_refresh_memory_table(), and dt_collection_query_restrict_to_selection().
Definition at line 1074 of file collection_query.c.
References _query, _recompose(), and IS_NULL_PTR.
Referenced by dt_collection_query_get_group_members(), dt_collection_query_get_images(), dt_collection_query_get_nth(), and dt_collection_query_refresh_memory_table().
Definition at line 682 of file collection_query.c.
References _where_ext, dt_free, and L.
Referenced by _recompose().
The WHERE for every rule except exclude – or NO restriction at all when apply_exclude is FALSE. The caller decides whether the exclusion applies (that used to be a conf read of "plugins/lighttable/collect/mode<N>", and conf is not this module's to read), and FALSE means the rule being edited is an OR rule: an OR rule does not limit the collection, so nothing may limit its value list either. The original spelled this "don't limit the collection for OR" and appended no rule whatsoever.
Definition at line 666 of file collection_query.c.
References _where_ext, dt_free, dt_util_dstrcat(), i, IS_NULL_PTR, and L.
Referenced by dt_collection_query_get_property_values().
|
static |
Definition at line 650 of file collection_query.c.
Referenced by dt_collection_query_get_property_values().
Definition at line 798 of file collection_query.c.
References _extended_where(), _params, _set_selq_pre_sort(), _sort_query(), _store(), _tagid, 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_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_free, 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, L, LIMIT_QUERY, or_operator(), or_operator_initial, dt_collection_params_t::query_flags, dt_collection_params_t::sort, and dt_collection_params_t::text_filter.
Referenced by _ensure_query(), dt_collection_query_recompose(), and dt_collection_query_set_rules().
Definition at line 690 of file collection_query.c.
References _tagid, dt_util_dstrcat(), and L.
Referenced by _recompose().
Definition at line 710 of file collection_query.c.
References _params, dt_collection_params_t::descending, DT_COLLECTION_SORT_CHANGE_TIMESTAMP, DT_COLLECTION_SORT_COLOR, DT_COLLECTION_SORT_DATETIME, DT_COLLECTION_SORT_EXPORT_TIMESTAMP, DT_COLLECTION_SORT_FILENAME, DT_COLLECTION_SORT_GROUP, DT_COLLECTION_SORT_ID, DT_COLLECTION_SORT_IMPORT_TIMESTAMP, DT_COLLECTION_SORT_NONE, DT_COLLECTION_SORT_PATH, DT_COLLECTION_SORT_PRINT_TIMESTAMP, DT_COLLECTION_SORT_RATING, DT_COLLECTION_SORT_TITLE, dt_util_dstrcat(), L, and dt_collection_params_t::sort.
Referenced by _recompose().
|
static |
Definition at line 103 of file collection_query.c.
References _generation, _query, dt_free, and L.
Referenced by _recompose().
|
static |
Definition at line 58 of file collection_query.c.
References IS_NULL_PTR, and L.
Referenced by _recompose().
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().
| 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().
| 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().
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().
| 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().
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().
| 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().
| 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().
| int32_t dt_collection_query_get_nth | ( | const int | nth | ) |
The id at position nth, or -1.
Definition at line 1673 of file collection_query.c.
References _ensure_query(), dt_collection_query_count(), dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, and L.
Referenced by _slideshow_get_imgid_from_rank(), and dt_collection_get_nth().
| GList * dt_collection_query_get_property_values | ( | const dt_collection_values_request_t * | req | ) |
The distinct values of the requested property across the collection, with counts.
Definition at line 1193 of file collection_query.c.
References _extended_where_excluding(), _name_value_new(), _order_names, _order_names_count, dt_collection_get_makermodel(), DT_COLLECTION_PROP_APERTURE, DT_COLLECTION_PROP_CAMERA, DT_COLLECTION_PROP_CHANGE_TIMESTAMP, DT_COLLECTION_PROP_COLORLABEL, DT_COLLECTION_PROP_DAY, DT_COLLECTION_PROP_EXPORT_TIMESTAMP, DT_COLLECTION_PROP_EXPOSURE, DT_COLLECTION_PROP_FILENAME, DT_COLLECTION_PROP_FILMROLL, DT_COLLECTION_PROP_FOCAL_LENGTH, DT_COLLECTION_PROP_FOLDERS, DT_COLLECTION_PROP_GEOTAGGING, DT_COLLECTION_PROP_GROUPING, DT_COLLECTION_PROP_HISTORY, DT_COLLECTION_PROP_IMPORT_TIMESTAMP, DT_COLLECTION_PROP_ISO, DT_COLLECTION_PROP_LENS, DT_COLLECTION_PROP_LOCAL_COPY, DT_COLLECTION_PROP_METADATA, DT_COLLECTION_PROP_MODULE, DT_COLLECTION_PROP_ORDER, DT_COLLECTION_PROP_PRINT_TIMESTAMP, DT_COLLECTION_PROP_RATING, DT_COLLECTION_PROP_TAG, DT_COLLECTION_PROP_TIME, dt_database_get_sqlite3_global(), DT_DATETIME_EXIF_LENGTH, dt_datetime_gtimespan_to_exif(), DT_DEBUG_SQLITE3_PREPARE_V2, DT_IMAGE_LOCAL_COPY, dt_map_location_data_tag_root(), dt_metadata_get_keyid_by_display_order(), DT_METADATA_NUMBER, dt_util_dstrcat(), i, IS_NULL_PTR, L, maker, model, name, orders, and out.
Referenced by dt_collection_get_property_values().
| 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().
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().
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().
| 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().
Rebuild memory.collected_images from the current query.
Definition at line 1607 of file collection_query.c.
References _compute_count(), _ensure_query(), dt_collection_get_global(), dt_database_get_sqlite3_global(), dt_database_is_open(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_EXEC, DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, IS_NULL_PTR, and L.
Referenced by dt_collection_memory_update().
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().
| 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().
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().
| 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().
| 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().
|
static |
The WHERE built from the rules the caller handed in, as "(1=1<rule><rule>...)".
The original took an exclude index and, for exclude >= 0, read "plugins/lighttable/collect/mode<N>" from conf to decide whether to honour it. That branch serves dt_collection_get_images_for_rule() and stays in common/collection.c with the conf it needs; only the plain join is composition.
Definition at line 123 of file collection_query.c.
References _order_resolver, color, dt_collection_get_makermodels(), DT_COLLECTION_PROP_APERTURE, DT_COLLECTION_PROP_CAMERA, DT_COLLECTION_PROP_CHANGE_TIMESTAMP, DT_COLLECTION_PROP_COLORLABEL, DT_COLLECTION_PROP_DAY, DT_COLLECTION_PROP_EXPORT_TIMESTAMP, DT_COLLECTION_PROP_EXPOSURE, DT_COLLECTION_PROP_FILENAME, DT_COLLECTION_PROP_FILMROLL, DT_COLLECTION_PROP_FOCAL_LENGTH, DT_COLLECTION_PROP_FOLDERS, DT_COLLECTION_PROP_GEOTAGGING, DT_COLLECTION_PROP_GROUPING, DT_COLLECTION_PROP_HISTORY, DT_COLLECTION_PROP_IMPORT_TIMESTAMP, DT_COLLECTION_PROP_ISO, DT_COLLECTION_PROP_LENS, DT_COLLECTION_PROP_LOCAL_COPY, DT_COLLECTION_PROP_METADATA, DT_COLLECTION_PROP_MODULE, DT_COLLECTION_PROP_ORDER, DT_COLLECTION_PROP_PRINT_TIMESTAMP, DT_COLLECTION_PROP_QUERY, DT_COLLECTION_PROP_RATING, DT_COLLECTION_PROP_TAG, DT_COLLECTION_PROP_TIME, dt_collection_split_operator_datetime(), dt_collection_split_operator_exposure(), dt_collection_split_operator_number(), dt_datetime_exif_to_gtimespan(), dt_free, dt_free_gpointer(), DT_IMAGE_LOCAL_COPY, dt_map_location_data_tag_root(), dt_metadata_get_keyid_by_display_order(), DT_METADATA_NUMBER, dt_util_dstrcat(), dt_util_glist_to_str(), dt_util_str_to_glist(), i, IS_NULL_PTR, L, and name.
Referenced by _compose_where_ext(), and dt_collection_query_get_images_for_rule().
|
static |
Definition at line 75 of file collection_query.c.
References IS_NULL_PTR, and L.
Referenced by _recompose().
|
static |
Definition at line 46 of file collection_query.c.
Referenced by _compute_count(), and dt_collection_query_count().
|
static |
Definition at line 47 of file collection_query.c.
Referenced by _store(), and dt_collection_query_get_generation().
Definition at line 49 of file collection_query.c.
Referenced by dt_collection_query_get_property_values(), and dt_collection_query_set_order_names().
|
static |
Definition at line 50 of file collection_query.c.
Referenced by dt_collection_query_get_property_values(), and dt_collection_query_set_order_names().
|
static |
Definition at line 48 of file collection_query.c.
Referenced by dt_collection_query_set_order_resolver(), and get_query_string().
|
static |
Definition at line 42 of file collection_query.c.
Referenced by _recompose(), _sort_query(), dt_collection_query_cleanup(), dt_collection_query_get_images(), and dt_collection_query_set_rules().
|
static |
Definition at line 45 of file collection_query.c.
Referenced by _ensure_query(), _store(), and dt_collection_query_cleanup().
|
static |
Definition at line 44 of file collection_query.c.
Referenced by _recompose(), _set_selq_pre_sort(), and dt_collection_query_set_rules().
|
static |
Definition at line 43 of file collection_query.c.
Referenced by _extended_where(), _extended_where_excluding(), dt_collection_query_cleanup(), and dt_collection_query_set_rules().