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-2021 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 44 /** 45 * @brief The NamespaceEntry class provide a simple container 46 * for dmetadata namespaces variables, such 47 * as names, what types of data expects and extra 48 * xml tags 49 */ 50 class DIGIKAM_EXPORT NamespaceEntry 51 { 52 53 public: 54 55 enum NsSubspace 56 { 57 EXIF = 0, 58 IPTC = 1, 59 XMP = 2 60 }; 61 62 enum TagType 63 { 64 TAG = 0, 65 TAGPATH = 1 66 }; 67 68 enum SpecialOptions 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 80 enum NamespaceType 81 { 82 TAGS = 0, 83 TITLE = 1, 84 RATING = 2, 85 COMMENT = 3, 86 // PICKLABEL = 4, 87 COLORLABEL = 5 88 }; 89 90 public: 91 NamespaceEntry()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 NamespaceEntry(const NamespaceEntry & other)104 NamespaceEntry(const NamespaceEntry& other) 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 ~NamespaceEntry()120 ~NamespaceEntry() 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 134 NamespaceType nsType; 135 NsSubspace subspace; 136 bool isDefault; 137 bool isDisabled; 138 int index; 139 140 /** 141 * Tag Options 142 */ 143 QString namespaceName; 144 QString alternativeName; 145 TagType tagPaths; 146 QString separator; 147 148 /** 149 * Rating Options 150 */ 151 QList<int> convertRatio; 152 153 SpecialOptions specialOpts; 154 SpecialOptions secondNameOpts; 155 }; 156 157 //! qDebug() stream operator. Writes property @a inf to the debug output in a nicely formatted way. 158 DIGIKAM_EXPORT QDebug operator<<(QDebug dbg, const NamespaceEntry& inf); 159 160 /** 161 * The class DMetadataSettingsContainer is designed to dynamically add namespaces. 162 */ 163 class DIGIKAM_EXPORT DMetadataSettingsContainer 164 { 165 public: 166 167 explicit DMetadataSettingsContainer(); 168 DMetadataSettingsContainer(const DMetadataSettingsContainer& other); 169 ~DMetadataSettingsContainer(); 170 171 DMetadataSettingsContainer& operator=(const DMetadataSettingsContainer& other); 172 173 public: 174 175 void readFromConfig(KConfigGroup& group); 176 void writeToConfig(KConfigGroup& group) const; 177 178 /** 179 * @brief defaultValues - default namespaces used by digiKam 180 */ 181 void defaultValues(); 182 183 bool unifyReadWrite() const; 184 void setUnifyReadWrite(bool b); 185 186 void addMapping(const QString& key); 187 188 QList<NamespaceEntry>& getReadMapping(const QString& key) const; 189 190 QList<NamespaceEntry>& getWriteMapping(const QString& key) const; 191 192 QList<QString> mappingKeys() const; 193 194 private: 195 196 void defaultTagValues(); 197 void defaultTitleValues(); 198 void defaultRatingValues(); 199 void defaultCommentValues(); 200 void defaultColorLabelValues(); 201 void readOneGroup(KConfigGroup& group, const QString& name, QList<NamespaceEntry>& container); 202 void writeOneGroup(KConfigGroup& group, const QString& name, QList<NamespaceEntry>& container) const; 203 204 private: 205 206 class Private; 207 Private* d; 208 }; 209 210 //! qDebug() stream operator. Writes property @a inf to the debug output in a nicely formatted way. 211 DIGIKAM_EXPORT QDebug operator<<(QDebug dbg, const DMetadataSettingsContainer& inf); 212 213 } // namespace Digikam 214 215 #endif // DIGIKAM_DMETADATA_SETTINGS_CONTAINER_H 216