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 @@ -23,17 +23,33 @@ /** * 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++) { + auto it = propMap.constBegin(); + while (it != propMap.constEnd()) { KFileMetaData::PropertyInfo pi(it.key()); - map.insertMulti(pi.name(), it.value()); + auto nextIt = ++it; + if (nextIt != propMap.constEnd()) { + break; + } + if (it.key() != nextIt.key()) { + map.insert(pi.name(), it.value()); + } else { + QVariantList list = {it.value(), nextIt.value()}; + ++nextIt; + while (nextIt != propMap.constEnd() && it.key() == nextIt.key()) { + list.append(nextIt.value()); + ++nextIt; + } + map.insert(pi.name(), list); + } + it = nextIt; } - return map; }