digiKam
Digikam::TagsCache Class Reference
+ Inheritance diagram for Digikam::TagsCache:

Public Types

enum  HiddenTagsPolicy { NoHiddenTags , IncludeHiddenTags }
 
enum  LeadingSlashPolicy { NoLeadingSlash , IncludeLeadingSlash }
 

Signals

void tagAboutToBeDeleted (QString name)
 
void tagAdded (int tagId)
 
void tagDeleted (int tagId)
 

Public Member Functions

bool canBeWrittenToMetadata (int tagId) const
 
int colorLabelForTag (int tagId)
 
int colorLabelFromTags (QList< int > tagIds)
 
QVector< int > colorLabelTags ()
 
bool containsPublicTags (const QList< int > &tagIds) const
 
int createTag (const QString &tagPathToCreate)
 
QList< int > createTags (const QStringList &tagPaths)
 
int getOrCreateInternalTag (const QString &tagName)
 
int getOrCreateTag (const QString &tagPath)
 
QList< int > getOrCreateTags (const QStringList &tagPaths)
 
int getOrCreateTagWithProperty (const QString &tagPath, const QString &property, const QString &value=QString())
 
bool hasProperty (int tagId, const QString &property, const QString &value=QString()) const
 
bool hasTag (int id) const
 
bool isInternalTag (int tagId) const
 
int parentTag (int id) const
 
QList< int > parentTags (int id) const
 
int pickLabelForTag (int tagId)
 
int pickLabelFromTags (QList< int > tagIds)
 
QVector< int > pickLabelTags ()
 
QMap< QString, QString > properties (int tagId) const
 
QString propertyValue (int tagId, const QString &property) const
 
QStringList propertyValues (int tagId, const QString &property) const
 
QList< int > publicTags (const QList< int > &tagIds) const
 
QStringList shortenedTagPaths (const QList< int > &ids, LeadingSlashPolicy slashPolicy=IncludeLeadingSlash, HiddenTagsPolicy hiddenTagsPolicy=IncludeHiddenTags) const
 
QStringList shortenedTagPaths (const QList< int > &ids, QList< int > *sortedIds, LeadingSlashPolicy slashPolicy=IncludeLeadingSlash, HiddenTagsPolicy hiddenTagsPolicy=IncludeHiddenTags) const
 
int tagForColorLabel (int label)
 
int tagForName (const QString &tagName, int parentId=0) const
 
int tagForPath (const QString &path) const
 
int tagForPickLabel (int label)
 
QString tagName (int id) const
 
QStringList tagNames (const QList< int > &ids, HiddenTagsPolicy hiddenTagsPolicy=IncludeHiddenTags) const
 
QString tagPath (int id, LeadingSlashPolicy slashPolicy=IncludeLeadingSlash) const
 
QStringList tagPaths (const QList< int > &ids, LeadingSlashPolicy slashPolicy=IncludeLeadingSlash, HiddenTagsPolicy hiddenTagsPolicy=IncludeHiddenTags) const
 
QList< int > tagsContaining (const QString &fragment, Qt::CaseSensitivity caseSensitivity=Qt::CaseInsensitive, HiddenTagsPolicy hiddenTagsPolicy=NoHiddenTags)
 
QList< int > tagsForName (const QString &tagName, HiddenTagsPolicy hiddenTagsPolicy=NoHiddenTags) const
 
QList< int > tagsForPaths (const QStringList &tagPaths) const
 
QList< int > tagsStartingWith (const QString &begin, Qt::CaseSensitivity caseSensitivity=Qt::CaseInsensitive, HiddenTagsPolicy hiddenTagsPolicy=NoHiddenTags)
 
QList< int > tagsWithProperty (const QString &property, const QString &value=QString()) const
 
QList< int > tagsWithPropertyCached (const QString &property) const
 

Static Public Member Functions

static TagsCacheinstance ()
 
