HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_GalleryDataSource Class Reference

#include <UT_GalleryDataSource.h>

Public Types

typedef UT_Function< bool(const
UT_StringHolder &)> 
ValidatorFunc
 
typedef UT_Function
< UT_SharedPtr
< UT_GalleryDataSourceImpl >
const UT_StringHolder
&, const UT_StringHolder &)> 
CreatorFunc
 

Public Member Functions

 UT_GalleryDataSource (const UT_StringHolder &source_identifier, const UT_StringHolder &args)
 
 ~UT_GalleryDataSource ()
 
bool isValid () const
 
bool isReadOnly () const
 Return true if the source implementation is read only. More...
 
const UT_StringHoldersourceIdentifier () const
 Return the source identifier. More...
 
const UT_StringHoldersourceArgs () const
 Return the source args. More...
 
UT_StringHolder infoHtml () const
 Return HTML formatted info about the data source. More...
 
void startTransaction () const
 
void endTransaction (bool commit=true) const
 
void itemIds (UT_StringArray &item_ids) const
 Populate an array with all valid item ids. More...
 
void updatedItemIds (UT_StringArray &item_ids)
 
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'. More...
 
UT_StringHolder sourceTypeName (const UT_StringRef &item_id) const
 Return the source type. More...
 
UT_StringHolder typeName (const UT_StringRef &item_id) const
 
UT_StringHolder label (const UT_StringRef &item_id) const
 
UT_WorkBuffer thumbnail (const UT_StringRef &item_id) const
 
time_t creationDate (const UT_StringRef &item_id) const
 
time_t modificationDate (const UT_StringRef &item_id) const
 
bool isStarred (const UT_StringRef &item_id) const
 
UT_StringHolder colorTag (const UT_StringRef &item_id) const
 
UT_StringSet tags (const UT_StringRef &item_id) const
 
UT_Options metadata (const UT_StringRef &item_id) const
 
UT_StringHolder filePath (const UT_StringRef &item_id) const
 
bool ownsFile (const UT_StringRef &item_id) const
 
UT_WorkBuffer blindData (const UT_StringRef &item_id) const
 
UT_StringHolder status (const UT_StringRef &item_id) const
 
UT_StringHolder parentId (const UT_StringRef &item_id) const
 
UT_StringHolder prepareItemForUse (const UT_StringRef &item_id) const
 
bool setLabel (const UT_StringRef &item_id, const UT_StringHolder &label)
 
bool setThumbnail (const UT_StringRef &item_id, const UT_WorkBuffer &thumbnail)
 
bool setModificationDate (const UT_StringRef &item_id, time_t timestamp)
 
bool setIsStarred (const UT_StringRef &item_id, bool isstarred)
 
bool setColorTag (const UT_StringRef &item_id, const UT_StringHolder &color_tag)
 
bool setMetadata (const UT_StringRef &item_id, const UT_Options &metadata)
 
bool setFilePath (const UT_StringRef &item_id, const char *file_path)
 
bool setOwnsFile (const UT_StringRef &item_id, bool owns_file)
 
bool setBlindData (const UT_StringRef &item_id, const void *data, int data_size)
 
bool setStatus (const UT_StringRef &item_id, const UT_StringHolder &status)
 
bool setParentId (const UT_StringRef &item_id, const UT_StringRef &parent_item_id)
 
bool createTag (const char *tag)
 
bool deleteTag (const char *tag, bool delete_if_assigned)
 
bool addTag (const UT_StringRef &item_id, const char *tag)
 
bool removeTag (const UT_StringRef &item_id, const char *tag)
 
UT_StringHolder generateItemFilePath (const UT_StringRef &item_id, const char *file_ext)
 
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=nullptr, bool item_owns_file=false, const void *item_data=nullptr, int item_data_size=0, time_t *creation_date=nullptr, const UT_StringRef &parent_id=UT_StringHolder::theEmptyString)
 Add a new gallery item to the data source. More...
 
bool markItemsForDeletion (const UT_StringArray &item_ids)
 
bool unmarkItemsForDeletion (const UT_StringArray &item_ids)
 
bool saveAs (const UT_StringHolder &source_identifier)
 

Static Public Member Functions

static void registerDataSourceImplementation (const ValidatorFunc &validator, const CreatorFunc &creator)
 

Detailed Description

Provides a stable API for QT_GalleryModel and its subclasses for populating the model from a variety of data sources. Provides a plugin architecture for adding new UT_GalleryDataSourceImpl subclasses which are constructed based on the source_identifier sent to this object's constructor. Also provides a global registry of UT_GalleryDataSource objects, so there is always only one data source created for a given source_identifier.

Definition at line 207 of file UT_GalleryDataSource.h.

Member Typedef Documentation

Constructor & Destructor Documentation

UT_GalleryDataSource::UT_GalleryDataSource ( const UT_StringHolder source_identifier,
const UT_StringHolder args 
)
UT_GalleryDataSource::~UT_GalleryDataSource ( )

Member Function Documentation

UT_StringHolder UT_GalleryDataSource::addItem ( const UT_StringRef item_type_name,
const UT_StringRef name,
const void thumbnail_data,
int  thumbnail_data_size,
const char *  item_file = nullptr,
bool  item_owns_file = false,
const void item_data = nullptr,
int  item_data_size = 0,
time_t *  creation_date = nullptr,
const UT_StringRef parent_id = UT_StringHolder::theEmptyString 
)

Add a new gallery item to the data source.

bool UT_GalleryDataSource::addTag ( const UT_StringRef item_id,
const char *  tag 
)
UT_WorkBuffer UT_GalleryDataSource::blindData ( const UT_StringRef item_id) const
inline

Definition at line 286 of file UT_GalleryDataSource.h.

void UT_GalleryDataSource::childItemIds ( const UT_StringRef parent_item_id,
UT_StringArray item_ids 
) const
inline

Populate an array with all valid item ids with the given parent 'item_id'.

Definition at line 258 of file UT_GalleryDataSource.h.

UT_StringHolder UT_GalleryDataSource::colorTag ( const UT_StringRef item_id) const
inline

Definition at line 276 of file UT_GalleryDataSource.h.

bool UT_GalleryDataSource::createTag ( const char *  tag)
time_t UT_GalleryDataSource::creationDate ( const UT_StringRef item_id) const
inline

Definition at line 270 of file UT_GalleryDataSource.h.

bool UT_GalleryDataSource::deleteTag ( const char *  tag,
bool  delete_if_assigned 
)
void UT_GalleryDataSource::endTransaction ( bool  commit = true) const
inline

Definition at line 249 of file UT_GalleryDataSource.h.

UT_StringHolder UT_GalleryDataSource::filePath ( const UT_StringRef item_id) const
inline

Definition at line 282 of file UT_GalleryDataSource.h.

UT_StringHolder UT_GalleryDataSource::generateItemFilePath ( const UT_StringRef item_id,
const char *  file_ext 
)

Generates a file path to associate with a particular item id, for cases where the new item needs a new file, as in a snapshot data source (rather than referring to an existing file, as in an asset data source).

UT_StringHolder UT_GalleryDataSource::infoHtml ( ) const
inline

Return HTML formatted info about the data source.

Definition at line 241 of file UT_GalleryDataSource.h.

bool UT_GalleryDataSource::isReadOnly ( ) const
inline

Return true if the source implementation is read only.

Definition at line 232 of file UT_GalleryDataSource.h.

bool UT_GalleryDataSource::isStarred ( const UT_StringRef item_id) const
inline

Definition at line 274 of file UT_GalleryDataSource.h.

bool UT_GalleryDataSource::isValid ( ) const
inline

Return true if this gallery data source owns a valid data source implementation object. You can still call all the methods on an invalid object, but they do nothing. This check allows the UI to present an error message for an invalid source identifier.

Definition at line 229 of file UT_GalleryDataSource.h.

void UT_GalleryDataSource::itemIds ( UT_StringArray item_ids) const
inline

Populate an array with all valid item ids.

Definition at line 253 of file UT_GalleryDataSource.h.

UT_StringHolder UT_GalleryDataSource::label ( const UT_StringRef item_id) const
inline

Definition at line 266 of file UT_GalleryDataSource.h.

bool UT_GalleryDataSource::markItemsForDeletion ( const UT_StringArray item_ids)

Mark items for deletion in the data source. Do nothing for invalid item ids or items that are already marked for deletion.

UT_Options UT_GalleryDataSource::metadata ( const UT_StringRef item_id) const
inline

