]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Don't include `iconOverlays` in rolesData if it is empty
authorKai Uwe Broulik <kde@privat.broulik.de>
Mon, 15 Aug 2022 13:02:13 +0000 (15:02 +0200)
committerKai Uwe Broulik <kde@privat.broulik.de>
Mon, 15 Aug 2022 13:02:13 +0000 (15:02 +0200)
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.

src/kitemviews/kfileitemmodelrolesupdater.cpp

index ed762e98ffc881284ae4db87d12c9afe35c7f09c..2107ebc5ef86ae6cf593b6b2abc07d79197244bc 100644 (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) {