diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ project(baloo-widgets VERSION ${KDE_APPLICATIONS_VERSION}) set(QT_MIN_VERSION "5.8.0") -set(KF5_MIN_VERSION "5.57.0") +set(KF5_MIN_VERSION "5.58.0") find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ${ECM_MODULE_PATH}) diff --git a/src/propertymaputil_p.h b/src/propertymaputil_p.h --- a/src/propertymaputil_p.h +++ b/src/propertymaputil_p.h @@ -21,17 +21,38 @@ #include #include +#include + /** * 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++) { + if (propMap.isEmpty()) { + return map; + } + + auto it = propMap.constBegin(); + while (it != propMap.constEnd()) { KFileMetaData::PropertyInfo pi(it.key()); - map.insertMulti(pi.name(), it.value()); + auto range = propMap.equal_range(it.key()); + auto distance = std::distance(range.first, range.second); + if (distance > 1) { + QVariantList list; + list.reserve(static_cast(distance)); + for (int i = 0; i < distance; ++i) { + list.append(it.value()); + ++it; + } + map.insert(pi.name(), list); + } else { + map.insert(pi.name(), it.value()); + ++it; + } } return map;