static QLatin1String propertyNameDigikamInternalTag ()
 
static QLatin1String propertyNameExcludedFromWriting ()
 
static QLatin1String tagPathOfDigikamInternalTags (LeadingSlashPolicy slashPolicy=IncludeLeadingSlash)
 

Friends

class ChangingDB
 
class CoreDbAccess
 
class TagsCacheCreator
 

Member Enumeration Documentation

◆ HiddenTagsPolicy

Enumerator
NoHiddenTags 
IncludeHiddenTags 

◆ LeadingSlashPolicy

Enumerator
NoLeadingSlash 

Ex: "Places/Cities/Paris".

IncludeLeadingSlash 

Ex: "/Places/Cities/Paris".

Member Function Documentation

◆ canBeWrittenToMetadata()

bool Digikam::TagsCache::canBeWrittenToMetadata ( int  tagId) const

Returns if a tag shall be written to the metadata of a file. Always returns false if the tag is a program-internal tag.

References isInternalTag(), propertyNameExcludedFromWriting(), and tagsWithPropertyCached().

Referenced by Digikam::MetadataHub::writeToBaloo().

◆ colorLabelForTag()

int Digikam::TagsCache::colorLabelForTag ( int  tagId)

Return color label id corresponding of internal tags ID. see ColorLabel values from globals.h. Return -1 if not it's found.

Referenced by Digikam::SearchFieldLabels::read().

◆ colorLabelFromTags()

int Digikam::TagsCache::colorLabelFromTags ( QList< int >  tagIds)

From the given list of tags, returns the color label corresponding to the first encountered tag which is a color label tag. Returns -1 if no tag in the list is a color label tag.

References Digikam::FirstColorLabel, and Digikam::LastColorLabel.

Referenced by Digikam::ItemInfo::colorLabel().

◆ colorLabelTags()

QVector< int > Digikam::TagsCache::colorLabelTags ( )

Returns all color label tags, where index is the label id and value the tag id.

Referenced by Digikam::ItemScanner::commitTags(), and Digikam::ItemInfo::setColorLabel().

◆ containsPublicTags()

bool Digikam::TagsCache::containsPublicTags ( const QList< int > &  tagIds) const

Returns true if the given list of tag ids contains at least one non-internal tag

Referenced by Digikam::ItemFilterSettings::matches().

◆ createTag()

int Digikam::TagsCache::createTag ( const QString &  tagPathToCreate)

Add the tag described by the given tag path, and all missing parent tags, to the database. Returns the tag id. Use this if you know that tag path does not exist. If you are unsure, use getOrCreateTag.

References Digikam::CoreDB::addTag(), Digikam::CoreDbAccess::db(), QT_SKIP_EMPTY_PARTS, and tagName().

Referenced by createTags(), and getOrCreateTag().

◆ createTags()

QList< int > Digikam::TagsCache::createTags ( const QStringList &  tagPaths)

References createTag(), and tagPaths().

◆ getOrCreateInternalTag()

◆ getOrCreateTag()

int Digikam::TagsCache::getOrCreateTag ( const QString &  tagPath)

A combination of tagForPath and createTag: Finds ids for the given tagPaths. If a tag does not exist yet and create is true, it will be created. Otherwise the id 0 is returned for this path.

References createTag(), tagForPath(), and tagPath().

Referenced by Digikam::TagProperties::getOrCreate(), getOrCreateTags(), getOrCreateTagWithProperty(), Digikam::FaceTags::ignoredPersonTagId(), Digikam::FaceTags::personParentTag(), Digikam::FaceTags::unconfirmedPersonTagId(), and Digikam::FaceTags::unknownPersonTagId().

◆ getOrCreateTags()

QList< int > Digikam::TagsCache::getOrCreateTags ( const QStringList &  tagPaths)

◆ getOrCreateTagWithProperty()

int Digikam::TagsCache::getOrCreateTagWithProperty ( const QString &  tagPath,
const QString &  property,
const QString &  value = QString() 
)

