Don't include iconOverlays in rolesData if it is empty

If this role isn't in the model yet, it would be `QVariant::Invalid`
which is obviously a distinct type from an empty string list.

This means `KFileItemModel::setData` treats them non-equal and
potentially does expensive operations on the model, which is
called every time a role is resolved in `KFileItemModelRolesUpdater`.

With this change, the number of pointless layout calculations is
significantly reduced.
This commit is contained in:
Kai Uwe Broulik 2022-08-15 15:02:13 +02:00
parent f45d2e9854
commit fac08af081

View file

@ -1350,7 +1350,9 @@ QHash<QByteArray, QVariant> KFileItemModelRolesUpdater::rolesData(const KFileIte
for (KOverlayIconPlugin *it : qAsConst(m_overlayIconsPlugin)) {
overlays.append(it->getOverlays(item.url()));
}
data.insert("iconOverlays", overlays);
if (!overlays.isEmpty()) {
data.insert("iconOverlays", overlays);
}
#if HAVE_BALOO
if (m_balooFileMonitor) {