14 #ifndef __UT_GALLERYDATASOURCE_H__
15 #define __UT_GALLERYDATASOURCE_H__
56 virtual bool isValid()
const = 0;
59 virtual bool isReadOnly()
const = 0;
76 virtual time_t creationDate(
const UT_StringRef &item_id)
const = 0;
77 virtual time_t modificationDate(
const UT_StringRef &item_id)
const = 0;
78 virtual bool isStarred(
const UT_StringRef &item_id)
const = 0;
83 virtual bool ownsFile(
const UT_StringRef &item_id)
const = 0;
113 const char *file_path)
119 const void *
data,
int data_size)
130 virtual bool deleteTag(
const char *tag,
bool delete_if_assigned)
const
142 const char *file_ext)
148 const void *thumbnail_data,
149 int thumbnail_data_size,
150 const char *item_file,
152 const void *item_data,
154 time_t *creation_date,
190 { myOwnerUpdatedIds.erase(owner); }
221 static void registerDataSourceImplementation(
230 {
return myImpl && myImpl->isValid(); }
233 {
return myImpl->isReadOnly(); }
236 {
return mySourceIdentifier; }
239 {
return mySourceArgs; }
242 {
return myImpl->infoHtml(); }
248 { myImpl->startTransaction(); }
250 { myImpl->endTransaction(); }
254 { item_ids.
clear(); myImpl->itemIds(item_ids); }
259 { item_ids.
clear(); myImpl->childItemIds(parent_item_id, item_ids); }
263 {
return myImpl->sourceTypeName(item_id); }
265 {
return myImpl->typeName(item_id); }
267 {
return myImpl->label(item_id); }
269 {
return myImpl->thumbnail(item_id); }
271 {
return myImpl->creationDate(item_id); }
273 {
return myImpl->modificationDate(item_id); }
275 {
return myImpl->isStarred(item_id); }
277 {
return myImpl->colorTag(item_id); }
279 {
return myImpl->tags(item_id); }
281 {
return myImpl->metadata(item_id); }
283 {
return myImpl->filePath(item_id); }
285 {
return myImpl->ownsFile(item_id); }
287 {
return myImpl->blindData(item_id); }
289 {
return myImpl->status(item_id); }
291 {
return myImpl->parentId(item_id); }
293 {
return myImpl->prepareItemForUse(item_id); }
308 const char *file_path);
312 const void *
data,
int data_size);
318 bool createTag(
const char *tag);
319 bool deleteTag(
const char *tag,
bool delete_if_assigned);
320 bool addTag(
const UT_StringRef &item_id,
const char *tag);
321 bool removeTag(
const UT_StringRef &item_id,
const char *tag);
328 const char *file_ext);
333 const void *thumbnail_data,
334 int thumbnail_data_size,
335 const char *item_file =
nullptr,
336 bool item_owns_file =
false,
337 const void *item_data =
nullptr,
338 int item_data_size = 0,
339 time_t *creation_date =
nullptr,
UT_StringHolder typeName(const UT_StringRef &item_id) const
void itemIds(UT_StringArray &item_ids) const
Populate an array with all valid item ids.
GLuint GLsizei const GLchar * label
UT_StringHolder filePath(const UT_StringRef &item_id) const
virtual bool setMetadata(const UT_StringRef &item_id, const UT_Options &metadata)
virtual bool saveAs(const UT_StringHolder &source_identifier)
UT_StringHolder parentId(const UT_StringRef &item_id) const
void addOwner(const UT_GalleryDataSource *owner)
UT_StringHolder label(const UT_StringRef &item_id) const
void childItemIds(const UT_StringRef &parent_item_id, UT_StringArray &item_ids) const
Populate an array with all valid item ids with the given parent 'item_id'.
virtual bool setIsStarred(const UT_StringRef &item_id, bool isstarred)
virtual bool deleteTag(const char *tag, bool delete_if_assigned) const
void endTransaction(bool commit=true) const
virtual UT_StringHolder generateItemFilePath(const UT_StringRef &item_id, const char *file_ext)
time_t creationDate(const UT_StringRef &item_id) const
UT_StringHolder colorTag(const UT_StringRef &item_id) const
UT_StringHolder sourceTypeName(const UT_StringRef &item_id) const
Return the source type.
virtual void endTransaction(bool commit=true) const
virtual bool markItemsForDeletion(const UT_StringArray &item_ids)
UT_StringHolder prepareItemForUse(const UT_StringRef &item_id) const
GLintptr GLsizeiptr GLboolean commit
virtual bool setOwnsFile(const UT_StringRef &item_id, bool owns_file)
const UT_StringHolder & sourceIdentifier() const
Return the source identifier.
bool isStarred(const UT_StringRef &item_id) const
UT_WorkBuffer thumbnail(const UT_StringRef &item_id) const
UT_Function< UT_SharedPtr< UT_GalleryDataSourceImpl > const UT_StringHolder &, const UT_StringHolder &)> CreatorFunc
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
virtual bool setFilePath(const UT_StringRef &item_id, const char *file_path)
virtual bool setStatus(const UT_StringRef &item_id, const UT_StringHolder &status)
static const UT_StringHolder theEmptyString
virtual void startTransaction() const
virtual bool unmarkItemsForDeletion(const UT_StringArray &item_ids)
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
virtual bool setThumbnail(const UT_StringRef &item_id, const UT_WorkBuffer &thumbnail)
UT_Options metadata(const UT_StringRef &item_id) const
GLuint const GLchar * name
virtual UT_StringHolder addItem(const UT_StringRef &item_type_name, const UT_StringRef &name, const void *thumbnail_data, int thumbnail_data_size, const char *item_file, bool item_owns_file, const void *item_data, int item_data_size, time_t *creation_date, const UT_StringRef &parent_id)
Add a new gallery item to the data source.
std::function< T > UT_Function
UT_WorkBuffer blindData(const UT_StringRef &item_id) const
void startTransaction() const
void removeOwner(const UT_GalleryDataSource *owner)
UT_StringHolder status(const UT_StringRef &item_id) const
A map of string to various well defined value types.
virtual bool setColorTag(const UT_StringRef &item_id, const UT_StringHolder &color_tag)
virtual bool setParentId(const UT_StringRef &item_id, const UT_StringHolder &parent_item_id)
const UT_StringHolder & sourceArgs() const
Return the source args.
virtual bool addTag(const UT_StringRef &item_id, const char *tag)
virtual bool createTag(const char *tag)
bool ownsFile(const UT_StringRef &item_id) const
virtual bool setBlindData(const UT_StringRef &item_id, const void *data, int data_size)
time_t modificationDate(const UT_StringRef &item_id) const
**If you just want to fire and args
UT_Map< const UT_GalleryDataSource *, UT_StringSet > myOwnerUpdatedIds
UT_StringHolder infoHtml() const
Return HTML formatted info about the data source.
void clear()
Resets list to an empty list.
UT_StringSet tags(const UT_StringRef &item_id) const
UT_Function< bool(const UT_StringHolder &)> ValidatorFunc
virtual bool setModificationDate(const UT_StringRef &item_id, time_t timestamp)
virtual bool removeTag(const UT_StringRef &item_id, const char *tag) const
bool isReadOnly() const
Return true if the source implementation is read only.
virtual bool setLabel(const UT_StringRef &item_id, const UT_StringHolder &label)