digiKam
Digikam::MetadataHub Class Reference

Public Types

enum  Status { MetadataInvalid , MetadataAvailable }
 
enum  WriteComponents {
  WRITE_DATETIME = 1 , WRITE_TITLE = 2 , WRITE_COMMENTS = 4 , WRITE_PICKLABEL = 8 ,
  WRITE_COLORLABEL = 16 , WRITE_RATING = 32 , WRITE_TEMPLATE = 64 , WRITE_TAGS = 128 ,
  WRITE_POSITION = 256 , WRITE_ALL = 511
}
 
enum  WriteMode { FullWrite , FullWriteIfChanged , PartialWrite }
 

Public Member Functions

QStringList cleanupTags (const QStringList &toClean)
 cleanupTags - remove duplicates and obsolete tags before setting metadata More...
 
QMultiMap< QString, QVariant > getFaceTags ()
 
void load (const ItemInfo &info)
 
void loadFaceTags (const ItemInfo &info, const QSize &size)
 
 MetadataHub ()
 
void reset ()
 
void setFaceTags (QMultiMap< QString, QVariant > newFaceTags, QSize size)
 
bool willWriteMetadata (Digikam::MetadataHub::WriteComponent writeMode=WRITE_ALL, const MetaEngineSettingsContainer &settings=MetaEngineSettings::instance() ->settings()) const
 
bool write (const DImg &image, WriteComponent writeMode=WRITE_ALL, bool ignoreLazySync=false, const MetaEngineSettingsContainer &settings=MetaEngineSettings::instance() ->settings())
 
bool write (const QString &filePath, WriteComponent writeMode=WRITE_ALL, bool ignoreLazySync=false, const MetaEngineSettingsContainer &settings=MetaEngineSettings::instance() ->settings())
 
bool writeTags (const DMetadata &metadata, bool saveTags)
 writeTags - used to deduplicate code from writeTags and usual write, all write to tags operations must be done here More...
 
bool writeTags (const QString &filePath, WriteComponent writeMode=WRITE_ALL, const MetaEngineSettingsContainer &settings=MetaEngineSettings::instance() ->settings())
 
void writeToBaloo (const QString &filePath, const MetaEngineSettingsContainer &settings=MetaEngineSettings::instance() ->settings())
 writeToBaloo - write tags, comments and rating to KDE Nepomuk replacement: Baloo More...
 
bool writeToMetadata (const ItemInfo &info, WriteComponent writeMode=WRITE_ALL, bool ignoreLazySync=false, const MetaEngineSettingsContainer &settings=MetaEngineSettings::instance() ->settings())
 writeToMetadata - write to metadata using image info to retrieve tags and filepath use this method when multiple image infos are loaded in hub More...
 
 ~MetadataHub ()
 

Protected Member Functions

void applyChangeNotifications ()
 
void load (const QDateTime &dateTime, const CaptionsMap &titles, const CaptionsMap &comment, int colorLabel, int pickLabel, int rating, const Template &t)
 
void loadTags (const QList< int > &loadedTagIds)
 
void loadTags (const QStringList &loadedTagPaths)
 
void notifyTagDeleted (int id)
 
bool write (DMetadata &metadata, WriteComponent writeMode=WRITE_ALL, const MetaEngineSettingsContainer &settings=MetaEngineSettings::instance() ->settings())
 

Member Enumeration Documentation

◆ Status

The status enum describes the result of joining several metadata sets. If only one set has been added, the status is always MetadataAvailable. If no set has been added, the status is always MetadataInvalid

Enumerator
MetadataInvalid 

not yet filled with any value

MetadataAvailable 

only one data set has been added, or a common value is available

◆ WriteComponents

Enumerator
WRITE_DATETIME 
WRITE_TITLE 
WRITE_COMMENTS 
WRITE_PICKLABEL 
WRITE_COLORLABEL 
WRITE_RATING 
WRITE_TEMPLATE 
WRITE_TAGS 
WRITE_POSITION 
WRITE_ALL 

◆ WriteMode

Enumerator
FullWrite 

Write all available information

FullWriteIfChanged 

Do a full write if and only if

  • metadata fields changed
  • the changed fields shall be written according to write settings "Changed" in this context means changed by one of the set... methods, the load() methods are ignored for this attribute. This mode allows to avoid write operations when e.g. the user does not want keywords to be written and only changes keywords.
PartialWrite 

Write only the changed parts. Metadata fields which cannot be changed from MetadataHub (photographer ID etc.) will never be written

