digiKam
metadatahub.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-01-05
7  * Description : Metadata handling
8  *
9  * Copyright (C) 2007-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2007-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_METADATA_HUB_H
26 #define DIGIKAM_METADATA_HUB_H
27 
28 // Qt includes
29 
30 #include <QList>
31 #include <QStringList>
32 #include <QDateTime>
33 #include <QMap>
34 
35 // Local includes
36 
37 #include "metaenginesettings.h"
38 #include "captionvalues.h"
39 #include "dmetadata.h"
40 #include "dimg.h"
41 
42 namespace Digikam
43 {
44 
45 class ApplicationSettings;
46 class ItemInfo;
47 class Template;
48 
50 {
51 public:
52 
58  enum Status
59  {
62  };
63 
64  enum WriteMode
65  {
70 
81 
88  };
89 
91  {
99  WRITE_TAGS = 128,
101  WRITE_ALL = 511
102  };
103  Q_DECLARE_FLAGS(WriteComponent, WriteComponents)
104 
105 public:
106 
110  MetadataHub();
111  ~MetadataHub();
112 
113  void reset();
114 
115  // --------------------------------------------------
116 
123  void load(const ItemInfo& info);
124 
125 // /**
126 // * Add metadata information from the meta engine object
127 // */
128 // void load(const DMetadata& metadata);
129 
130 // /**
131 // * Load metadata information from the given file.
132 // * (Uses DMetadata, QFileInfo)
133 // * @returns True if the metadata could be loaded
134 // */
135 // bool load(const QString& filePath, const MetaEngineSettingsContainer& settings = MetaEngineSettings::instance()->settings());
136 
137  // --------------------------------------------------
138 
147  bool writeToMetadata(const ItemInfo& info,
148  WriteComponent writeMode = WRITE_ALL,
149  bool ignoreLazySync = false,
150  const MetaEngineSettingsContainer& settings = MetaEngineSettings::instance()->settings());
151 
152 
162  bool write(const QString& filePath,
163  WriteComponent writeMode = WRITE_ALL,
164  bool ignoreLazySync = false,
165  const MetaEngineSettingsContainer& settings = MetaEngineSettings::instance()->settings());
166 
172  bool write(const DImg& image,
173  WriteComponent writeMode = WRITE_ALL,
174  bool ignoreLazySync = false,
175  const MetaEngineSettingsContainer& settings = MetaEngineSettings::instance()->settings());
176 
182  bool writeTags(const QString& filePath,
183  WriteComponent writeMode = WRITE_ALL,
184  const MetaEngineSettingsContainer& settings = MetaEngineSettings::instance()->settings());
185 
193  bool writeTags(const DMetadata& metadata, bool saveTags);
194 
200  QStringList cleanupTags(const QStringList& toClean);
201 
207  bool willWriteMetadata(Digikam::MetadataHub::WriteComponent writeMode = WRITE_ALL,
208  const MetaEngineSettingsContainer& settings = MetaEngineSettings::instance()->settings()) const;
209 
215  void writeToBaloo(const QString& filePath,
216  const MetaEngineSettingsContainer& settings = MetaEngineSettings::instance()->settings());
217 
218 
219  // --------------------------------------------------
220 
227  void loadFaceTags(const ItemInfo& info, const QSize& size);
228 
233  QMultiMap<QString, QVariant> getFaceTags();
234 
238  void setFaceTags(QMultiMap<QString, QVariant> newFaceTags, QSize size);
239 
240 protected:
241 
261  bool write(DMetadata& metadata,
262  WriteComponent writeMode = WRITE_ALL,
263  const MetaEngineSettingsContainer& settings = MetaEngineSettings::instance()->settings());
264 
265  void load(const QDateTime& dateTime,
266  const CaptionsMap& titles,
267  const CaptionsMap& comment,
268  int colorLabel, int pickLabel,
269  int rating, const Template& t);
270 
271  void loadTags(const QList<int>& loadedTagIds);
272  void loadTags(const QStringList& loadedTagPaths);
273  void notifyTagDeleted(int id);
274 
276 
277 private:
278 
279  bool writeFaceTagsMap(const DMetadata& metadata, bool saveFaces);
280 
281 private:
282 
283  class Private;
284  Private* const d;
285 
286 private:
287 
288  Q_DISABLE_COPY(MetadataHub)
289 };
290 
291 } // namespace Digikam
292 
293 Q_DECLARE_OPERATORS_FOR_FLAGS(Digikam::MetadataHub::WriteComponent)
294 
295 #endif // DIGIKAM_METADATA_HUB_H
Definition: captionvalues.h:69
Definition: dimg.h:62
Definition: dmetadata.h:55
Definition: iteminfo.h:78
Definition: metaenginesettingscontainer.h:48
static MetaEngineSettings * instance()
Definition: metaenginesettings.cpp:106
Definition: metadatahub.h:50
QStringList cleanupTags(const QStringList &toClean)
cleanupTags - remove duplicates and obsolete tags before setting metadata
Definition: metadatahub.cpp:595
Status
Definition: metadatahub.h:59
@ MetadataAvailable
only one data set has been added, or a common value is available
Definition: metadatahub.h:61
@ MetadataInvalid
not yet filled with any value
Definition: metadatahub.h:60
void reset()
Definition: metadatahub.cpp:125
void loadFaceTags(const ItemInfo &info, const QSize &size)
Definition: metadatahub.cpp:717
WriteMode
Definition: metadatahub.h:65
@ PartialWrite
Definition: metadatahub.h:87
@ FullWrite
Definition: metadatahub.h:69
@ FullWriteIfChanged
Definition: metadatahub.h:80
bool write(const QString &filePath, WriteComponent writeMode=WRITE_ALL, bool ignoreLazySync=false, const MetaEngineSettingsContainer &settings=MetaEngineSettings::instance() ->settings())
Definition: metadatahub.cpp:386
~MetadataHub()
Definition: metadatahub.cpp:120
void setFaceTags(QMultiMap< QString, QVariant > newFaceTags, QSize size)
Definition: metadatahub.cpp:755
void writeToBaloo(const QString &filePath, const MetaEngineSettingsContainer &settings=MetaEngineSettings::instance() ->settings())
writeToBaloo - write tags, comments and rating to KDE Nepomuk replacement: Baloo
Definition: metadatahub.cpp:651
bool writeToMetadata(const ItemInfo &info, WriteComponent writeMode=WRITE_ALL, bool ignoreLazySync=false, const MetaEngineSettingsContainer &settings=MetaEngineSettings::instance() ->settings())
writeToMetadata - write to metadata using image info to retrieve tags and filepath use this method wh...
Definition: metadatahub.cpp:243
QMultiMap< QString, QVariant > getFaceTags()
Definition: metadatahub.cpp:750
bool willWriteMetadata(Digikam::MetadataHub::WriteComponent writeMode=WRITE_ALL, const MetaEngineSettingsContainer &settings=MetaEngineSettings::instance() ->settings()) const
Definition: metadatahub.cpp:621
void notifyTagDeleted(int id)
MetadataHub()
Definition: metadatahub.cpp:115
void loadTags(const QList< int > &loadedTagIds)
Definition: metadatahub.cpp:173
void applyChangeNotifications()
Definition: metadatahub.cpp:713
WriteComponents
Definition: metadatahub.h:91
@ WRITE_TEMPLATE
Definition: metadatahub.h:98
@ WRITE_RATING
Definition: metadatahub.h:97
@ WRITE_TITLE
Definition: metadatahub.h:93
@ WRITE_COLORLABEL
Definition: metadatahub.h:96
@ WRITE_TAGS
Definition: metadatahub.h:99
@ WRITE_DATETIME
Definition: metadatahub.h:92
@ WRITE_POSITION
Definition: metadatahub.h:100
@ WRITE_COMMENTS
Definition: metadatahub.h:94
@ WRITE_ALL
Definition: metadatahub.h:101
@ WRITE_PICKLABEL
Definition: metadatahub.h:95
void load(const ItemInfo &info)
Definition: metadatahub.cpp:132
bool writeTags(const QString &filePath, WriteComponent writeMode=WRITE_ALL, const MetaEngineSettingsContainer &settings=MetaEngineSettings::instance() ->settings())
Definition: metadatahub.cpp:466
void loadTags(const QStringList &loadedTagPaths)
Definition: template.h:46
Definition: datefolderview.cpp:43