Calls getOrCreateTag for the given path, and ensures that the tag has assigned the given property. If you pass a null string as value, then the value is not checked and not changed.

References getOrCreateTag(), hasProperty(), Digikam::TagProperties::setProperty(), tagPath(), and value.

Referenced by getOrCreateInternalTag().

◆ hasProperty()

bool Digikam::TagsCache::hasProperty ( int  tagId,
const QString &  property,
const QString &  value = QString() 
) const

Tests if the tag has the given property a) just has the property b) has the property with the given value (value not null)

References value.

Referenced by getOrCreateTagWithProperty(), Digikam::TAlbum::hasProperty(), Digikam::FaceTags::isPerson(), Digikam::FaceTags::isTheIgnoredPerson(), Digikam::FaceTags::isTheUnconfirmedPerson(), and Digikam::FaceTags::isTheUnknownPerson().

◆ hasTag()

bool Digikam::TagsCache::hasTag ( int  id) const

Returns true if the tag for the given id exists.

◆ instance()

TagsCache * Digikam::TagsCache::instance ( )
static

Referenced by Digikam::TaggingActionFactory::actions(), Digikam::CoreDB::addItemTag(), Digikam::ContextMenuHelper::addRemoveTagsMenu(), Digikam::ItemInfo::addTagPaths(), Digikam::FaceTags::allPersonNames(), Digikam::FaceTags::allPersonPaths(), Digikam::FaceTags::allPersonTags(), Digikam::ItemInfo::colorLabel(), Digikam::ItemScanner::commitImageHistory(), Digikam::ItemScanner::commitTags(), Digikam::CollectionScanner::completeHistoryScanning(), Digikam::CollectionScanner::copyFileProperties(), Digikam::TaggingActionFactory::defaultTaggingAction(), Digikam::FaceTags::faceNameForTag(), Digikam::AlbumManager::findOrCreateTAlbums(), Digikam::AlbumManager::findTagsWithProperty(), Digikam::ColorLabelFilter::getCheckedColorLabelTags(), Digikam::PickLabelFilter::getCheckedPickLabelTags(), Digikam::CoreDB::getItemsURLsWithTag(), Digikam::TagProperties::getOrCreate(), Digikam::TAlbum::hasProperty(), Digikam::FaceTags::identityAttributes(), Digikam::FaceTags::ignoredPersonTagId(), Digikam::TAlbum::isInternalTag(), Digikam::FaceTags::isPerson(), Digikam::FaceTags::isTheIgnoredPerson(), Digikam::FaceTags::isTheUnconfirmedPerson(), Digikam::FaceTags::isTheUnknownPerson(), Digikam::CollectionScanner::itemsWereRemoved(), Digikam::DisjointMetadata::keywords(), Digikam::ItemLister::listFaces(), Digikam::MetadataHub::loadTags(), Digikam::DisjointMetadata::Private::makeConnections(), Digikam::ItemFilterSettings::matches(), Digikam::FaceTags::personParentTag(), Digikam::ItemInfo::pickLabel(), Digikam::TAlbum::properties(), Digikam::TAlbum::property(), Digikam::SearchFieldAlbum::read(), Digikam::SearchFieldLabels::read(), Digikam::TagsActionMngr::registerTagsActionCollections(), Digikam::ItemScanner::resolveImageHistory(), Digikam::RecognitionBenchmarker::result(), Digikam::ItemGPS::saveChanges(), Digikam::ItemScanner::scanBalooInfo(), Digikam::FaceTags::scannedForFacesTagId(), Digikam::ItemScanner::scanTags(), Digikam::ItemInfo::setColorLabel(), Digikam::CoreDbAccess::setParameters(), Digikam::ItemInfo::setPickLabel(), Digikam::VersionItemFilterSettings::setVersionManagerSettings(), Digikam::ShowHideVersionsOverlay::slotClicked(), Digikam::TaggingActionFactory::suggestedUIString(), Digikam::ItemScanner::tagItemHistoryGraph(), Digikam::DisjointMetadata::tagStatus(), Digikam::FaceTagsIface::typeForAttribute(), Digikam::FaceTags::unconfirmedPersonTagId(), Digikam::FaceTags::unknownPersonTagId(), Digikam::TagCompleter::update(), Digikam::TagsActionMngr::updateTagShortcut(), Digikam::MetadataHub::writeTags(), and Digikam::MetadataHub::writeToBaloo().

