+ // PreviewJob internally caches items always with the size of
+ // 128 x 128 pixels or 256 x 256 pixels. A (slow) downscaling is done
+ // by PreviewJob if a smaller size is requested. For images KFileItemModelRolesUpdater must
+ // do a downscaling anyhow because of the frame, so in this case only the provided
+ // cache sizes are requested.
+ const QSize cacheSize = (m_iconSize.width() > 128) || (m_iconSize.height() > 128)
+ ? QSize(256, 256) : QSize(128, 128);
+
+ // KIO::filePreview() will request the MIME-type of all passed items, which (in the
+ // worst case) might block the application for several seconds. To prevent such
+ // a blocking, we only pass items with known mime type to the preview job.
+ const int count = m_pendingPreviewItems.count();
+ KFileItemList itemSubSet;
+ itemSubSet.reserve(count);
+
+ if (m_pendingPreviewItems.first().isMimeTypeKnown()) {
+ // Some mime types are known already, probably because they were
+ // determined when loading the icons for the visible items. Start
+ // a preview job for all items at the beginning of the list which
+ // have a known mime type.
+ do {
+ itemSubSet.append(m_pendingPreviewItems.takeFirst());
+ } while (!m_pendingPreviewItems.isEmpty() && m_pendingPreviewItems.first().isMimeTypeKnown());