Commit dcdf4b01 authored by Stefan Brüns's avatar Stefan Brüns
Browse files

[BalooRolesProvider] Reduce number of XAttr reads

Typically most of the extended attributes are not set for a file. Instead
of trying to fetch each attribute individually check which attributes
exist first.
parent fa604383
......@@ -91,17 +91,37 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f
rangeBegin = rangeEnd;
}
KFileMetaData::UserMetaData md(file.path());
KFileMetaData::UserMetaData::Attributes attributes;
if (roles.contains("tags")) {
values.insert("tags", tagsFromValues(md.tags()));
attributes |= KFileMetaData::UserMetaData::Tags;
}
if (roles.contains("rating")) {
values.insert("rating", QString::number(md.rating()));
attributes |= KFileMetaData::UserMetaData::Rating;
}
if (roles.contains("comment")) {
values.insert("comment", md.userComment());
attributes |= KFileMetaData::UserMetaData::Comment;
}
if (roles.contains("originUrl")) {
attributes |= KFileMetaData::UserMetaData::OriginUrl;
}
if (attributes == KFileMetaData::UserMetaData::None) {
return values;
}
KFileMetaData::UserMetaData md(file.path());
attributes = md.queryAttributes(attributes);
if (attributes & KFileMetaData::UserMetaData::Tags) {
values.insert("tags", tagsFromValues(md.tags()));
}
if (attributes & KFileMetaData::UserMetaData::Rating) {
values.insert("rating", QString::number(md.rating()));
}
if (attributes & KFileMetaData::UserMetaData::Comment) {
values.insert("comment", md.userComment());
}
if (attributes & KFileMetaData::UserMetaData::OriginUrl) {
values.insert("originUrl", md.originUrl());
}
......
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