digiKam
Digikam::ItemComments Class Reference

Public Types

enum  LanguageChoiceBehavior { ReturnMatchingLanguageOnly , ReturnMatchingOrDefaultLanguage , ReturnMatchingDefaultOrFirstLanguage }
 
enum  UniqueBehavior { UniquePerLanguage , UniquePerLanguageAndAuthor }
 

Public Member Functions

void addComment (const QString &comment, const QString &language=QString(), const QString &author=QString(), const QDateTime &date=QDateTime(), DatabaseComment::Type type=DatabaseComment::Comment)
 
void addHeadline (const QString &headline, const QString &language=QString(), const QString &author=QString(), const QDateTime &date=QDateTime())
 
void addTitle (const QString &title, const QString &language=QString(), const QString &author=QString(), const QDateTime &date=QDateTime())
 
void apply ()
 
void apply (CoreDbAccess &access)
 
QString author (int index) const
 
void changeAuthor (int index, const QString &author)
 
void changeComment (int index, const QString &comment)
 
void changeDate (int index, const QDateTime &date)
 
void changeLanguage (int index, const QString &language)
 
void changeType (int index, DatabaseComment::Type type)
 
QString comment (int index) const
 
QString commentForLanguage (const QString &languageCode, int *const index=nullptr, LanguageChoiceBehavior behavior=ReturnMatchingDefaultOrFirstLanguage) const
 
QDateTime date (int index) const
 
QString defaultComment (DatabaseComment::Type type=DatabaseComment::Comment) const
 
QString defaultComment (int *const index, Digikam::DatabaseComment::Type type=DatabaseComment::Comment) const
 
bool isNull () const
 
 ItemComments ()
 
 ItemComments (const CoreDbAccess &access, qlonglong imageid)
 
 ItemComments (const ItemComments &other)
 
 ItemComments (qlonglong imageid)
 
QString language (int index) const
 
int numberOfComments () const
 
ItemCommentsoperator= (const ItemComments &other)
 
void remove (int index)
 
void removeAll ()
 
void removeAll (DatabaseComment::Type type)
 
void removeAllComments ()
 
void replaceComments (const CaptionsMap &comments, DatabaseComment::Type type=DatabaseComment::Comment)
 
void replaceFrom (const ItemComments &source)
 
void setUniqueBehavior (UniqueBehavior behavior)
 
CaptionsMap toCaptionsMap (DatabaseComment::Type=DatabaseComment::Comment) const
 
DatabaseComment::Type type (int index) const
 
 ~ItemComments ()
 

Protected Member Functions

void addCommentDirectly (const QString &comment, const QString &language, const QString &author, DatabaseComment::Type type, const QDateTime &date)
 

Protected Attributes

QSharedDataPointer< Private > d
 

Member Enumeration Documentation

◆ LanguageChoiceBehavior

The ItemComments class shall provide short-lived objects that provide read/write access to the comments stored in the database. It is a mere wrapper around the less convenient access methods in CoreDB. Database results are cached, but the object will not listen to database changes from other places.

Changes are applied to the database only after calling apply(), which you can call any time and which will in any case be called from the destructor.

Enumerator
ReturnMatchingLanguageOnly 

Return only a comment if the language code (at least the language code, the country part may differ) is identical. Else returns a null QString.

ReturnMatchingOrDefaultLanguage 

If no matching language as above is found, return the default language.

ReturnMatchingDefaultOrFirstLanguage 

If no matching or default language is found, return the first comment. Returns a null string only if no comment is available.

◆ UniqueBehavior

Enumerator
UniquePerLanguage 

Allow only one comment per language. Default setting.

UniquePerLanguageAndAuthor 

Allow multiple comments per language, each with a different author

Constructor & Destructor Documentation

◆ ItemComments() [1/4]

Digikam::ItemComments::ItemComments ( )

Create a null ItemComments object

◆ ItemComments() [2/4]

Digikam::ItemComments::ItemComments ( qlonglong  imageid)
explicit

Create a ItemComments object for the image with the specified id.

References d.

◆ ItemComments() [3/4]

Digikam::ItemComments::ItemComments ( const CoreDbAccess access,
qlonglong  imageid 
)

Create a ItemComments object for the image with the specified id. The existing CoreDbAccess object will be used to access the database.

References d.

◆ ItemComments() [4/4]

Digikam::ItemComments::ItemComments ( const ItemComments other)

◆ ~ItemComments()

Digikam::ItemComments::~ItemComments ( )

References apply().

Member Function Documentation

◆ addComment()

void Digikam::ItemComments::addComment ( const QString &  comment,
const QString &  language = QString(),
const QString &  author = QString(),
const QDateTime &  date = QDateTime(),
DatabaseComment::Type  type = DatabaseComment::Comment 
)

Add a new comment to the list of normal image comments, specified with language and author. Checking for unique comments is done as set by setUniqueBehavior. If you pass a null string as language, it will be translated to the language code designating the default language ("x-default"). If you just want to change the one comment of the image, call addComment(myComment);

References addCommentDirectly(), Digikam::CommentInfo::author, author(), Digikam::CommentInfo::comment, Digikam::DatabaseComment::Comment, comment(), d, Digikam::CommentInfo::date, date(), Digikam::CommentInfo::language, language(), Digikam::CommentInfo::type, type(), and UniquePerLanguageAndAuthor.

Referenced by addHeadline(), addTitle(), replaceComments(), and replaceFrom().

◆ addCommentDirectly()

void Digikam::ItemComments::addCommentDirectly ( const QString &  comment,
const QString &  language,
const QString &  author,
DatabaseComment::Type  type,
const QDateTime &  date 
)
protected

◆ addHeadline()