◆ isInternalTag()

bool Digikam::TagsCache::isInternalTag ( int  tagId) const

Returns if a tag is to be regarded program-internal, that is, a technical implementation detail not visible to the user at any time.

Referenced by canBeWrittenToMetadata(), Digikam::TAlbum::isInternalTag(), shortenedTagPaths(), tagNames(), and tagPaths().

◆ parentTag()

int Digikam::TagsCache::parentTag ( int  id) const

Returns the parent tag id, or 0 if a toplevel tag or tag does not exist.

Referenced by Digikam::TaggingActionFactory::suggestedUIString().

◆ parentTags()

QList< int > Digikam::TagsCache::parentTags ( int  id) const

Returns the parent tag ids of the given tag, starting with the toplevel tag, ending with the direct parent tag. If the tag is a toplevel tag or does not exist, an empty list is returned.

Referenced by Digikam::FaceTags::personParentTag().

◆ pickLabelForTag()

int Digikam::TagsCache::pickLabelForTag ( int  tagId)

Return pick label id corresponding of internal tags ID. see PickLabel values from globals.h. Return -1 if not it's found.

Referenced by Digikam::SearchFieldLabels::read().

◆ pickLabelFromTags()

int Digikam::TagsCache::pickLabelFromTags ( QList< int >  tagIds)

From the given list of tags, returns the pick label corresponding to the first encountered tag which is a pick label tag. Returns -1 if no tag in the list is a pick label tag.

References Digikam::FirstPickLabel, and Digikam::LastPickLabel.

Referenced by Digikam::ItemInfo::pickLabel().

◆ pickLabelTags()

QVector< int > Digikam::TagsCache::pickLabelTags ( )

Returns all pick label tags, where index is the label id and value the tag id.

Referenced by Digikam::ItemScanner::commitTags(), and Digikam::ItemInfo::setPickLabel().

◆ properties()

QMap< QString, QString > Digikam::TagsCache::properties ( int  tagId) const

Returns a list or a map of the properties of the tag. Note: The list and map may be constructed for each call. Prefer hasProperty() and property().

Referenced by Digikam::TAlbum::properties().

◆ propertyNameDigikamInternalTag()

QLatin1String Digikam::TagsCache::propertyNameDigikamInternalTag ( )
static

Referenced by getOrCreateInternalTag().

◆ propertyNameExcludedFromWriting()

QLatin1String Digikam::TagsCache::propertyNameExcludedFromWriting ( )
static

Referenced by canBeWrittenToMetadata().

◆ propertyValue()

QString Digikam::TagsCache::propertyValue ( int  tagId,
const QString &  property 
) const

Returns the value of the property. Returning a null string cannot distinguish between the property set with a null value, or the property not set. The first method returns any property, if multiple are set with the same key.

Referenced by Digikam::FaceTags::faceNameForTag(), Digikam::FaceTags::identityAttributes(), Digikam::TAlbum::property(), and Digikam::TagsActionMngr::updateTagShortcut().

◆ propertyValues()

QStringList Digikam::TagsCache::propertyValues ( int  tagId,
const QString &  property 
) const

◆ publicTags()

QList< int > Digikam::TagsCache::publicTags ( const QList< int > &  tagIds) const

From the given list of tag ids, filter out any internal tags and return only public tags.

◆ shortenedTagPaths() [1/2]