Constructor & Destructor Documentation

◆ MetadataHub()

Digikam::MetadataHub::MetadataHub ( )

Constructs a MetadataHub.

◆ ~MetadataHub()

Digikam::MetadataHub::~MetadataHub ( )

Member Function Documentation

◆ applyChangeNotifications()

void Digikam::MetadataHub::applyChangeNotifications ( )
protected

Referenced by write(), writeTags(), and writeToMetadata().

◆ cleanupTags()

QStringList Digikam::MetadataHub::cleanupTags ( const QStringList &  toClean)

cleanupTags - remove duplicates and obsolete tags before setting metadata

Parameters
toClean- tag list to be cleared and de-duplicated
Returns
- clean tag list

Referenced by writeTags(), and writeToBaloo().

◆ getFaceTags()

QMultiMap< QString, QVariant > Digikam::MetadataHub::getFaceTags ( )

Get face tag names and face tag regions. This is used for metadata synchronization in Image Editor

◆ load() [1/2]

◆ load() [2/2]

void Digikam::MetadataHub::load ( const QDateTime &  dateTime,
const CaptionsMap titles,
const CaptionsMap comments,
int  colorLabel,
int  pickLabel,
int  rating,
const Template t 
)
protected

private common code to load dateTime, comment, color label, pick label, rating

◆ loadFaceTags()

void Digikam::MetadataHub::loadFaceTags ( const ItemInfo info,
const QSize &  size 
)

◆ loadTags() [1/2]

void Digikam::MetadataHub::loadTags ( const QList< int > &  loadedTags)
protected

private common code to merge tags

References Digikam::TagsCache::instance(), and MetadataAvailable.

Referenced by load().

◆ loadTags() [2/2]

void Digikam::MetadataHub::loadTags ( const QStringList &  loadedTagPaths)
protected

◆ notifyTagDeleted()

void Digikam::MetadataHub::notifyTagDeleted ( int  id)
protected

◆ reset()

void Digikam::MetadataHub::reset ( )

◆ setFaceTags()

void Digikam::MetadataHub::setFaceTags ( QMultiMap< QString, QVariant >  newFaceTags,
QSize  size 
)

Set new face tags

References Digikam::TagRegion::absoluteToRelative().

◆ willWriteMetadata()

◆ write() [1/3]

bool Digikam::MetadataHub::write ( const DImg image,
WriteComponent  writeMode = WRITE_ALL,
bool  ignoreLazySync = false,
const MetaEngineSettingsContainer settings = MetaEngineSettings::instance()->settings() 
)

Constructs a meta engine object from the metadata stored in the given DImg object, calls the above method, and changes the stored metadata in the DImg object.

Returns
Returns if the DImg object has been touched

References Digikam::MetadataHubMngr::addPending(), applyChangeNotifications(), Digikam::ItemInfo::fromLocalFile(), Digikam::DImg::getMetadata(), Digikam::MetadataHubMngr::instance(), Digikam::DImg::lastSavedFilePath(), Digikam::DImg::originalFilePath(), Digikam::MetaEngineSettingsContainer::useLazySync, willWriteMetadata(), write(), and writeToBaloo().

◆ write() [2/3]

bool Digikam::MetadataHub::write ( const QString &  filePath,
WriteComponent  writeMode = WRITE_ALL,
bool  ignoreLazySync = false,
const MetaEngineSettingsContainer settings = MetaEngineSettings::instance()->settings() 
)

Constructs a meta engine object for given filePath, calls the above method, writes the changes out to the file, and notifies the ItemAttributesWatch. WARNING: Do not use this method when multiple image infos are loaded It will result in disjoint tags not being written Use writeToMetadata(Image info ...) instead

Returns
Returns if the file has been touched

References Digikam::MetadataHubMngr::addPending(), applyChangeNotifications(), Digikam::ItemAttributesWatch::fileMetadataChanged(), Digikam::ItemInfo::fromLocalFile(), Digikam::ItemAttributesWatch::instance(), Digikam::MetadataHubMngr::instance(), Digikam::MetaEngineSettingsContainer::useLazySync, willWriteMetadata(), and writeToBaloo().

Referenced by Digikam::FaceGroup::rejectAll(), Digikam::MetadataTask::run(), Digikam::FileActionMngrFileWorker::transform(), write(), Digikam::FileActionMngrFileWorker::writeMetadataToFiles(), and writeToMetadata().