Definition at line 280 of file UT_GalleryDataSource.h.

time_t UT_GalleryDataSource::modificationDate ( const UT_StringRef item_id) const
inline

Definition at line 272 of file UT_GalleryDataSource.h.

bool UT_GalleryDataSource::ownsFile ( const UT_StringRef item_id) const
inline

Definition at line 284 of file UT_GalleryDataSource.h.

UT_StringHolder UT_GalleryDataSource::parentId ( const UT_StringRef item_id) const
inline

Definition at line 290 of file UT_GalleryDataSource.h.

UT_StringHolder UT_GalleryDataSource::prepareItemForUse ( const UT_StringRef item_id) const
inline

Definition at line 292 of file UT_GalleryDataSource.h.

static void UT_GalleryDataSource::registerDataSourceImplementation ( const ValidatorFunc validator,
const CreatorFunc creator 
)
static
bool UT_GalleryDataSource::removeTag ( const UT_StringRef item_id,
const char *  tag 
)
bool UT_GalleryDataSource::saveAs ( const UT_StringHolder source_identifier)

For file-based sources, does the equivalent of a "save as" operation. The source identifier of the data source should be updated if the implementation's save as operation reports success.

bool UT_GalleryDataSource::setBlindData ( const UT_StringRef item_id,
const void data,
int  data_size 
)
bool UT_GalleryDataSource::setColorTag ( const UT_StringRef item_id,
const UT_StringHolder color_tag 
)
bool UT_GalleryDataSource::setFilePath ( const UT_StringRef item_id,
const char *  file_path 
)
bool UT_GalleryDataSource::setIsStarred ( const UT_StringRef item_id,
bool  isstarred 
)
bool UT_GalleryDataSource::setLabel ( const UT_StringRef item_id,
const UT_StringHolder label 
)
bool UT_GalleryDataSource::setMetadata ( const UT_StringRef item_id,
const UT_Options metadata 
)
bool UT_GalleryDataSource::setModificationDate ( const UT_StringRef item_id,
time_t  timestamp 
)
bool UT_GalleryDataSource::setOwnsFile ( const UT_StringRef item_id,
bool  owns_file 
)
bool UT_GalleryDataSource::setParentId ( const UT_StringRef item_id,
const UT_StringRef parent_item_id 
)
bool UT_GalleryDataSource::setStatus ( const UT_StringRef item_id,
const UT_StringHolder status 
)
bool UT_GalleryDataSource::setThumbnail ( const UT_StringRef item_id,
const UT_WorkBuffer thumbnail 
)
const UT_StringHolder& UT_GalleryDataSource::sourceArgs ( ) const
inline

Return the source args.

Definition at line 238 of file UT_GalleryDataSource.h.

const UT_StringHolder& UT_GalleryDataSource::sourceIdentifier ( ) const
inline

Return the source identifier.

Definition at line 235 of file UT_GalleryDataSource.h.

UT_StringHolder UT_GalleryDataSource::sourceTypeName ( const UT_StringRef item_id) const
inline

Return the source type.

Definition at line 262 of file UT_GalleryDataSource.h.

void UT_GalleryDataSource::startTransaction ( ) const
inline

Begins/ends transactions so that functions which end up generating large numbers of queries/modifications can be more efficient.

Definition at line 247 of file UT_GalleryDataSource.h.

UT_StringHolder UT_GalleryDataSource::status ( const UT_StringRef item_id) const
inline

Definition at line 288 of file UT_GalleryDataSource.h.

UT_StringSet UT_GalleryDataSource::tags ( const UT_StringRef item_id) const
inline

Definition at line 278 of file UT_GalleryDataSource.h.

UT_WorkBuffer UT_GalleryDataSource::thumbnail ( const UT_StringRef item_id) const
inline

Definition at line 268 of file UT_GalleryDataSource.h.

UT_StringHolder UT_GalleryDataSource::typeName ( const UT_StringRef item_id) const
inline

Definition at line 264 of file UT_GalleryDataSource.h.

bool UT_GalleryDataSource::unmarkItemsForDeletion ( const UT_StringArray item_ids)

Unmark items for deletion in the data source. Do nothing for invalid item ids or items that are not marked for deletion.

void UT_GalleryDataSource::updatedItemIds ( UT_StringArray item_ids)

The documentation for this class was generated from the following file: