8#include <klocalizedstring.h>
43 return i18n(
"Drop all meta data");
68 return "PriorityToFirst";
72 return i18n(
"Priority to first meta data");
77 return i18n(
"Use in priority the meta data from the layers at the bottom of the stack.");
85 Q_FOREACH (
const Store* store, srcs) {
87 Q_FOREACH (
const QString & key, keys) {
108 return "OnlyIdentical";
112 return i18n(
"Only identical");
117 return i18n(
"Keep only meta data that are identical");
126 Q_ASSERT(srcs.size() > 0);
128 Q_FOREACH (
const QString & key, keys) {
130 const Entry& e = srcs[0]->getEntry(key);
132 Q_FOREACH (
const Store* store, srcs) {
162 return i18n(
"Smart");
167 return i18n(
"This merge strategy attempts to find the best solution for merging, "
168 "for instance by merging the list of authors together, or keeping "
169 "identical photographic information.");
180 for (
int i = 0; i < srcs.size(); i++) {
181 if (srcs[i]->containsEntry(key)) {
182 const Value& nv = srcs[i]->getEntry(key).value();
185 for (
int j = 0; j < scoreValues.size(); j++) {
187 if (sv.
value == nv) {
189 sv.
score += scores[i];
195 sv.
score = scores[i];
197 scoreValues.append(sv);
202 if (scoreValues.size() < 1) {
203 warnMetaData <<
"SmartMergeStrategy::election returned less than 1 score value";
207 double bestScore = -1.0;
208 Q_FOREACH (
const ScoreValue& sv, scoreValues) {
209 if (sv.
score > bestScore) {
210 bestScore = sv.
score;
215 return bestSv->
value;
224 bool foundOnce =
false;
226 Q_FOREACH (
const Store* store, srcs) {
240 Q_ASSERT(srcs.size() == scores.size());
241 Q_ASSERT(srcs.size() > 0);
242 if (srcs.size() == 1) {
253 QMultiMap<double, const Store*> scores2srcs;
254 for (
int i = 0; i < scores.size(); ++i) {
255 scores2srcs.insert(scores[i], srcs[i]);
257 srcs = scores2srcs.values();
258 scores = scores2srcs.keys();
262 if (scores[0] > 2 * scores[1]) {
269 Q_FOREACH (
const Store* store, srcs) {
271 Q_FOREACH (
const QString & key, keys) {
284 for (
int i = 0; i < srcs.size(); i++) {
285 const Store* store = srcs[i];
287 double score = scores[i];
293 dst->
getEntry(XMPSchema,
"Rating").
value() = QVariant((
int)(rating / norm));
297 mergeEntry(dst, srcs, dcSchema,
"contributor");
301 mergeEntry(dst, srcs, XMPRightsSchema,
"Owner");
302 mergeEntry(dst, srcs, XMPSchema,
"Identifier");
const KisMetaData::Value & value() const