34 sqlite3_stmt *stmt = NULL;
41 sqlite3_stmt *stmt =
_prepared(
"SELECT color FROM main.color_labels WHERE imgid = ?1");
47 while(sqlite3_step(stmt) == SQLITE_ROW)
48 colors |= (1 << sqlite3_column_int(stmt, 0));
49 sqlite3_finalize(stmt);
56 sqlite3_stmt *stmt =
_prepared(
"INSERT OR IGNORE INTO main.color_labels (imgid, color) VALUES (?1, ?2)");
61 sqlite3_finalize(stmt);
66 sqlite3_stmt *stmt =
_prepared(
"DELETE FROM main.color_labels WHERE imgid=?1 AND color=?2");
71 sqlite3_finalize(stmt);
76 sqlite3_stmt *stmt =
_prepared(
"DELETE FROM main.color_labels WHERE imgid=?1");
80 sqlite3_finalize(stmt);
85 if(imgid <= 0)
return FALSE;
88 sqlite3_stmt *stmt = NULL;
91 "SELECT * FROM main.color_labels WHERE imgid=?1 AND color=?2 LIMIT 1",
97 const gboolean found = (sqlite3_step(stmt) == SQLITE_ROW);
98 sqlite3_finalize(stmt);
104 sqlite3_stmt *stmt = NULL;
113 "SELECT color FROM main.color_labels WHERE imgid IN "
114 "(SELECT imgid FROM main.selected_images)",
122 "SELECT color FROM main.color_labels WHERE imgid=?1 ORDER BY color",
128 GList *result = NULL;
129 while(sqlite3_step(stmt) == SQLITE_ROW)
130 result = g_list_prepend(result, GINT_TO_POINTER(sqlite3_column_int(stmt, 0)));
131 sqlite3_finalize(stmt);
133 return g_list_reverse(result);
145 while(sqlite3_step(stmt) == SQLITE_ROW)
146 cb(user_data, sqlite3_column_int(stmt, 0));
147 sqlite3_finalize(stmt);
gboolean dt_colorlabel_repository_has(const int32_t imgid, const int color)
TRUE when colour color is set on imgid.
void dt_colorlabel_repository_remove_all(const int32_t imgid)
Clear every colour on imgid.
void dt_colorlabel_repository_remove(const int32_t imgid, const int color)
Clear colour color on imgid. Clearing one that is not set does nothing.
void dt_colorlabel_repository_set(const int32_t imgid, const int color)
Set colour color on imgid. Setting one that is already set does nothing.
static sqlite3_stmt * _prepared(const char *query)
GList * dt_colorlabel_repository_get_list(const int32_t imgid)
The colours set on imgid, as a list rather than a bitmask.
int dt_colorlabel_repository_get(const int32_t imgid)
The colours set on imgid, as a bitmask: bit c is set when colour c is.
void dt_colorlabel_repository_foreach(const int32_t imgid, void(*cb)(void *, const int), void *user_data)
Every colour label of imgid, one call per row, in the order the rows come back.
void dt_colorlabel_repository_cleanup(void)
Finalise whatever this repository still caches – today, nothing.
main.color_labels: which of the five colour labels are set on an image.
sqlite3 * dt_database_get_sqlite3_global(void)
const dt_collection_filter_flag_t colors[6]
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
Checked wrappers around the sqlite3_* calls: trace the statement, assert the return code,...
#define DT_DEBUG_SQLITE3_PREPARE_V2(a, b, c, d, e)
#define DT_DEBUG_SQLITE3_BIND_INT(a, b, c)