98
99
GList *list=filter;
100
101
char include[2048]= {0};
101
strcat(include,"num in (");
102
g_strlcat(include,"num in (", 2048);
104
105
if(list!=g_list_first(list))
106
g_strlcat(include,",", 2048);
106
107
sprintf(tmp,"%ld",(long int)list->data);
108
g_strlcat(include,tmp, 2048);
109
110
while ((list=g_list_next(list)));
111
g_strlcat(include,")", 2048);
111
112
char query[4096]= {0};
112
sprintf(query,"insert into style_items (styleid,num,module,operation,op_params,enabled) select ?1, num,module,operation,op_params,enabled from history where imgid=?2 and %s",include);
113
sprintf(query,"insert into style_items (styleid,num,module,operation,op_params,enabled,blendop_params) select ?1, num,module,operation,op_params,enabled,blendop_params from history where imgid=?2 and %s",include);
113
114
DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, query, -1, &stmt, NULL);
116
DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, "insert into style_items (styleid,num,module,operation,op_params,enabled) select ?1, num,module,operation,op_params,enabled from history where imgid=?2", -1, &stmt, NULL);
117
DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, "insert into style_items (styleid,num,module,operation,op_params,enabled,blendop_params) select ?1, num,module,operation,op_params,enabled,blendop_params from history where imgid=?2", -1, &stmt, NULL);
117
118
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
118
119
DT_DEBUG_SQLITE3_BIND_INT(stmt, 2, imgid);
119
120
sqlite3_step (stmt);
169
170
sqlite3_finalize (stmt);
171
172
/* copy history items from styles onto image */
172
DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, "insert into history (imgid,num,module,operation,op_params,enabled) select ?1, num+?2,module,operation,op_params,enabled from style_items where styleid=?3", -1, &stmt, NULL);
173
DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, "insert into history (imgid,num,module,operation,op_params,enabled,blendop_params) select ?1, num+?2,module,operation,op_params,enabled,blendop_params from style_items where styleid=?3", -1, &stmt, NULL);
173
174
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, imgid);
174
175
DT_DEBUG_SQLITE3_BIND_INT(stmt, 2, offs);
175
176
DT_DEBUG_SQLITE3_BIND_INT(stmt, 3, id);
181
if (dt_tag_new(name,&tagid))
183
g_snprintf(ntag,512,"darktable|style|%s",name);
184
if (dt_tag_new(ntag,&tagid))
182
185
dt_tag_attach(tagid,imgid);
184
187
/* if current image in develop reload history */
311
314
xmlTextWriterEndElement(writer);
313
316
xmlTextWriterStartElement(writer, BAD_CAST "style");
314
DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, "select num,module,operation,op_params,enabled from style_items where styleid =?1",-1, &stmt,NULL);
317
DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, "select num,module,operation,op_params,enabled,blendop_params from style_items where styleid =?1",-1, &stmt,NULL);
315
318
DT_DEBUG_SQLITE3_BIND_INT(stmt,1,dt_styles_get_id_by_name(style_name));
316
319
while (sqlite3_step (stmt) == SQLITE_ROW)
321
324
xmlTextWriterWriteFormatElement(writer, BAD_CAST "operation", "%s", sqlite3_column_text(stmt,2));
322
325
xmlTextWriterWriteFormatElement(writer, BAD_CAST "op_params", "%s", dt_style_encode(stmt,3));
323
326
xmlTextWriterWriteFormatElement(writer, BAD_CAST "enabled", "%d", sqlite3_column_int(stmt,4));
327
xmlTextWriterWriteFormatElement(writer, BAD_CAST "blendop_params", "%s", dt_style_encode(stmt,5));
324
328
xmlTextWriterEndElement(writer);
326
330
sqlite3_finalize(stmt);
430
434
g_string_append_len (plug->op_params, text, text_len);
436
else if (g_ascii_strcasecmp (elt, "blendop_params") == 0 )
438
g_string_append_len (plug->blendop_params, text, text_len);
432
440
else if (g_ascii_strcasecmp (elt, "num") == 0 )
434
442
plug->num = atoi(text);
460
468
int id = GPOINTER_TO_INT(styleId);
461
469
sqlite3_stmt *stmt;
462
DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, "insert into style_items (styleid,num,module,operation,op_params,enabled) values(?1,?2,?3,?4,?5,?6)", -1, &stmt, NULL);
470
DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, "insert into style_items (styleid,num,module,operation,op_params,enabled,blendop_params) values(?1,?2,?3,?4,?5,?6,?7)", -1, &stmt, NULL);
463
471
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
464
472
DT_DEBUG_SQLITE3_BIND_INT(stmt, 2, plugin->num);
465
473
DT_DEBUG_SQLITE3_BIND_INT(stmt, 3, plugin->module);
473
481
DT_DEBUG_SQLITE3_BIND_BLOB(stmt, 5, params, params_len, SQLITE_TRANSIENT);
475
483
DT_DEBUG_SQLITE3_BIND_INT(stmt, 6, plugin->enabled);
485
/* decode and store blendop params */
486
unsigned char *blendop_params = (unsigned char *)g_malloc(strlen(plugin->blendop_params->str));
487
dt_exif_xmp_decode(plugin->blendop_params->str, blendop_params, strlen(plugin->blendop_params->str));
488
DT_DEBUG_SQLITE3_BIND_BLOB(stmt, 7, blendop_params, strlen(plugin->blendop_params->str)/2, SQLITE_TRANSIENT);
476
490
sqlite3_step(stmt);
477
491
sqlite3_finalize(stmt);