diff options
| author | Kai Uwe Broulik <[email protected]> | 2022-08-15 15:02:13 +0200 |
|---|---|---|
| committer | Kai Uwe Broulik <[email protected]> | 2022-08-15 15:02:13 +0200 |
| commit | fac08af081467a798a649cde6f8ca615e797c137 (patch) | |
| tree | 40ef9d3c824e62e1840e917b55639c14aa925c53 | |
| parent | f45d2e985422a0ca96098155a20d32ec4783e5fa (diff) | |
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.
| -rw-r--r-- | src/kitemviews/kfileitemmodelrolesupdater.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index ed762e98f..2107ebc5e 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -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) { |
