1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185 | /* ============================================================
*
* This file is a part of digiKam project
* https://www.digikam.org
*
* Date : 2006-02-23
* Description : item metadata interface - Xmp helpers.
*
* SPDX-FileCopyrightText: 2006-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
* SPDX-FileCopyrightText: 2006-2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
* SPDX-FileCopyrightText: 2011 by Leif Huhn <leif at dkstat dot com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* ============================================================ */
#include "dmetadata.h"
// Qt includes
#include <QLocale>
// Local includes
#include "metaenginesettings.h"
#include "digikam_version.h"
#include "digikam_globals.h"
#include "digikam_debug.h"
namespace Digikam
{
QVariant DMetadata::fromXmpList(const char* const xmpTagName) const
{
QVariant var = getXmpTagVariant(xmpTagName);
if (var.isNull())
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return QVariant(QMetaType(QMetaType::QStringList));
#else
return QVariant(QVariant::StringList);
#endif
}
return var;
}
QVariant DMetadata::fromXmpLangAlt(const char* const xmpTagName) const
{
QVariant var = getXmpTagVariant(xmpTagName);
if (var.isNull())
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return QVariant(QMetaType(QMetaType::QVariantMap));
#else
return QVariant(QVariant::Map);
#endif
}
return var;
}
bool DMetadata::addToXmpTagStringBag(const char* const xmpTagName, const QStringList& entriesToAdd) const<--- Derived function 'DMetadata::addToXmpTagStringBag'
{
QStringList oldEntries = getXmpTagStringBag(xmpTagName, false);
QStringList newEntries = entriesToAdd;
// Create a list of keywords including old one which already exists.
for (QStringList::const_iterator it = oldEntries.constBegin() ; it != oldEntries.constEnd() ; ++it )
{
if (!newEntries.contains(*it))
{
newEntries.append(*it);
}
}
if (setXmpTagStringBag(xmpTagName, newEntries))
{
return true;
}
return false;
}
bool DMetadata::removeFromXmpTagStringBag(const char* const xmpTagName, const QStringList& entriesToRemove) const<--- Derived function 'DMetadata::removeFromXmpTagStringBag'
{
QStringList currentEntries = getXmpTagStringBag(xmpTagName, false);
QStringList newEntries;
// Create a list of current keywords except those that shall be removed
for (QStringList::const_iterator it = currentEntries.constBegin() ; it != currentEntries.constEnd() ; ++it )
{
if (!entriesToRemove.contains(*it))
{
newEntries.append(*it);
}
}
if (setXmpTagStringBag(xmpTagName, newEntries))
{
return true;
}
return false;
}
QStringList DMetadata::getXmpKeywords() const<--- Derived function 'DMetadata::getXmpKeywords'
{
return (getXmpTagStringBag("Xmp.dc.subject", false));
}
bool DMetadata::setXmpKeywords(const QStringList& newKeywords) const<--- Derived function 'DMetadata::setXmpKeywords'
{
return setXmpTagStringBag("Xmp.dc.subject", newKeywords);
}
bool DMetadata::removeXmpKeywords(const QStringList& keywordsToRemove)<--- Derived function 'DMetadata::removeXmpKeywords'
{
return removeFromXmpTagStringBag("Xmp.dc.subject", keywordsToRemove);
}
QStringList DMetadata::getXmpSubCategories() const<--- Derived function 'DMetadata::getXmpSubCategories'
{
return (getXmpTagStringBag("Xmp.photoshop.SupplementalCategories", false));
}
bool DMetadata::setXmpSubCategories(const QStringList& newSubCategories) const<--- Derived function 'DMetadata::setXmpSubCategories'
{
return addToXmpTagStringBag("Xmp.photoshop.SupplementalCategories", newSubCategories);
}
bool DMetadata::removeXmpSubCategories(const QStringList& subCategoriesToRemove)<--- Derived function 'DMetadata::removeXmpSubCategories'
{
return removeFromXmpTagStringBag("Xmp.photoshop.SupplementalCategories", subCategoriesToRemove);
}
QStringList DMetadata::getXmpSubjects() const<--- Derived function 'DMetadata::getXmpSubjects'
{
return (getXmpTagStringBag("Xmp.iptc.SubjectCode", false));
}
bool DMetadata::setXmpSubjects(const QStringList& newSubjects) const<--- Derived function 'DMetadata::setXmpSubjects'
{
return addToXmpTagStringBag("Xmp.iptc.SubjectCode", newSubjects);
}
bool DMetadata::removeXmpSubjects(const QStringList& subjectsToRemove)<--- Derived function 'DMetadata::removeXmpSubjects'
{
return removeFromXmpTagStringBag("Xmp.iptc.SubjectCode", subjectsToRemove);
}
bool DMetadata::removeXmpTags(const QStringList& tagFilters)
{
MetaDataMap m = getXmpTagsDataList(tagFilters);
if (m.isEmpty())
{
return false;
}
for (MetaDataMap::iterator it = m.begin() ; it != m.end() ; ++it)
{
removeXmpTag(it.key().toLatin1().constData());
}
return true;
}
} // namespace Digikam
|