X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/a24327cd50ef17b953ecb908d260b73460158107..15baa93640bbb49162f26d439e006729ee9c3441:/src/kitemviews/kfileitemmodel.cpp diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index e8cd8f393..c06202fd8 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -19,9 +19,11 @@ #include #include +#include #include #include #include +#include Q_GLOBAL_STATIC_WITH_ARGS(QMutex, s_collatorMutex, (QMutex::Recursive)) @@ -487,7 +489,7 @@ void KFileItemModel::setRoles(const QSet& roles) m_itemData[i]->values = retrieveData(m_itemData.at(i)->item, m_itemData.at(i)->parent); } - emit itemsChanged(KItemRangeList() << KItemRange(0, count()), changedRoles); + Q_EMIT itemsChanged(KItemRangeList() << KItemRange(0, count()), changedRoles); } // Clear the 'values' of all filtered items. They will be re-populated with the @@ -892,13 +894,13 @@ void KFileItemModel::resortAllItems() movedToIndexes.append(newIndex); } - emit itemsMoved(KItemRange(firstMovedIndex, movedItemsCount), movedToIndexes); + Q_EMIT itemsMoved(KItemRange(firstMovedIndex, movedItemsCount), movedToIndexes); } else if (groupedSorting()) { // The groups might have changed even if the order of the items has not. const QList > oldGroups = m_groups; m_groups.clear(); if (groups() != oldGroups) { - emit groupsChanged(); + Q_EMIT groupsChanged(); } } @@ -917,7 +919,9 @@ void KFileItemModel::slotCompleted() // Note that the parent folder must be expanded before any of its subfolders become visible. // Therefore, some URLs in m_restoredExpandedUrls might not be visible yet // -> we expand the first visible URL we find in m_restoredExpandedUrls. - for (const QUrl& url : qAsConst(m_urlsToExpand)) { + QMutableSetIterator it(m_urlsToExpand); + while (it.hasNext()) { + const QUrl url = it.next(); const int indexForUrl = index(url); if (indexForUrl >= 0) { m_urlsToExpand.remove(url); @@ -934,7 +938,7 @@ void KFileItemModel::slotCompleted() m_urlsToExpand.clear(); } - emit directoryLoadingCompleted(); + Q_EMIT directoryLoadingCompleted(); } void KFileItemModel::slotCanceled() @@ -942,7 +946,7 @@ void KFileItemModel::slotCanceled() m_maximumUpdateIntervalTimer->stop(); dispatchPendingItemsToInsert(); - emit directoryLoadingCanceled(); + Q_EMIT directoryLoadingCanceled(); } void KFileItemModel::slotItemsAdded(const QUrl &directoryUrl, const KFileItemList& items) @@ -1143,7 +1147,7 @@ void KFileItemModel::slotClear() qDeleteAll(m_itemData); m_itemData.clear(); m_items.clear(); - emit itemsRemoved(KItemRangeList() << KItemRange(0, removedCount)); + Q_EMIT itemsRemoved(KItemRangeList() << KItemRange(0, removedCount)); } m_expandedDirs.clear(); @@ -1259,7 +1263,7 @@ void KFileItemModel::insertItems(QList& newItems) // It will be re-populated with the updated indices if index(const QUrl&) is called. m_items.clear(); - emit itemsInserted(itemRanges); + Q_EMIT itemsInserted(itemRanges); #ifdef KFILEITEMMODEL_DEBUG qCDebug(DolphinDebug) << "[TIME] Inserting of" << newItems.count() << "items:" << timer.elapsed(); @@ -1312,7 +1316,7 @@ void KFileItemModel::removeItems(const KItemRangeList& itemRanges, RemoveItemsBe // It will be re-populated with the updated indices if index(const QUrl&) is called. m_items.clear(); - emit itemsRemoved(itemRanges); + Q_EMIT itemsRemoved(itemRanges); } QList KFileItemModel::createItemDataList(const QUrl& parentUrl, const KFileItemList& items) const @@ -1428,7 +1432,7 @@ void KFileItemModel::removeExpandedItems() void KFileItemModel::emitItemsChangedAndTriggerResorting(const KItemRangeList& itemRanges, const QSet& changedRoles) { - emit itemsChanged(itemRanges, changedRoles); + Q_EMIT itemsChanged(itemRanges, changedRoles); // Trigger a resorting if necessary. Note that this can happen even if the sort // role has not changed at all because the file name can be used as a fallback. @@ -1655,7 +1659,13 @@ QHash KFileItemModel::retrieveData(const KFileItem& item, } if (item.isMimeTypeKnown()) { - data.insert(sharedValue("iconName"), item.iconName()); + QString iconName = item.iconName(); + if (!QIcon::hasThemeIcon(iconName)) { + QMimeType mimeType = QMimeDatabase().mimeTypeForName(item.mimetype()); + iconName = mimeType.genericIconName(); + } + + data.insert(sharedValue("iconName"), iconName); if (m_requestRole[TypeRole]) { data.insert(sharedValue("type"), item.mimeComment()); @@ -2307,14 +2317,14 @@ void KFileItemModel::emitSortProgress(int resolvedCount) resortAllItems(); } - emit directorySortingProgress(100); + Q_EMIT directorySortingProgress(100); } else if (itemCount > 0) { resolvedCount = qBound(0, resolvedCount, itemCount); const int progress = resolvedCount * 100 / itemCount; if (m_sortingProgressPercent != progress) { m_sortingProgressPercent = progress; - emit directorySortingProgress(progress); + Q_EMIT directorySortingProgress(progress); } } }