digiKam
itemcopyright.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 : 2008-05-12
7  * Description : Access to copy-right info of an item in the database
8  *
9  * Copyright (C) 2008-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  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_ITEM_COPY_RIGHT_H
26 #define DIGIKAM_ITEM_COPY_RIGHT_H
27 
28 // Qt includes
29 
30 #include <QString>
31 #include <QStringList>
32 #include <QList>
33 
34 // Local includes
35 
36 #include "metaengine.h"
37 #include "metadatainfo.h"
38 #include "digikam_export.h"
39 
40 namespace Digikam
41 {
42 
43 class CopyrightInfo;
44 class ItemCopyrightCache;
45 class Template;
46 
47 class DIGIKAM_DATABASE_EXPORT ItemCopyright
48 {
49 public:
50 
52  {
55  AddEntryToExisting
56  };
57 
58 public:
59 
60  explicit ItemCopyright(qlonglong imageid);
61 
65  ItemCopyright();
66 
67  ItemCopyright(const ItemCopyright& other);
68  ~ItemCopyright();
69 
70  ItemCopyright& operator=(const ItemCopyright& other);
71 
87  QStringList creator() const;
88 
89  QStringList author() const
90  {
91  return creator();
92  }
93 
94  QStringList byLine() const
95  {
96  return creator();
97  }
98 
105  void setCreator(const QString& creator, ReplaceMode mode = ReplaceAllEntries);
106 
107  void setAuthor(const QString& author, ReplaceMode mode = ReplaceAllEntries)
108  {
109  setCreator(author, mode);
110  }
111 
112  void setByLine(const QString& byline, ReplaceMode mode = ReplaceAllEntries)
113  {
114  setCreator(byline, mode);
115  }
116 
117  void removeCreators();
118 
126  QString provider() const;
127 
128  QString credit() const
129  {
130  return provider();
131  }
132 
133  void setProvider(const QString& provider);
134 
135  void setCredit(const QString& credit)
136  {
137  setProvider(credit);
138  }
139 
140  void removeProvider();
141 
159  QString copyrightNotice(const QString& languageCode = QString());
160 
161  QString rights(const QString& languageCode = QString())
162  {
163  return copyrightNotice(languageCode);
164  }
165 
166  MetaEngine::AltLangMap allCopyrightNotices();
167 
173  void setCopyrightNotice(const QString& notice,
174  const QString& languageCode = QString(),
175  ReplaceMode mode = ReplaceLanguageEntry);
176 
177  void setRights(const QString& notice,
178  const QString& languageCode = QString(),
179  ReplaceMode mode = ReplaceLanguageEntry)
180  {
181  setCopyrightNotice(notice, languageCode, mode);
182  }
183 
184  void removeCopyrightNotices();
185 
193  QString rightsUsageTerms(const QString& languageCode = QString());
194  MetaEngine::AltLangMap allRightsUsageTerms();
195 
196  void setRightsUsageTerms(const QString& term,
197  const QString& languageCode = QString(),
198  ReplaceMode mode = ReplaceLanguageEntry);
199 
200  void removeRightsUsageTerms();
201 
213  QString source();
214  void setSource(const QString& source);
215 
216  void removeSource();
217 
227  QString creatorJobTitle() const;
228 
229  QString authorsPosition() const
230  {
231  return creatorJobTitle();
232  }
233 
234  QString byLineTitle() const
235  {
236  return creatorJobTitle();
237  }
238 
239  void setCreatorJobTitle(const QString& title);
240 
241  void setAuthorsPosition(const QString& position)
242  {
243  setCreatorJobTitle(position);
244  }
245 
246  void setByLineTitle(const QString& title)
247  {
248  setCreatorJobTitle(title);
249  }
250 
251  void removeCreatorJobTitle();
252 
265  QString instructions();
266  void setInstructions(const QString& instructions);
267  void removeInstructions();
268 
275  IptcCoreContactInfo contactInfo();
276  void setContactInfo(const IptcCoreContactInfo& info);
277  void removeContactInfo();
278 
283  void fillTemplate(Template& t);
284 
289  void setFromTemplate(const Template& t);
290 
294  void removeAll();
295 
299  void replaceFrom(const ItemCopyright& source);
300 
301 protected:
302 
303  CopyrightInfo copyrightInfo(const QString& property) const;
304  QList<CopyrightInfo> copyrightInfos(const QString& property) const;
305  QString readSimpleProperty(const QString& property) const;
306  int languageMatch(const QList<CopyrightInfo>& infos, const QString& languageCode) const;
307 
308  void setSimpleProperty(const QString& property, const QString& value);
309  QString readLanguageProperty(const QString& property, const QString& languageCode);
310  MetaEngine::AltLangMap readLanguageProperties(const QString& property);
311 
312  void setLanguageProperty(const QString& property,
313  const QString& value,
314  const QString& languageCode,
315  ReplaceMode mode);
316 
317  void removeProperties(const QString& property);
318  void removeLanguageProperty(const QString& property, const QString& languageCode);
319 
320 protected:
321 
322  friend class ItemCopyrightCache;
323 
324  qlonglong m_id;
325  ItemCopyrightCache* m_cache;
326 };
327 
328 } // namespace Digikam
329 
330 #endif // DIGIKAM_ITEM_COPY_RIGHT_H
Definition: coredbalbuminfo.h:338
Definition: metadatainfo.h:63
Definition: itemcopyright.h:48
void setByLine(const QString &byline, ReplaceMode mode=ReplaceAllEntries)
Definition: itemcopyright.h:112
void setAuthorsPosition(const QString &position)
Definition: itemcopyright.h:241
ItemCopyrightCache * m_cache
Definition: itemcopyright.h:325
QStringList author() const
Definition: itemcopyright.h:89
QString rights(const QString &languageCode=QString())
Definition: itemcopyright.h:161
QStringList byLine() const
Definition: itemcopyright.h:94
QString authorsPosition() const
Definition: itemcopyright.h:229
QString credit() const
Definition: itemcopyright.h:128
void setRights(const QString &notice, const QString &languageCode=QString(), ReplaceMode mode=ReplaceLanguageEntry)
Definition: itemcopyright.h:177
ReplaceMode
Definition: itemcopyright.h:52
@ ReplaceAllEntries
Remove entries for all languages and add one new entry.
Definition: itemcopyright.h:53
@ ReplaceLanguageEntry
Only replace the entry with the given language.
Definition: itemcopyright.h:54
QString byLineTitle() const
Definition: itemcopyright.h:234
void setCredit(const QString &credit)
Definition: itemcopyright.h:135
void setByLineTitle(const QString &title)
Definition: itemcopyright.h:246
qlonglong m_id
Definition: itemcopyright.h:324
void setAuthor(const QString &author, ReplaceMode mode=ReplaceAllEntries)
Definition: itemcopyright.h:107
QMap< QString, QString > AltLangMap
Definition: metaengine.h:143
Definition: template.h:46
Definition: piwigotalker.h:48
qulonglong value
Definition: itemviewutilities.cpp:592
Definition: datefolderview.cpp:43
Definition: scan.h:26