diff --git a/CMakeLists.txt b/CMakeLists.txt index 78a89a558..7816b5717 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,155 +1,155 @@ cmake_minimum_required(VERSION 3.0) # KDE Application Version, managed by release script set (KDE_APPLICATIONS_VERSION_MAJOR "19") set (KDE_APPLICATIONS_VERSION_MINOR "07") set (KDE_APPLICATIONS_VERSION_MICRO "70") set (KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}") project(Dolphin VERSION ${KDE_APPLICATIONS_VERSION}) set(QT_MIN_VERSION "5.8.0") -set(KF5_MIN_VERSION "5.56.0") +set(KF5_MIN_VERSION "5.58.0") # ECM setup find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) include(ECMSetupVersion) include(ECMGenerateHeaders) include(CMakePackageConfigHelpers) include(GenerateExportHeader) include(FeatureSummary) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(ECMQtDeclareLoggingCategory) ecm_setup_version(${KDE_APPLICATIONS_VERSION} VARIABLE_PREFIX DOLPHIN VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/src/dolphin_version.h" ) ecm_setup_version("5.0.0" VARIABLE_PREFIX DOLPHINVCS VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/dolphinvcs_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/DolphinVcsConfigVersion.cmake" SOVERSION 5 ) ecm_setup_version("5.0.0" VARIABLE_PREFIX DOLPHINPRIVATE SOVERSION 5 ) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Concurrent Widgets Gui DBus ) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS DocTools Init KCMUtils NewStuff CoreAddons I18n DBusAddons Bookmarks Config KIO Parts Solid IconThemes Completion TextWidgets Notifications Crash ) find_package(KF5 ${KF5_MIN_VERSION} OPTIONAL_COMPONENTS Activities ) set_package_properties(KF5Activities PROPERTIES DESCRIPTION "KActivities libraries" URL "http://www.kde.org" TYPE OPTIONAL PURPOSE "For tracking which folders are frequently accessed on a Plasma desktop" ) find_package(Phonon4Qt5 CONFIG REQUIRED) find_package(KF5Baloo ${KF5_MIN_VERSION}) set_package_properties(KF5Baloo PROPERTIES DESCRIPTION "Baloo Core libraries" URL "http://www.kde.org" TYPE OPTIONAL PURPOSE "For adding desktop-wide search and tagging support to dolphin" ) find_package(KF5BalooWidgets 19.07.70) set_package_properties(KF5BalooWidgets PROPERTIES DESCRIPTION "Baloos Widgets" URL "http://www.kde.org" TYPE OPTIONAL ) find_package(KF5FileMetaData ${KF5_MIN_VERSION}) set_package_properties(KF5FileMetaData PROPERTIES URL "https://projects.kde.org/kfilemetadata" TYPE OPTIONAL PURPOSE "For accessing file metadata labels" ) if (KF5Activities_FOUND) set(HAVE_KACTIVITIES TRUE) endif() if (KF5Baloo_FOUND AND KF5BalooWidgets_FOUND AND KF5FileMetaData_FOUND) message(STATUS "Baloo packages are found") set(HAVE_BALOO TRUE) else() message(WARNING "Baloo packages not found. They are needed for the metadata features of Dolphin (including the information panel).") endif() # TODO: drop HAVE_TERMINAL once we are sure the terminal panel works on Windows too. if(WIN32) set(HAVE_TERMINAL FALSE) else() set(HAVE_TERMINAL TRUE) endif() add_subdirectory(src) add_subdirectory(doc) # CMake files set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/DolphinVcs") configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/DolphinVcsConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/DolphinVcsConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/DolphinVcsConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/DolphinVcsConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT DolphinVcsTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE DolphinVcsTargets.cmake ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dolphinvcs_version.h" DESTINATION "${KDE_INSTALL_INCLUDEDIR}/Dolphin" COMPONENT Devel ) configure_file(org.kde.dolphin.FileManager1.service.in ${CMAKE_CURRENT_BINARY_DIR}/org.kde.dolphin.FileManager1.service) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.dolphin.FileManager1.service DESTINATION ${DBUS_SERVICES_INSTALL_DIR}) install( FILES dolphin.categories DESTINATION ${KDE_INSTALL_CONFDIR} ) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/kitemviews/private/kbaloorolesprovider.cpp b/src/kitemviews/private/kbaloorolesprovider.cpp index 469f07915..f3671540d 100644 --- a/src/kitemviews/private/kbaloorolesprovider.cpp +++ b/src/kitemviews/private/kbaloorolesprovider.cpp @@ -1,143 +1,159 @@ /*************************************************************************** * Copyright (C) 2012 by Peter Penz * * Copyright (C) 2013 by Vishesh Handa * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "kbaloorolesprovider.h" #include #include #include #include #include #include #include #include struct KBalooRolesProviderSingleton { KBalooRolesProvider instance; }; Q_GLOBAL_STATIC(KBalooRolesProviderSingleton, s_balooRolesProvider) KBalooRolesProvider& KBalooRolesProvider::instance() { return s_balooRolesProvider->instance; } KBalooRolesProvider::~KBalooRolesProvider() { } QSet KBalooRolesProvider::roles() const { return m_roles; } QHash KBalooRolesProvider::roleValues(const Baloo::File& file, const QSet& roles) const { QHash values; - QMapIterator it(file.properties()); - while (it.hasNext()) { - it.next(); + using entry = std::pair; + + const auto& propMap = file.properties(); + auto rangeBegin = propMap.constKeyValueBegin(); + + while (rangeBegin != propMap.constKeyValueEnd()) { + auto key = (*rangeBegin).first; + const KFileMetaData::PropertyInfo propertyInfo(key); + const QByteArray role = roleForProperty(propertyInfo.name()); + + auto rangeEnd = std::find_if(rangeBegin, propMap.constKeyValueEnd(), + [key](const entry& e) { return e.first != key; }); - const KFileMetaData::PropertyInfo pi(it.key()); - const QString property = pi.name(); - const QByteArray role = roleForProperty(property); if (role.isEmpty() || !roles.contains(role)) { + rangeBegin = rangeEnd; continue; } - values.insert(role, pi.formatAsDisplayString(it.value())); + auto distance = std::distance(rangeBegin, rangeEnd); + if (distance > 1) { + QVariantList list; + list.reserve(static_cast(distance)); + std::for_each(rangeBegin, rangeEnd, [&list](const entry& s) { list.append(s.second); }); + values.insert(role, propertyInfo.formatAsDisplayString(list)); + } else { + values.insert(role, propertyInfo.formatAsDisplayString((*rangeBegin).second)); + } + rangeBegin = rangeEnd; } KFileMetaData::UserMetaData md(file.path()); if (roles.contains("tags")) { values.insert("tags", tagsFromValues(md.tags())); } if (roles.contains("rating")) { values.insert("rating", QString::number(md.rating())); } if (roles.contains("comment")) { values.insert("comment", md.userComment()); } if (roles.contains("originUrl")) { values.insert("originUrl", md.originUrl()); } return values; } QByteArray KBalooRolesProvider::roleForProperty(const QString& property) const { return m_roleForProperty.value(property); } KBalooRolesProvider::KBalooRolesProvider() : m_roles(), m_roleForProperty() { struct PropertyInfo { const char* const property; const char* const role; }; // Mapping from the URIs to the KFileItemModel roles. Note that this must not be // a 1:1 mapping: One role may contain several URI-values static const PropertyInfo propertyInfoList[] = { { "rating", "rating" }, { "tag", "tags" }, { "comment", "comment" }, { "title", "title" }, { "wordCount", "wordCount" }, { "lineCount", "lineCount" }, { "width", "width" }, { "height", "height" }, { "imageDateTime", "imageDateTime"}, { "imageOrientation", "orientation", }, { "artist", "artist" }, { "genre", "genre" }, { "album", "album" }, { "duration", "duration" }, { "bitRate", "bitrate" }, { "aspectRatio", "aspectRatio" }, { "frameRate", "frameRate" }, { "releaseYear", "releaseYear" }, { "trackNumber", "track" }, { "originUrl", "originUrl" } }; for (unsigned int i = 0; i < sizeof(propertyInfoList) / sizeof(PropertyInfo); ++i) { m_roleForProperty.insert(propertyInfoList[i].property, propertyInfoList[i].role); m_roles.insert(propertyInfoList[i].role); } } QString KBalooRolesProvider::tagsFromValues(const QStringList& values) const { QStringList alphabeticalOrderTags = values; QCollator coll; coll.setNumericMode(true); std::sort(alphabeticalOrderTags.begin(), alphabeticalOrderTags.end(), [&](const QString& s1, const QString& s2){ return coll.compare(s1, s2) < 0; }); return alphabeticalOrderTags.join(QStringLiteral(", ")); }