digiKam
dmetadatasettingscontainer.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 : 2010-08-20
7  * Description : metadata Settings Container.
8  *
9  * Copyright (C) 2015 by Veaceslav Munteanu <veaceslav dot munteanu90 at gmail dot com>
10  * Copyright (C) 2015-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_DMETADATA_SETTINGS_CONTAINER_H
26 #define DIGIKAM_DMETADATA_SETTINGS_CONTAINER_H
27 
28 // Qt includes
29 
30 #include <QFlags>
31 #include <QString>
32 #include <QMap>
33 #include <QDebug>
34 
35 // Local includes
36 
37 #include "digikam_export.h"
38 
39 class KConfigGroup;
40 
41 namespace Digikam
42 {
43 
50 class DIGIKAM_EXPORT NamespaceEntry
51 {
52 
53 public:
54 
56  {
57  EXIF = 0,
58  IPTC = 1,
59  XMP = 2
60  };
61 
62  enum TagType
63  {
64  TAG = 0,
65  TAGPATH = 1
66  };
67 
69  {
70  NO_OPTS = 0,
71  COMMENT_ALTLANG = 1,
72  COMMENT_ATLLANGLIST = 2,
73  COMMENT_XMP = 3,
74  COMMENT_JPEG = 4,
75  TAG_XMPBAG = 5,
76  TAG_XMPSEQ = 6,
77  TAG_ACDSEE = 7
78  };
79 
81  {
82  TAGS = 0,
83  TITLE = 1,
84  RATING = 2,
85  COMMENT = 3,
86  // PICKLABEL = 4,
87  COLORLABEL = 5
88  };
89 
90 public:
91 
92  explicit NamespaceEntry()
93  : nsType (TAGS),
94  subspace (XMP),
95  isDefault (true),
96  isDisabled (false),
97  index (-1),
98  tagPaths (TAGPATH),
99  specialOpts (NO_OPTS),
100  secondNameOpts (NO_OPTS)
101  {
102  }
103 
105  : nsType (other.nsType),
106  subspace (other.subspace),
107  isDefault (other.isDefault),
108  isDisabled (other.isDisabled),
109  index (other.index),
110  namespaceName (other.namespaceName),
111  alternativeName (other.alternativeName),
112  tagPaths (other.tagPaths),
113  separator (other.separator),
114  convertRatio (QList<int>(other.convertRatio)),
115  specialOpts (other.specialOpts),
116  secondNameOpts (other.secondNameOpts)
117  {
118  }
119 
121  {
122  }
123 
124 public:
125 
126  static QString DM_TAG_CONTAINER();
127  static QString DM_TITLE_CONTAINER();
128  static QString DM_RATING_CONTAINER();
129  static QString DM_COMMENT_CONTAINER();
130  static QString DM_COLORLABEL_CONTAINER();
131 
132 public:
133 
136  bool isDefault;
138  int index;
139 
143  QString namespaceName;
146  QString separator;
147 
152 
155 };
156 
158 DIGIKAM_EXPORT QDebug operator<<(QDebug dbg, const NamespaceEntry& inf);
159 
163 class DIGIKAM_EXPORT DMetadataSettingsContainer
164 {
165 public:
166 
167  explicit DMetadataSettingsContainer();
170 
172 
173 public:
174 
175  void readFromConfig(KConfigGroup& group);
176  void writeToConfig(KConfigGroup& group) const;
177 
181  void defaultValues();
182 
183  bool unifyReadWrite() const;
184  void setUnifyReadWrite(bool b);
185 
186  bool readingAllTags() const;
187  void setReadingAllTags(bool b);
188 
189  void addMapping(const QString& key);
190 
191  QList<NamespaceEntry>& getReadMapping(const QString& key) const;
192 
193  QList<NamespaceEntry>& getWriteMapping(const QString& key) const;
194 
195  QList<QString> mappingKeys() const;
196 
197 private:
198 
199  void defaultTagValues();
200  void defaultTitleValues();
201  void defaultRatingValues();
202  void defaultCommentValues();
203  void defaultColorLabelValues();
204  void readOneGroup(KConfigGroup& group, const QString& name, QList<NamespaceEntry>& container);
205  void writeOneGroup(KConfigGroup& group, const QString& name, QList<NamespaceEntry>& container) const;
206 
207 private:
208 
209  class Private;
210  Private* d;
211 };
212 
214 DIGIKAM_EXPORT QDebug operator<<(QDebug dbg, const DMetadataSettingsContainer& inf);
215 
216 } // namespace Digikam
217 
218 #endif // DIGIKAM_DMETADATA_SETTINGS_CONTAINER_H
Definition: dmetadatasettingscontainer.h:164
The NamespaceEntry class provide a simple container for dmetadata namespaces variables,...
Definition: dmetadatasettingscontainer.h:51
QList< int > convertRatio
Definition: dmetadatasettingscontainer.h:151
QString alternativeName
Definition: dmetadatasettingscontainer.h:144
SpecialOptions
Definition: dmetadatasettingscontainer.h:69
NsSubspace subspace
Definition: dmetadatasettingscontainer.h:135
NamespaceType nsType
Definition: dmetadatasettingscontainer.h:134
NamespaceEntry()
Definition: dmetadatasettingscontainer.h:92
NamespaceEntry(const NamespaceEntry &other)
Definition: dmetadatasettingscontainer.h:104
bool isDisabled
Definition: dmetadatasettingscontainer.h:137
TagType tagPaths
Definition: dmetadatasettingscontainer.h:145
int index
Definition: dmetadatasettingscontainer.h:138
TagType
Definition: dmetadatasettingscontainer.h:63
SpecialOptions specialOpts
Definition: dmetadatasettingscontainer.h:153
SpecialOptions secondNameOpts
Definition: dmetadatasettingscontainer.h:154
~NamespaceEntry()
Definition: dmetadatasettingscontainer.h:120
QString namespaceName
Definition: dmetadatasettingscontainer.h:143
NamespaceType
Definition: dmetadatasettingscontainer.h:81
QString separator
Definition: dmetadatasettingscontainer.h:146
NsSubspace
Definition: dmetadatasettingscontainer.h:56
bool isDefault
Definition: dmetadatasettingscontainer.h:136
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43
QDebug operator<<(QDebug dbg, const DbEngineParameters &p)
Definition: dbengineparameters.cpp:863
@ TAGS
Definition: filtersidebarwidget.h:50
@ RATING
Definition: itemquerybuilder_p.h:83
@ TAG
Definition: itemquerybuilder_p.h:77