mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
[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.
This commit is contained in:
parent
fa60438376
commit
dcdf4b01c8
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue