collection.h 8.87 KB
Newer Older
1 2
/*
    This file is part of darktable,
3
    copyright (c) 2010--2011 Henrik Andersson.
4 5 6 7 8 9 10 11 12 13 14 15 16 17

    darktable is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    darktable is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with darktable.  If not, see <http://www.gnu.org/licenses/>.
*/
18 19

#pragma once
20

21
#include <glib.h>
22
#include <inttypes.h>
23

24 25
typedef enum dt_collection_query_t
{
26 27 28 29 30 31 32
  COLLECTION_QUERY_SIMPLE = 0,                 // a query with only select and where statement
  COLLECTION_QUERY_USE_SORT = 1 << 0,          // if query should include order by statement
  COLLECTION_QUERY_USE_LIMIT = 1 << 1,         // if query should include "limit ?1,?2" part
  COLLECTION_QUERY_USE_WHERE_EXT = 1 << 2,     // if query should include extended where part
  COLLECTION_QUERY_USE_ONLY_WHERE_EXT = 1 << 3 // if query should only use extended where part
} dt_collection_query_t;
#define COLLECTION_QUERY_FULL (COLLECTION_QUERY_USE_SORT | COLLECTION_QUERY_USE_LIMIT)
33

34 35
typedef enum dt_collection_filter_comparator_t
{
36 37 38 39 40 41 42 43 44
  COLLECTION_FILTER_NONE = 0,
  COLLECTION_FILTER_FILM_ID = 1 << 0,        // use film_id in filter
  COLLECTION_FILTER_ATLEAST_RATING = 1 << 1, // show all stars including and above selected star filter
  COLLECTION_FILTER_EQUAL_RATING = 1 << 2,   // show only selected star filter
  COLLECTION_FILTER_ALTERED = 1 << 3,        // show only altered images
  COLLECTION_FILTER_UNALTERED = 1 << 4,      // show only unaltered images
  COLLECTION_FILTER_CUSTOM_COMPARE
  = 1 << 5 // use the comparator defined in the comparator field to filter stars
} dt_collection_filter_comparator_t;
45

46 47
typedef enum dt_collection_filter_t
{
48 49 50 51 52 53 54 55
  DT_COLLECTION_FILTER_ALL = 0,
  DT_COLLECTION_FILTER_STAR_NO = 1,
  DT_COLLECTION_FILTER_STAR_1 = 2,
  DT_COLLECTION_FILTER_STAR_2 = 3,
  DT_COLLECTION_FILTER_STAR_3 = 4,
  DT_COLLECTION_FILTER_STAR_4 = 5,
  DT_COLLECTION_FILTER_STAR_5 = 6,
  DT_COLLECTION_FILTER_REJECT = 7,
56
  DT_COLLECTION_FILTER_NOT_REJECT = 8
57
} dt_collection_filter_t;
58 59 60

typedef enum dt_collection_sort_t
{
61
  DT_COLLECTION_SORT_NONE = -1,
62 63 64 65
  DT_COLLECTION_SORT_FILENAME = 0,
  DT_COLLECTION_SORT_DATETIME,
  DT_COLLECTION_SORT_RATING,
  DT_COLLECTION_SORT_ID,
66
  DT_COLLECTION_SORT_COLOR,
67 68
  DT_COLLECTION_SORT_GROUP,
  DT_COLLECTION_SORT_PATH
69
} dt_collection_sort_t;
70

71 72 73 74 75 76 77
typedef enum dt_collection_properties_t
{
  DT_COLLECTION_PROP_FILMROLL,
  DT_COLLECTION_PROP_FOLDERS,
  DT_COLLECTION_PROP_CAMERA,
  DT_COLLECTION_PROP_TAG,
  DT_COLLECTION_PROP_DAY,
78
  DT_COLLECTION_PROP_TIME,
79 80 81 82 83 84 85 86
  DT_COLLECTION_PROP_HISTORY,
  DT_COLLECTION_PROP_COLORLABEL,
  DT_COLLECTION_PROP_TITLE,
  DT_COLLECTION_PROP_DESCRIPTION,
  DT_COLLECTION_PROP_CREATOR,
  DT_COLLECTION_PROP_PUBLISHER,
  DT_COLLECTION_PROP_RIGHTS,
  DT_COLLECTION_PROP_LENS,
87
  DT_COLLECTION_PROP_FOCAL_LENGTH,
88 89
  DT_COLLECTION_PROP_ISO,
  DT_COLLECTION_PROP_APERTURE,
90
  DT_COLLECTION_PROP_FILENAME,
91 92
  DT_COLLECTION_PROP_GEOTAGGING,
  DT_COLLECTION_PROP_LOCAL_COPY
93
} dt_collection_properties_t;
94

95 96
typedef enum dt_collection_rating_comperator_t
{
97
  DT_COLLECTION_RATING_COMP_LT = 0,
98
  DT_COLLECTION_RATING_COMP_LEQ = 1,
99
  DT_COLLECTION_RATING_COMP_EQ = 2,
100
  DT_COLLECTION_RATING_COMP_GEQ = 3,
101 102 103 104
  DT_COLLECTION_RATING_COMP_GT = 4,
  DT_COLLECTION_RATING_COMP_NE = 5,
  DT_COLLECTION_RATING_N_COMPS = 6
} dt_collection_rating_comperator_t;
105

106 107
typedef struct dt_collection_params_t
{
108 109
  /** flags for which query parts to use, see COLLECTION_QUERY_x defines... */
  uint32_t query_flags;
johannes hanika's avatar
johannes hanika committed
110

111 112
  /** flags for which filters to use, see COLLECTION_FILTER_x defines... */
  uint32_t filter_flags;
johannes hanika's avatar
johannes hanika committed
113

114 115
  /** current film id */
  uint32_t film_id;
johannes hanika's avatar
johannes hanika committed
116

117 118
  /** current  filter */
  uint32_t rating;
119
  dt_collection_rating_comperator_t comparator;
johannes hanika's avatar
johannes hanika committed
120

121
  /** sorting **/
122
  dt_collection_sort_t sort; // Has to be changed to a dt_collection_sort struct
123 124
  gint descending;

125 126 127 128
} dt_collection_params_t;

typedef struct dt_collection_t
{
129
  int clone;
130
  gchar *query;
131
  gchar *where_ext;
132
  unsigned int count;
133
  dt_collection_params_t params;
134
  dt_collection_params_t store;
135
} dt_collection_t;
136 137


Unknown's avatar
Unknown committed
138
/** instantiates a collection context, if clone equals NULL default query is constructed. */
139
const dt_collection_t *dt_collection_new(const dt_collection_t *clone);
140
/** frees a collection context. */
141
void dt_collection_free(const dt_collection_t *collection);
142
/** fetch params for collection for storing. */
143
const dt_collection_params_t *dt_collection_params(const dt_collection_t *collection);
144
/** get the filtered map between sanitized makermodel and exif maker/model **/
145
void dt_collection_get_makermodel(const gchar *filter, GList **sanitized, GList **exif);
146
/** get the generated query for collection */
147
const gchar *dt_collection_get_query(const dt_collection_t *collection);
148
/** updates sql query for a collection. @return 1 if query changed. */
149
int dt_collection_update(const dt_collection_t *collection);
150
/** reset collection to default dummy selection */
151
void dt_collection_reset(const dt_collection_t *collection);
152
/** sets an extended where part */
153
void dt_collection_set_extended_where(const dt_collection_t *collection, gchar *extended_where);
154 155

/** get filter flags for collection */
156
uint32_t dt_collection_get_filter_flags(const dt_collection_t *collection);
157
/** set filter flags for collection */
158
void dt_collection_set_filter_flags(const dt_collection_t *collection, uint32_t flags);
159

160
/** get filter flags for collection */
161
uint32_t dt_collection_get_query_flags(const dt_collection_t *collection);
162
/** set filter flags for collection */
163
void dt_collection_set_query_flags(const dt_collection_t *collection, uint32_t flags);
164

165
/** set the film_id of collection */
166
void dt_collection_set_film_id(const dt_collection_t *collection, uint32_t film_id);
167
/** set the star level for filter */
168
void dt_collection_set_rating(const dt_collection_t *collection, uint32_t rating);
169
/** get the star level for filter. The value returned starts on 0 **/
170
uint32_t dt_collection_get_rating(const dt_collection_t *collection);
171
/** set the comparator for rating */
172 173
void dt_collection_set_rating_comparator(const dt_collection_t *collection,
                                         const dt_collection_rating_comperator_t comparator);
174
/** get the comparator for rating */
175
dt_collection_rating_comperator_t dt_collection_get_rating_comparator(const dt_collection_t *collection);
176 177 178 179 180 181 182 183 184 185

/** set the sort fields and flags used to show the collection **/
void dt_collection_set_sort(const dt_collection_t *collection, dt_collection_sort_t sort, gint reverse);
/** get the sort field used **/
dt_collection_sort_t dt_collection_get_sort_field(const dt_collection_t *collection);
/** get if the collection must be shown in descending order **/
gboolean dt_collection_get_sort_descending(const dt_collection_t *collection);
/** get the part of the query for sorting the collection **/
gchar *dt_collection_get_sort_query(const dt_collection_t *collection);

186
/** get the count of query */
187
uint32_t dt_collection_get_count(const dt_collection_t *collection);
188 189
/** get the nth image in the query */
int dt_collection_get_nth(const dt_collection_t *collection, int nth);
190 191 192
/** get all image ids order as current selection. no more than limit many images are returned, <0 ==
 * unlimited */
GList *dt_collection_get_all(const dt_collection_t *collection, int limit);
193 194 195
/** get selected image ids order as current selection. no more than limit many images are returned, <0 ==
 * unlimited */
GList *dt_collection_get_selected(const dt_collection_t *collection, int limit);
196
/** get the count of selected images */
197
uint32_t dt_collection_get_selected_count(const dt_collection_t *collection);
198

199
/** update query by conf vars */
200 201
void dt_collection_update_query(const dt_collection_t *collection);

202 203 204
/** updates the hint message for collection */
void dt_collection_hint_message(const dt_collection_t *collection);

205 206
/** returns the image offset in the collection */
int dt_collection_image_offset(int imgid);
207 208 209 210 211

/* serialize and deserialize into a string. */
void dt_collection_deserialize(char *buf);
int dt_collection_serialize(char *buf, int bufsize);

212
/* splits an input string into a number part and an optional operator part */
213 214 215
void dt_collection_split_operator_number(const gchar *input, char **number1, char **number2, char **operator);
void dt_collection_split_operator_datetime(const gchar *input, char **number1, char **number2,
                                           char **operator);
216

Richard Wonka's avatar
Richard Wonka committed
217
// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh
218
// vim: shiftwidth=2 expandtab tabstop=2 cindent
Tobias Ellinghaus's avatar
Tobias Ellinghaus committed
219
// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;