void Digikam::ItemComments::addHeadline ( const QString &  headline,
const QString &  language = QString(),
const QString &  author = QString(),
const QDateTime &  date = QDateTime() 
)

Convenience method to add a comment of type Headline. Calls addComment, see above for more info.

References addComment(), author(), date(), and Digikam::DatabaseComment::Headline.

Referenced by Digikam::ItemScanner::commitItemComments().

◆ addTitle()

void Digikam::ItemComments::addTitle ( const QString &  title,
const QString &  language = QString(),
const QString &  author = QString(),
const QDateTime &  date = QDateTime() 
)

Convenience method to add a comment of type Headline. Calls addComment, see above for more info.

References addComment(), author(), date(), and Digikam::DatabaseComment::Title.

Referenced by Digikam::ItemScanner::commitItemComments().

◆ apply() [1/2]

void Digikam::ItemComments::apply ( )

Apply all changes. Also called in destructor, so you typically do not need to call this.

References d.

Referenced by Digikam::CollectionScanner::copyFileProperties(), and ~ItemComments().

◆ apply() [2/2]

◆ author()

QString Digikam::ItemComments::author ( int  index) const

◆ changeAuthor()

void Digikam::ItemComments::changeAuthor ( int  index,
const QString &  author 
)

References author(), and d.

◆ changeComment()

void Digikam::ItemComments::changeComment ( int  index,
const QString &  comment 
)

Access individual properties. Please ensure that the specified index is a valid index

References comment(), and d.

◆ changeDate()

void Digikam::ItemComments::changeDate ( int  index,
const QDateTime &  date 
)

References d, and date().

◆ changeLanguage()

void Digikam::ItemComments::changeLanguage ( int  index,
const QString &  language 
)

References d, and language().

◆ changeType()

void Digikam::ItemComments::changeType ( int  index,
DatabaseComment::Type  type 
)

References d, and type().

◆ comment()

QString Digikam::ItemComments::comment ( int  index) const

References d.

Referenced by addComment(), addCommentDirectly(), and changeComment().

◆ commentForLanguage()

QString Digikam::ItemComments::commentForLanguage ( const QString &  languageCode,
int *const  index = nullptr,
LanguageChoiceBehavior  behavior = ReturnMatchingDefaultOrFirstLanguage 
) const

Returns a comment for the specified language. Matching behavior can be specified. Optionally also returns the index with which you can access further information about the comment.

References d, ReturnMatchingDefaultOrFirstLanguage, and ReturnMatchingLanguageOnly.

◆ date()

QDateTime Digikam::ItemComments::date ( int  index) const

◆ defaultComment() [1/2]

QString Digikam::ItemComments::defaultComment ( DatabaseComment::Type  type = DatabaseComment::Comment) const

This methods presents one of the comment strings of the available comment as the default value, when you just want to have one string. Optionally also returns the index with which you can access further information about the comment.

References type().

Referenced by Digikam::ItemInfo::comment(), and Digikam::ItemInfo::title().

◆ defaultComment() [2/2]

QString Digikam::ItemComments::defaultComment ( int *const  index,
Digikam::DatabaseComment::Type  type = DatabaseComment::Comment 
) const

References d, and type().

◆ isNull()

bool Digikam::ItemComments::isNull ( ) const

References d.

◆ language()

QString Digikam::ItemComments::language ( int  index) const

RFC 3066 notation, or "x-default"

References d.

Referenced by addComment(), addCommentDirectly(), and changeLanguage().

◆ numberOfComments()

int Digikam::ItemComments::numberOfComments ( ) const

Returns the number of comments available.

References d.

◆ operator=()

ItemComments & Digikam::ItemComments::operator= ( const ItemComments other)

References d.

◆ remove()

void Digikam::ItemComments::remove ( int  index)

Remove the entry referred to by index.

References d.

Referenced by removeAll(), replaceComments(), and replaceFrom().

◆ removeAll() [1/2]

void Digikam::ItemComments::removeAll ( )

Remove all entries of all types: Comments, Headlines, Titles

References d, and Digikam::CommentInfo::id.

Referenced by removeAllComments(), and replaceFrom().

◆ removeAll() [2/2]

void Digikam::ItemComments::removeAll ( DatabaseComment::Type  type)

Remove all entries of the given type

References d, remove(), and type().

◆ removeAllComments()

void Digikam::ItemComments::removeAllComments ( )

Convenience method: remove all entries of type Comment

References Digikam::DatabaseComment::Comment, and removeAll().

◆ replaceComments()

void Digikam::ItemComments::replaceComments ( const CaptionsMap comments,
DatabaseComment::Type  type = DatabaseComment::Comment 
)

Replaces all existing comments with the given set of comments and associated language. Optionally date and author can be specified in CaptionsMap container.

References addComment(), Digikam::CaptionValues::author, Digikam::CaptionValues::caption, d, Digikam::CaptionValues::date, remove(), and type().

Referenced by Digikam::ItemScanner::commitItemComments().

◆ replaceFrom()

void Digikam::ItemComments::replaceFrom ( const ItemComments source)

◆ setUniqueBehavior()

void Digikam::ItemComments::setUniqueBehavior ( UniqueBehavior  behavior)

Changes the behavior to unique comments per language, see the enum above for possible values. Default value is UniquePerLanguage. Note: This is not a property of the database, but only of this single ItemComments object,

References d.

◆ toCaptionsMap()

◆ type()

DatabaseComment::Type Digikam::ItemComments::type ( int  index) const

Access individual properties. Please ensure that the specified index is a valid index

References d, and Digikam::DatabaseComment::UndefinedType.

Referenced by addComment(), addCommentDirectly(), changeType(), defaultComment(), removeAll(), replaceComments(), and toCaptionsMap().

Member Data Documentation

◆ d


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