X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/30691235c5acc4c5b30ffc8820d2ef7c55fc632e..cebcf8dbb3ff310aa0761ad452e4ca79278d7831:/src/kitemviews/kfileitemmodelrolesupdater.cpp diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index bcd172d02..ac14ed795 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -13,8 +13,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -556,15 +558,13 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem &item, const QPi const QStringList overlays = data["iconOverlays"].toStringList(); // Strangely KFileItem::overlays() returns empty string-values, so // we need to check first whether an overlay must be drawn at all. - // It is more efficient to do it here, as KIconLoader::drawOverlays() - // assumes that an overlay will be drawn and has some additional - // setup time. if (!scaledPixmap.isNull()) { for (const QString &overlay : overlays) { if (!overlay.isEmpty()) { // There is at least one overlay, draw all overlays above m_pixmap // and cancel the check - KIconLoader::global()->drawOverlays(overlays, scaledPixmap, KIconLoader::Desktop); + const QSize size = scaledPixmap.size(); + scaledPixmap = KIconUtils::addOverlays(scaledPixmap, overlays).pixmap(size); break; } } @@ -1287,11 +1287,11 @@ bool KFileItemModelRolesUpdater::applyResolvedRoles(int index, ResolveHint hint) void KFileItemModelRolesUpdater::startDirectorySizeCounting(const KFileItem &item, int index) { - if (!item.isLocalFile()) { + if (ContentDisplaySettings::directorySizeMode() == ContentDisplaySettings::EnumDirectorySizeMode::None || !item.isLocalFile()) { return; } - if (ContentDisplaySettings::directorySizeCount() || item.isSlow()) { + if (ContentDisplaySettings::directorySizeMode() == ContentDisplaySettings::EnumDirectorySizeMode::ContentCount || item.isSlow()) { // fastpath no recursion necessary auto data = m_model->data(index); @@ -1306,8 +1306,6 @@ void KFileItemModelRolesUpdater::startDirectorySizeCounting(const KFileItem &ite url = QUrl::fromLocalFile(item.localPath()); } - data.insert("isExpandable", false); - data.insert("count", 0); data.insert("size", -2); // invalid size, -1 means size unknown disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged); @@ -1339,14 +1337,21 @@ void KFileItemModelRolesUpdater::startDirectorySizeCounting(const KFileItem &ite ++entryCount; } - // count has changed - if (origCount < entryCount) { - QHash data; - data.insert("isExpandable", entryCount > 0); - data.insert("count", entryCount); + QHash newData; + QVariant expandable = data.value("isExpandable"); + if (expandable.isNull() || expandable.toBool() != (entryCount > 0)) { + // if expandable has changed + newData.insert("isExpandable", entryCount > 0); + } + + if (origCount != entryCount) { + // count has changed + newData.insert("count", entryCount); + } + if (!newData.isEmpty()) { disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged); - m_model->setData(index, data); + m_model->setData(index, newData); connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged); } });