digiKam
disjointmetadata.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 : 2015-08-17
7  * Description : Helper class for Image Description Editor Tab
8  *
9  * Copyright (C) 2015 by Veaceslav Munteanu <veaceslav dot munteanu90 at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_DISJOINT_METADATA_H
25 #define DIGIKAM_DISJOINT_METADATA_H
26 
27 // Qt includes
28 
29 #include <QString>
30 #include <QMap>
31 #include <QObject>
32 #include <QDateTime>
33 
34 // Local includes
35 
37 #include "metaenginesettings.h"
38 
39 namespace Digikam
40 {
41 
42 class ItemInfo;
43 class CaptionsMap;
44 class Template;
45 
46 class DisjointMetadata : public QObject
47 {
48  Q_OBJECT
49 
50 public:
51 
52  enum WriteMode
53  {
58 
69 
76  };
77 
78 public:
79 
81  ~DisjointMetadata() override;
82 
83 
85  void setDataFields(const DisjointMetadataDataFields& data);
86 
87  void reset();
88 
89  void load(const ItemInfo& info);
90 
92 
103 
105  DisjointMetadataDataFields::Status tagStatus(const QString& tagPath) const;
106 
108 
110 
115  bool dateTimeChanged() const;
116  bool titlesChanged() const;
117  bool commentsChanged() const;
118  bool pickLabelChanged() const;
119  bool colorLabelChanged() const;
120  bool ratingChanged() const;
121  bool templateChanged() const;
122  bool tagsChanged() const;
123 
125 
127 
132  void setDateTime(const QDateTime& dateTime,
134  void setTitles(const CaptionsMap& titles,
136  void setComments(const CaptionsMap& comments,
138  void setPickLabel(int pickId,
140  void setColorLabel(int colorId,
142  void setRating(int rating,
144  void setMetadataTemplate(const Template& t,
146  void setTag(int albumID,
148 
150 
157  QDateTime dateTime() const;
158 
164  CaptionsMap titles() const;
165 
171  CaptionsMap comments() const;
172 
179  int pickLabel() const;
180 
187  int colorLabel() const;
188 
195  int rating() const;
196 
202  Template metadataTemplate() const;
203 
209  void dateTimeInterval(QDateTime& lowest,
210  QDateTime& highest) const;
211 
217  void pickLabelInterval(int& lowest,
218  int& highest) const;
219 
225  void colorLabelInterval(int& lowest,
226  int& highest) const;
227 
233  void ratingInterval(int& lowest,
234  int& highest) const;
235 
240  QStringList keywords() const;
241 
249  QMap<int, DisjointMetadataDataFields::Status> tags() const;
250 
251  void resetChanged();
252 
258  bool write(ItemInfo info, WriteMode writeMode = FullWrite);
259 
265  bool willWriteMetadata(WriteMode writeMode,
266  const MetaEngineSettingsContainer& settings =
267  MetaEngineSettings::instance()->settings()) const;
268 
274  int changedFlags();
275 
276 private Q_SLOTS:
277 
278  void slotTagDeleted(int tagId);
279  void slotInvalidate();
280 
281 private:
282 
283  void load(const QDateTime& dateTime,
284  const CaptionsMap& titles,
285  const CaptionsMap& comment,
286  int colorLabel, int pickLabel,
287  int rating, const Template& t);
288 
289  void loadTags(const QList<int>& tagIds);
290  void notifyTagDeleted(int id);
291  void applyChangeNotifications();
292 
293 private:
294 
295  // Disable
296  explicit DisjointMetadata(QObject*) = delete;
297 
298  // Disable copy constructor and operator to prevent potential slicing with this class, reported by Clazy static analyzer.
299  // https://github.com/KDE/clazy/blob/master/docs/checks/README-copyable-polymorphic.md
300  // Use DisjointMetadataDataFields container setter and getter instead.
301  // TODO: remove legacy implementations for these methods later if no side effect.
302  DisjointMetadata(const DisjointMetadata& other);
303  DisjointMetadata& operator=(const DisjointMetadata& other);
304 
305 private:
306 
307  class Private;
308  Private* d;
309 };
310 
311 } // namespace Digikam
312 
313 #endif // DIGIKAM_DISJOINT_METADATA_H
Definition: captionvalues.h:69
Definition: disjointmetadatadatafields.h:49
Status
Definition: disjointmetadatadatafields.h:59
@ MetadataAvailable
Only one data set has been added, or a common value is available.
Definition: disjointmetadatadatafields.h:61
Definition: disjointmetadata.h:47
void dateTimeInterval(QDateTime &lowest, QDateTime &highest) const
Definition: disjointmetadata.cpp:702
DisjointMetadataDataFields::Status ratingStatus() const
Definition: disjointmetadata.cpp:177
DisjointMetadataDataFields::Status tagStatus(int albumId) const
Definition: disjointmetadata.cpp:187
void setColorLabel(int colorId, DisjointMetadataDataFields::Status status=DisjointMetadataDataFields::MetadataAvailable)
Definition: disjointmetadata.cpp:267
DisjointMetadataDataFields::Status dateTimeStatus() const
Definition: disjointmetadata.cpp:152
DisjointMetadataDataFields::Status titlesStatus() const
Definition: disjointmetadata.cpp:157
QMap< int, DisjointMetadataDataFields::Status > tags() const
Definition: disjointmetadata.cpp:827
~DisjointMetadata() override
Definition: disjointmetadata.cpp:43
void colorLabelInterval(int &lowest, int &highest) const
Definition: disjointmetadata.cpp:756
WriteMode
Definition: disjointmetadata.h:53
@ FullWrite
Definition: disjointmetadata.h:57
@ FullWriteIfChanged
Definition: disjointmetadata.h:68
@ PartialWrite
Definition: disjointmetadata.h:75
void resetChanged()
Definition: disjointmetadata.cpp:294
DisjointMetadataDataFields dataFields() const
Definition: disjointmetadata.cpp:834
DisjointMetadataDataFields::Status colorLabelStatus() const
Definition: disjointmetadata.cpp:172
QDateTime dateTime() const
Definition: disjointmetadata.cpp:667
bool colorLabelChanged() const
Definition: disjointmetadata.cpp:219
bool commentsChanged() const
Definition: disjointmetadata.cpp:209
bool dateTimeChanged() const
Definition: disjointmetadata.cpp:199
void reset()
Definition: disjointmetadata.cpp:59
CaptionsMap comments() const
Definition: disjointmetadata.cpp:677
int changedFlags()
changedFlags - used for selective metadata write. The result will be passed to metadatahub and it wil...
Definition: disjointmetadata.cpp:482
QStringList keywords() const
Definition: disjointmetadata.cpp:810
CaptionsMap titles() const
Definition: disjointmetadata.cpp:672
void setMetadataTemplate(const Template &t, DisjointMetadataDataFields::Status status=DisjointMetadataDataFields::MetadataAvailable)
Definition: disjointmetadata.cpp:281
void setDateTime(const QDateTime &dateTime, DisjointMetadataDataFields::Status status=DisjointMetadataDataFields::MetadataAvailable)
Definition: disjointmetadata.cpp:239
int rating() const
Definition: disjointmetadata.cpp:692
void setPickLabel(int pickId, DisjointMetadataDataFields::Status status=DisjointMetadataDataFields::MetadataAvailable)
Definition: disjointmetadata.cpp:260
DisjointMetadataDataFields::Status templateStatus() const
Definition: disjointmetadata.cpp:182
void setTitles(const CaptionsMap &titles, DisjointMetadataDataFields::Status status=DisjointMetadataDataFields::MetadataAvailable)
Definition: disjointmetadata.cpp:246
bool ratingChanged() const
Definition: disjointmetadata.cpp:224
DisjointMetadataDataFields::Status commentsStatus() const
Definition: disjointmetadata.cpp:162
int pickLabel() const
Definition: disjointmetadata.cpp:682
bool titlesChanged() const
Definition: disjointmetadata.cpp:204
void load(const ItemInfo &info)
Definition: disjointmetadata.cpp:65
void pickLabelInterval(int &lowest, int &highest) const
Definition: disjointmetadata.cpp:729
bool tagsChanged() const
Definition: disjointmetadata.cpp:234
DisjointMetadata()
Definition: disjointmetadata.cpp:29
void setTag(int albumID, DisjointMetadataDataFields::Status status=DisjointMetadataDataFields::MetadataAvailable)
Definition: disjointmetadata.cpp:288
void setRating(int rating, DisjointMetadataDataFields::Status status=DisjointMetadataDataFields::MetadataAvailable)
Definition: disjointmetadata.cpp:274
void setDataFields(const DisjointMetadataDataFields &data)
Definition: disjointmetadata.cpp:841
Template metadataTemplate() const
Definition: disjointmetadata.cpp:697
bool templateChanged() const
Definition: disjointmetadata.cpp:229
bool pickLabelChanged() const
Definition: disjointmetadata.cpp:214
DisjointMetadataDataFields::Status pickLabelStatus() const
Definition: disjointmetadata.cpp:167
bool write(ItemInfo info, WriteMode writeMode=FullWrite)
Definition: disjointmetadata.cpp:306
int colorLabel() const
Definition: disjointmetadata.cpp:687
bool willWriteMetadata(WriteMode writeMode, const MetaEngineSettingsContainer &settings=MetaEngineSettings::instance() ->settings()) const
Definition: disjointmetadata.cpp:431
void ratingInterval(int &lowest, int &highest) const
Definition: disjointmetadata.cpp:783
void setComments(const CaptionsMap &comments, DisjointMetadataDataFields::Status status=DisjointMetadataDataFields::MetadataAvailable)
Definition: disjointmetadata.cpp:253
Definition: iteminfo.h:78
Definition: metaenginesettingscontainer.h:48
static MetaEngineSettings * instance()
Definition: metaenginesettings.cpp:106
Definition: template.h:46
Definition: datefolderview.cpp:43