QStringList Digikam::TagsCache::shortenedTagPaths ( const QList< int > &  ids,
LeadingSlashPolicy  slashPolicy = IncludeLeadingSlash,
HiddenTagsPolicy  hiddenTagsPolicy = IncludeHiddenTags 
) const

Utility method. Orders the given tag paths. If tags begin with the same path (parent tags), the relevant part is cut off in the second line. The second variant allows you to pass a list as return parameter. This list will contain, upon return, the tag id corresponding to each tag in the returned, sorted list of shortened paths.

References Digikam::ItemPropertiesTab::shortenedTagPaths(), and tagPaths().

◆ shortenedTagPaths() [2/2]

QStringList Digikam::TagsCache::shortenedTagPaths ( const QList< int > &  ids,
QList< int > *  sortedIds,
LeadingSlashPolicy  slashPolicy = IncludeLeadingSlash,
HiddenTagsPolicy  hiddenTagsPolicy = IncludeHiddenTags 
) const

◆ tagAboutToBeDeleted

void Digikam::TagsCache::tagAboutToBeDeleted ( QString  name)
signal

◆ tagAdded

void Digikam::TagsCache::tagAdded ( int  tagId)
signal

These signals are provided for convenience; for finer grained information use CoreDbWatch. Use a queued connection if you carry out longer operations from slots connected to these signals.

◆ tagDeleted

void Digikam::TagsCache::tagDeleted ( int  tagId)
signal

◆ tagForColorLabel()

int Digikam::TagsCache::tagForColorLabel ( int  label)

Return internal tags ID corresponding of color label id. see ColorLabel values from globals.h. Return 0 if not it's found.

References Digikam::FirstColorLabel, and Digikam::LastColorLabel.

Referenced by Digikam::ColorLabelFilter::getCheckedColorLabelTags(), Digikam::CoreDB::getItemsURLsWithTag(), Digikam::ItemFilterSettings::matches(), and Digikam::ItemScanner::scanTags().

◆ tagForName()

int Digikam::TagsCache::tagForName ( const QString &  tagName,
int  parentId = 0 
) const

Returns the id of the tag with the given name and parent tag. If parentId is 0, the tag is a toplevel tag. Returns 0 if there is no such tag.

References tagName().

Referenced by Digikam::TaggingActionFactory::defaultTaggingAction().

◆ tagForPath()

int Digikam::TagsCache::tagForPath ( const QString &  path) const

Returns the tag matched exactly by the given path. The path can be given with or without leading slash. Returns 0 if there is no such tag, or if path is empty. If you want to create the tag if it does not yet exist, use getOrCreateTag.

References NoLeadingSlash, QT_SKIP_EMPTY_PARTS, and tagName().

Referenced by getOrCreateTag(), Digikam::ItemLister::listFaces(), Digikam::FaceTags::personParentTag(), and tagsForPaths().

◆ tagForPickLabel()

int Digikam::TagsCache::tagForPickLabel ( int  label)

Return internal tags ID corresponding of pick label id. see PickLabel values from globals.h. Return 0 if not it's found.

References Digikam::FirstPickLabel, and Digikam::LastPickLabel.

Referenced by Digikam::PickLabelFilter::getCheckedPickLabelTags(), Digikam::CoreDB::getItemsURLsWithTag(), Digikam::ItemFilterSettings::matches(), and Digikam::ItemScanner::scanTags().

◆ tagName()

QString Digikam::TagsCache::tagName ( int  id) const

◆ tagNames()

QStringList Digikam::TagsCache::tagNames ( const QList< int > &  ids,
HiddenTagsPolicy  hiddenTagsPolicy = IncludeHiddenTags 
) const

◆ tagPath()

QString Digikam::TagsCache::tagPath ( int  id,
LeadingSlashPolicy  slashPolicy = IncludeLeadingSlash 
) const

