Commit 4fdb2048 authored by Stefan Brüns's avatar Stefan Brüns

[UserMetaData] Shortcut attribute queries for the common case

Summary:
Optimize the common case of only a few or no attributes set, no functional
changes.
Bump KF5_MIN_VERSION to 5.60 for KFM:UMD:queryAttributes().

Test Plan:
ctest

Depends on D20967

Reviewers: #baloo, #frameworks, ngraham, astippich, lbeltrame

Reviewed By: lbeltrame

Tags: #baloo

Differential Revision: https://phabricator.kde.org/D21004
parent 36bcd8fc
......@@ -8,7 +8,7 @@ set (KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATI
project(baloo-widgets VERSION ${KDE_APPLICATIONS_VERSION})
set(QT_MIN_VERSION "5.11.0")
set(KF5_MIN_VERSION "5.58.0")
set(KF5_MIN_VERSION "5.60.0")
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ${ECM_MODULE_PATH})
......
......@@ -30,26 +30,38 @@ namespace Private
QVariantMap convertUserMetaData(const KFileMetaData::UserMetaData& metaData)
{
using Attribute = KFileMetaData::UserMetaData::Attribute;
QVariantMap properties;
const QStringList tags = metaData.tags();
if (!tags.isEmpty()) {
properties.insert(QStringLiteral("tags"), tags);
QFlags<Attribute> attributes = metaData.queryAttributes(Attribute::Tags | Attribute::Rating |
Attribute::Comment | Attribute::OriginUrl);
if (attributes & Attribute::Tags) {
QStringList tags = metaData.tags();
if (!tags.isEmpty()) {
properties.insert(QStringLiteral("tags"), tags);
}
}
int rating = metaData.rating();
if (rating) {
properties.insert(QStringLiteral("rating"), rating);
if (attributes & Attribute::Rating) {
int rating = metaData.rating();
if (rating) {
properties.insert(QStringLiteral("rating"), rating);
}
}
const QString comment = metaData.userComment();
if (!comment.isEmpty()) {
properties.insert(QStringLiteral("userComment"), comment);
if (attributes & Attribute::Comment) {
QString comment = metaData.userComment();
if (!comment.isEmpty()) {
properties.insert(QStringLiteral("userComment"), comment);
}
}
const QString originUrl = metaData.originUrl().toDisplayString();
if (!originUrl.isEmpty()) {
properties.insert(QStringLiteral("originUrl"), originUrl);
if (attributes & Attribute::OriginUrl) {
const QString originUrl = metaData.originUrl().toDisplayString();
if (!originUrl.isEmpty()) {
properties.insert(QStringLiteral("originUrl"), originUrl);
}
}
return properties;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment