File indexing completed on 2025-01-05 03:56:26
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2010-08-20 0007 * Description : metadata Settings Container. 0008 * 0009 * SPDX-FileCopyrightText: 2015 by Veaceslav Munteanu <veaceslav dot munteanu90 at gmail dot com> 0010 * SPDX-FileCopyrightText: 2015-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #ifndef DIGIKAM_DMETADATA_SETTINGS_CONTAINER_H 0017 #define DIGIKAM_DMETADATA_SETTINGS_CONTAINER_H 0018 0019 // Qt includes 0020 0021 #include <QFlags> 0022 #include <QString> 0023 #include <QMap> 0024 #include <QDebug> 0025 0026 // Local includes 0027 0028 #include "digikam_export.h" 0029 0030 class KConfigGroup; 0031 0032 namespace Digikam 0033 { 0034 0035 /** 0036 * @brief The NamespaceEntry class provide a simple container 0037 * for dmetadata namespaces variables, such 0038 * as names, what types of data expects and extra 0039 * xml tags 0040 */ 0041 class DIGIKAM_EXPORT NamespaceEntry 0042 { 0043 0044 public: 0045 0046 enum NsSubspace 0047 { 0048 EXIF = 0, 0049 IPTC = 1, 0050 XMP = 2 0051 }; 0052 0053 enum TagType 0054 { 0055 TAG = 0, 0056 TAGPATH = 1 0057 }; 0058 0059 enum SpecialOptions 0060 { 0061 NO_OPTS = 0, 0062 COMMENT_ALTLANG = 1, 0063 COMMENT_ATLLANGLIST = 2, 0064 COMMENT_XMP = 3, 0065 COMMENT_JPEG = 4, 0066 TAG_XMPBAG = 5, 0067 TAG_XMPSEQ = 6, 0068 TAG_ACDSEE = 7 0069 }; 0070 0071 enum NamespaceType 0072 { 0073 TAGS = 0, 0074 TITLE = 1, 0075 RATING = 2, 0076 COMMENT = 3, 0077 PICKLABEL = 4, 0078 COLORLABEL = 5 0079 }; 0080 0081 public: 0082 0083 explicit NamespaceEntry() 0084 : nsType (TAGS), 0085 subspace (XMP), 0086 isDefault (true), 0087 isDisabled (false), 0088 index (-1), 0089 tagPaths (TAGPATH), 0090 specialOpts (NO_OPTS), 0091 secondNameOpts (NO_OPTS) 0092 { 0093 } 0094 0095 NamespaceEntry(const NamespaceEntry& other) 0096 : nsType (other.nsType), 0097 subspace (other.subspace), 0098 isDefault (other.isDefault), 0099 isDisabled (other.isDisabled), 0100 index (other.index), 0101 namespaceName (other.namespaceName), 0102 alternativeName (other.alternativeName), 0103 tagPaths (other.tagPaths), 0104 separator (other.separator), 0105 convertRatio (QList<int>(other.convertRatio)), 0106 specialOpts (other.specialOpts), 0107 secondNameOpts (other.secondNameOpts) 0108 { 0109 } 0110 0111 ~NamespaceEntry() 0112 { 0113 } 0114 0115 public: 0116 0117 static QString DM_TAG_CONTAINER(); 0118 static QString DM_TITLE_CONTAINER(); 0119 static QString DM_RATING_CONTAINER(); 0120 static QString DM_COMMENT_CONTAINER(); 0121 static QString DM_PICKLABEL_CONTAINER(); 0122 static QString DM_COLORLABEL_CONTAINER(); 0123 0124 public: 0125 0126 NamespaceType nsType; 0127 NsSubspace subspace; 0128 bool isDefault; 0129 bool isDisabled; 0130 int index; 0131 0132 /** 0133 * Tag Options 0134 */ 0135 QString namespaceName; 0136 QString alternativeName; 0137 TagType tagPaths; 0138 QString separator; 0139 0140 /** 0141 * Rating Options 0142 */ 0143 QList<int> convertRatio; 0144 0145 SpecialOptions specialOpts; 0146 SpecialOptions secondNameOpts; 0147 }; 0148 0149 //! qDebug() stream operator. Writes property @a inf to the debug output in a nicely formatted way. 0150 DIGIKAM_EXPORT QDebug operator<<(QDebug dbg, const NamespaceEntry& inf); 0151 0152 /** 0153 * The class DMetadataSettingsContainer is designed to dynamically add namespaces. 0154 */ 0155 class DIGIKAM_EXPORT DMetadataSettingsContainer 0156 { 0157 public: 0158 0159 explicit DMetadataSettingsContainer(); 0160 DMetadataSettingsContainer(const DMetadataSettingsContainer& other); 0161 ~DMetadataSettingsContainer(); 0162 0163 DMetadataSettingsContainer& operator=(const DMetadataSettingsContainer& other); 0164 0165 public: 0166 0167 void readFromConfig(KConfigGroup& group); 0168 void writeToConfig(KConfigGroup& group) const; 0169 0170 /** 0171 * @brief defaultValues - default namespaces used by digiKam 0172 */ 0173 void defaultValues(); 0174 0175 bool unifyReadWrite() const; 0176 void setUnifyReadWrite(bool b); 0177 0178 bool readingAllTags() const; 0179 void setReadingAllTags(bool b); 0180 0181 void addMapping(const QString& key); 0182 0183 QList<NamespaceEntry>& getReadMapping(const QString& key) const; 0184 0185 QList<NamespaceEntry>& getWriteMapping(const QString& key) const; 0186 0187 QList<QString> mappingKeys() const; 0188 0189 QString translateMappingKey(const QString& key) const; 0190 0191 private: 0192 0193 void defaultTagValues(); 0194 void defaultTitleValues(); 0195 void defaultRatingValues(); 0196 void defaultCommentValues(); 0197 void defaultColorLabelValues(); 0198 void readOneGroup(KConfigGroup& group, const QString& name, QList<NamespaceEntry>& container); 0199 void writeOneGroup(KConfigGroup& group, const QString& name, QList<NamespaceEntry>& container) const; 0200 0201 private: 0202 0203 class Private; 0204 Private* d; 0205 }; 0206 0207 //! qDebug() stream operator. Writes property @a inf to the debug output in a nicely formatted way. 0208 DIGIKAM_EXPORT QDebug operator<<(QDebug dbg, const DMetadataSettingsContainer& inf); 0209 0210 } // namespace Digikam 0211 0212 #endif // DIGIKAM_DMETADATA_SETTINGS_CONTAINER_H