diff --git a/src/propertymaputil_p.h b/src/propertymaputil_p.h --- a/src/propertymaputil_p.h +++ b/src/propertymaputil_p.h @@ -23,15 +23,23 @@ /** * Converts the property map into a variant map - * using the property name as key. + * using the property name as key. Converts maps + * with duplicated keys into single entry maps + * with lists. */ static inline QVariantMap toNamedVariantMap(const KFileMetaData::PropertyMap& propMap) { QVariantMap map; - KFileMetaData::PropertyMap::const_iterator it = propMap.constBegin(); - for (; it != propMap.constEnd(); it++) { - KFileMetaData::PropertyInfo pi(it.key()); - map.insertMulti(pi.name(), it.value()); + + auto uniqueKeys = propMap.uniqueKeys(); + for (const auto& key : uniqueKeys) + { + KFileMetaData::PropertyInfo pi(key); + if (propMap.count(key) > 1) { + map.insert(pi.name(), propMap.values(key)); + } else { + map.insert(pi.name(), propMap.value(key)); + } } return map;