Returns the path of the tag with the given id. For the tag Places/Cities/Paris, this is Places/Cities/Paris. If there is no tag for the given id a null string is returned.

References IncludeLeadingSlash.

Referenced by Digikam::TaggingActionFactory::defaultTaggingAction(), getOrCreateTag(), getOrCreateTagWithProperty(), shortenedTagPaths(), Digikam::TaggingActionFactory::suggestedUIString(), tagPaths(), Digikam::MetadataHub::writeTags(), and Digikam::MetadataHub::writeToBaloo().

◆ tagPathOfDigikamInternalTags()

QLatin1String Digikam::TagsCache::tagPathOfDigikamInternalTags ( LeadingSlashPolicy  slashPolicy = IncludeLeadingSlash)
static

References IncludeLeadingSlash.

Referenced by getOrCreateInternalTag().

◆ tagPaths()

QStringList Digikam::TagsCache::tagPaths ( const QList< int > &  ids,
LeadingSlashPolicy  slashPolicy = IncludeLeadingSlash,
HiddenTagsPolicy  hiddenTagsPolicy = IncludeHiddenTags 
) const

◆ tagsContaining()

QList< int > Digikam::TagsCache::tagsContaining ( const QString &  fragment,
Qt::CaseSensitivity  caseSensitivity = Qt::CaseInsensitive,
HiddenTagsPolicy  hiddenTagsPolicy = NoHiddenTags 
)

Returns a list of tag ids whose tag name (not path) starts with / contains the given fragment

Referenced by Digikam::TaggingActionFactory::actions().

◆ tagsForName()

QList< int > Digikam::TagsCache::tagsForName ( const QString &  tagName,
HiddenTagsPolicy  hiddenTagsPolicy = NoHiddenTags 
) const

Finds all tags with the given name. For "Paris", this may give "Places/Cities/Paris" and "Places/USA/Texas/Paris". If there is no tag with the given name at all, returns an empty list.

References NoHiddenTags, and tagName().

Referenced by Digikam::TaggingActionFactory::defaultTaggingAction().

◆ tagsForPaths()

QList< int > Digikam::TagsCache::tagsForPaths ( const QStringList &  tagPaths) const

References tagForPath(), and tagPaths().

Referenced by Digikam::ItemInfo::addTagPaths().

◆ tagsStartingWith()

QList< int > Digikam::TagsCache::tagsStartingWith ( const QString &  begin,
Qt::CaseSensitivity  caseSensitivity = Qt::CaseInsensitive,
HiddenTagsPolicy  hiddenTagsPolicy = NoHiddenTags 
)

◆ tagsWithProperty()

QList< int > Digikam::TagsCache::tagsWithProperty ( const QString &  property,
const QString &  value = QString() 
) const

Finds all tags with the given property. The tag a)just has the property b) has the property with the given value (value not null) Note: The returned list is sorted.

References value.

Referenced by Digikam::FaceTags::allPersonTags(), Digikam::AlbumManager::findTagsWithProperty(), Digikam::TagsActionMngr::registerTagsActionCollections(), and tagsWithPropertyCached().

◆ tagsWithPropertyCached()

QList< int > Digikam::TagsCache::tagsWithPropertyCached ( const QString &  property) const

This method is equivalent to calling tagsWithProperty(property), but the immediate result will be cached for subsequent calls. Use it for queries for which you know that they will be issued very often, so that it's worth caching the result of the already pretty fast tagsWithProperty().

References tagsWithProperty().

Referenced by canBeWrittenToMetadata(), Digikam::FaceTags::ignoredPersonTagId(), Digikam::FaceTags::unconfirmedPersonTagId(), and Digikam::FaceTags::unknownPersonTagId().

Friends And Related Function Documentation

◆ ChangingDB

friend class ChangingDB
friend

◆ CoreDbAccess

friend class CoreDbAccess
friend

◆ TagsCacheCreator

friend class TagsCacheCreator
friend

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