◆ write() [3/3]

bool Digikam::MetadataHub::write ( DMetadata metadata,
WriteComponent  writeMode = WRITE_ALL,
const MetaEngineSettingsContainer settings = MetaEngineSettings::instance()->settings() 
)
protected

Applies the set of metadata contained in this MetadataHub to the given meta engine object. The MetaEngineSettingsContainer determine whether data is actually set or not. The following metadata fields may be set (depending on settings):

  • Comment
  • Date
  • Rating
  • Tags
  • Photographer ID (data from settings)
  • Credits (data from settings)

The data fields taken from this MetadataHub object are only set if their status is MetadataAvailable. If the status is MetadataInvalid or MetadataDisjoint, the respective metadata field is not touched.

Returns
Returns true if the metadata object has been touched

References applyChangeNotifications(), MetadataAvailable, Digikam::MetaEngine::removeGPSInfo(), Digikam::DMetadata::removeMetadataTemplate(), Digikam::Template::removeTemplateTitle(), Digikam::MetaEngineSettingsContainer::saveColorLabel, Digikam::MetaEngineSettingsContainer::saveComments, Digikam::MetaEngineSettingsContainer::saveDateTime, Digikam::MetaEngineSettingsContainer::saveFaceTags, Digikam::MetaEngineSettingsContainer::savePickLabel, Digikam::MetaEngineSettingsContainer::savePosition, Digikam::MetaEngineSettingsContainer::saveRating, Digikam::MetaEngineSettingsContainer::saveTags, Digikam::MetaEngineSettingsContainer::saveTemplate, Digikam::MetaEngine::setGPSInfo(), Digikam::MetaEngine::setImageDateTime(), Digikam::DMetadata::setItemColorLabel(), Digikam::DMetadata::setItemComments(), Digikam::DMetadata::setItemPickLabel(), Digikam::DMetadata::setItemRating(), Digikam::DMetadata::setItemTitles(), Digikam::DMetadata::setMetadataTemplate(), Digikam::DMetadata::setSettings(), WRITE_COLORLABEL, WRITE_COMMENTS, WRITE_DATETIME, WRITE_PICKLABEL, WRITE_POSITION, WRITE_RATING, WRITE_TAGS, WRITE_TEMPLATE, WRITE_TITLE, and writeTags().

◆ writeTags() [1/2]

bool Digikam::MetadataHub::writeTags ( const DMetadata metadata,
bool  saveTags 
)

writeTags - used to deduplicate code from writeTags and usual write, all write to tags operations must be done here

Parameters
metadata- meta engine object that apply changes
saveTags- save switch
Returns
- if tags were successfully set

References cleanupTags(), Digikam::TagsCache::instance(), MetadataAvailable, Digikam::TagsCache::NoLeadingSlash, Digikam::DMetadata::setItemTagsPath(), Digikam::TagsCache::tagName(), and Digikam::TagsCache::tagPath().

◆ writeTags() [2/2]

bool Digikam::MetadataHub::writeTags ( const QString &  filePath,
WriteComponent  writeMode = WRITE_ALL,
const MetaEngineSettingsContainer settings = MetaEngineSettings::instance()->settings() 
)

◆ writeToBaloo()

void Digikam::MetadataHub::writeToBaloo ( const QString &  filePath,
const MetaEngineSettingsContainer settings = MetaEngineSettings::instance()->settings() 
)

◆ writeToMetadata()

bool Digikam::MetadataHub::writeToMetadata ( const ItemInfo info,
WriteComponent  writeMode = WRITE_ALL,
bool  ignoreLazySync = false,
const MetaEngineSettingsContainer settings = MetaEngineSettings::instance()->settings() 
)

writeToMetadata - write to metadata using image info to retrieve tags and filepath use this method when multiple image infos are loaded in hub

Parameters
info- image info to retrieve current tags
writeMode
settings
Returns
true - if everything is successful

safe method

References Digikam::MetadataHubMngr::addPending(), applyChangeNotifications(), Digikam::ItemAttributesWatch::fileMetadataChanged(), Digikam::ItemInfo::filePath(), Digikam::ItemAttributesWatch::instance(), Digikam::MetadataHubMngr::instance(), Digikam::MetaEngineSettingsContainer::useLazySync, willWriteMetadata(), write(), and writeToBaloo().

Referenced by Digikam::TagModificationHelper::slotMultipleFaceTagDel(), and Digikam::FileActionMngrFileWorker::writeMetadata().


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