digiKam
|
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 |
ItemComments & | operator= (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 |
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.
Digikam::ItemComments::ItemComments | ( | ) |
Create a null ItemComments object
|
explicit |
Create a ItemComments object for the image with the specified id.
References d.
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.
Digikam::ItemComments::ItemComments | ( | const ItemComments & | other | ) |
Digikam::ItemComments::~ItemComments | ( | ) |
References apply().
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().
|
protected |
References Digikam::CommentInfo::author, author(), Digikam::CommentInfo::comment, comment(), d, Digikam::CommentInfo::date, date(), Digikam::CommentInfo::language, language(), Digikam::CommentInfo::type, and type().
Referenced by addComment().
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().
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().
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().
void Digikam::ItemComments::apply | ( | CoreDbAccess & | access | ) |
References Digikam::CommentInfo::author, Digikam::CoreDB::changeImageComment(), Digikam::CommentInfo::comment, d, Digikam::CommentInfo::date, Digikam::CoreDbAccess::db(), Digikam::CommentInfo::id, Digikam::CommentInfo::language, Digikam::CoreDB::removeImageComment(), Digikam::CoreDB::setImageComment(), and Digikam::CommentInfo::type.
QString Digikam::ItemComments::author | ( | int | index | ) | const |
References d.
Referenced by addComment(), addCommentDirectly(), addHeadline(), addTitle(), and changeAuthor().
void Digikam::ItemComments::changeAuthor | ( | int | index, |
const QString & | author | ||
) |
void Digikam::ItemComments::changeComment | ( | int | index, |
const QString & | comment | ||
) |
void Digikam::ItemComments::changeDate | ( | int | index, |
const QDateTime & | date | ||
) |
void Digikam::ItemComments::changeLanguage | ( | int | index, |
const QString & | language | ||
) |
References d, and language().
void Digikam::ItemComments::changeType | ( | int | index, |
DatabaseComment::Type | type | ||
) |
QString Digikam::ItemComments::comment | ( | int | index | ) | const |
References d.
Referenced by addComment(), addCommentDirectly(), and changeComment().
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.
QDateTime Digikam::ItemComments::date | ( | int | index | ) | const |
References d.
Referenced by addComment(), addCommentDirectly(), addHeadline(), addTitle(), and changeDate().
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().
QString Digikam::ItemComments::defaultComment | ( | int *const | index, |
Digikam::DatabaseComment::Type | type = DatabaseComment::Comment |
||
) | const |
bool Digikam::ItemComments::isNull | ( | ) | const |
References d.
QString Digikam::ItemComments::language | ( | int | index | ) | const |
RFC 3066 notation, or "x-default"
References d.
Referenced by addComment(), addCommentDirectly(), and changeLanguage().
int Digikam::ItemComments::numberOfComments | ( | ) | const |
Returns the number of comments available.
References d.
ItemComments & Digikam::ItemComments::operator= | ( | const ItemComments & | other | ) |
References d.
void Digikam::ItemComments::remove | ( | int | index | ) |
Remove the entry referred to by index.
References d.
Referenced by removeAll(), replaceComments(), and replaceFrom().
void Digikam::ItemComments::removeAll | ( | ) |
Remove all entries of all types: Comments, Headlines, Titles
References d, and Digikam::CommentInfo::id.
Referenced by removeAllComments(), and replaceFrom().
void Digikam::ItemComments::removeAll | ( | DatabaseComment::Type | type | ) |
void Digikam::ItemComments::removeAllComments | ( | ) |
Convenience method: remove all entries of type Comment
References Digikam::DatabaseComment::Comment, and removeAll().
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().
void Digikam::ItemComments::replaceFrom | ( | const ItemComments & | source | ) |
Replaces all entries in this object with all entries from source.
References addComment(), Digikam::CommentInfo::author, Digikam::CommentInfo::comment, d, Digikam::CommentInfo::date, Digikam::CommentInfo::language, remove(), removeAll(), and Digikam::CommentInfo::type.
Referenced by Digikam::CollectionScanner::copyFileProperties().
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.
CaptionsMap Digikam::ItemComments::toCaptionsMap | ( | DatabaseComment::Type | type = DatabaseComment::Comment | ) | const |
Returns all entries of the given type in a CaptionsMap container.
References Digikam::CommentInfo::author, Digikam::CaptionValues::author, Digikam::CaptionValues::caption, Digikam::CommentInfo::comment, d, Digikam::CommentInfo::date, Digikam::CaptionValues::date, Digikam::CommentInfo::language, Digikam::CommentInfo::type, and type().
Referenced by Digikam::MetadataHub::load().
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().
|
protected |
Referenced by addComment(), addCommentDirectly(), apply(), author(), changeAuthor(), changeComment(), changeDate(), changeLanguage(), changeType(), comment(), commentForLanguage(), date(), defaultComment(), isNull(), ItemComments(), language(), numberOfComments(), operator=(), remove(), removeAll(), replaceComments(), replaceFrom(), setUniqueBehavior(), toCaptionsMap(), and type().