digiKam
itemcomments.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2007-09-19
7  * Description : Access to comments of an item in the database
8  *
9  * Copyright (C) 2007-2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2009-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  * Copyright (C) 2008 by Patrick Spendrin <ps_ml at gmx dot de>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_ITEM_COMMENTS_H
27 #define DIGIKAM_ITEM_COMMENTS_H
28 
29 // Qt includes
30 
31 #include <QString>
32 #include <QDateTime>
33 #include <QSharedDataPointer>
34 #include <QSharedData>
35 #include <QSet>
36 
37 // Local includes
38 
39 #include "digikam_export.h"
40 #include "coredbalbuminfo.h"
41 #include "captionvalues.h"
42 #include "coredbaccess.h"
43 
44 namespace Digikam
45 {
46 
47 class DIGIKAM_DATABASE_EXPORT ItemComments
48 {
49 public:
50 
62  {
69 
74 
79  ReturnMatchingDefaultOrFirstLanguage
80  };
81 
83  {
88 
92  UniquePerLanguageAndAuthor
93  };
94 
95 public:
96 
100  ItemComments();
101 
105  explicit ItemComments(qlonglong imageid);
106 
111  ItemComments(const CoreDbAccess& access, qlonglong imageid);
112 
113  ItemComments(const ItemComments& other);
114  ~ItemComments();
115 
116  ItemComments& operator=(const ItemComments& other);
117 
118  bool isNull() const;
119 
126  void setUniqueBehavior(UniqueBehavior behavior);
127 
133  QString defaultComment(DatabaseComment::Type type = DatabaseComment::Comment) const;
134 
135  QString defaultComment(int* const index, Digikam::DatabaseComment::Type type = DatabaseComment::Comment) const;
136 
142  QString commentForLanguage(const QString& languageCode, int* const index = nullptr,
143  LanguageChoiceBehavior behavior = ReturnMatchingDefaultOrFirstLanguage) const;
144 
148  int numberOfComments() const;
149 
153  DatabaseComment::Type type(int index) const;
154 
158  QString language(int index) const;
159 
160  QString author(int index) const;
161  QDateTime date(int index) const;
162  QString comment(int index) const;
163 
171  void addComment(const QString& comment,
172  const QString& language = QString(),
173  const QString& author = QString(),
174  const QDateTime& date = QDateTime(),
176 
180  void addHeadline(const QString& headline,
181  const QString& language = QString(),
182  const QString& author = QString(),
183  const QDateTime& date = QDateTime());
184 
188  void addTitle(const QString& title,
189  const QString& language = QString(),
190  const QString& author = QString(),
191  const QDateTime& date = QDateTime());
192 
197  void replaceComments(const CaptionsMap& comments,
199 
203  void remove(int index);
204 
208  void removeAll(DatabaseComment::Type type);
209 
213  void removeAllComments();
214 
218  void removeAll();
219 
224  void changeComment(int index, const QString& comment);
225  void changeLanguage(int index, const QString& language);
226  void changeAuthor(int index, const QString& author);
227  void changeDate(int index, const QDateTime& date);
228  void changeType(int index, DatabaseComment::Type type);
229 
234  void apply();
235  void apply(CoreDbAccess& access);
236 
241 
245  void replaceFrom(const ItemComments& source);
246 
247 protected:
248 
249  void addCommentDirectly(const QString& comment,
250  const QString& language,
251  const QString& author,
253  const QDateTime& date);
254 public:
255 
256  class Private;
257 
258 protected:
259 
260  QSharedDataPointer<Private> d;
261 };
262 
263 } // namespace Digikam
264 
265 #endif // DIGIKAM_ITEM_COMMENTS_H
Definition: captionvalues.h:69
Definition: coredbaccess.h:56
Definition: itemcomments.h:48
UniqueBehavior
Definition: itemcomments.h:83
@ UniquePerLanguage
Definition: itemcomments.h:87
LanguageChoiceBehavior
Definition: itemcomments.h:62
@ ReturnMatchingOrDefaultLanguage
Definition: itemcomments.h:73
@ ReturnMatchingLanguageOnly
Definition: itemcomments.h:68
QSharedDataPointer< Private > d
Definition: itemcomments.h:256
Type
Definition: coredbconstants.h:128
@ Comment
Definition: coredbconstants.h:139
Definition: datefolderview.cpp:43