]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kfileitemmodelrolesupdater.cpp
Don't use nullptr/0 as flags (deprecated in qt5.15)
[dolphin.git] / src / kitemviews / kfileitemmodelrolesupdater.cpp
index 544d88040c8a52246b306b5e9487ee922add2362..bf2c84c4031ffa6346dc2e5813d6c7a0ea7b1007 100644 (file)
@@ -355,7 +355,7 @@ void KFileItemModelRolesUpdater::slotItemsInserted(const KItemRangeList& itemRan
 
 void KFileItemModelRolesUpdater::slotItemsRemoved(const KItemRangeList& itemRanges)
 {
-    Q_UNUSED(itemRanges);
+    Q_UNUSED(itemRanges)
 
     const bool allItemsRemoved = (m_model->count() == 0);
 
@@ -405,10 +405,10 @@ void KFileItemModelRolesUpdater::slotItemsRemoved(const KItemRangeList& itemRang
     }
 }
 
-void KFileItemModelRolesUpdater::slotItemsMoved(const KItemRange& itemRange, QList<int> movedToIndexes)
+void KFileItemModelRolesUpdater::slotItemsMoved(const KItemRange& itemRange, const QList<int> &movedToIndexes)
 {
-    Q_UNUSED(itemRange);
-    Q_UNUSED(movedToIndexes);
+    Q_UNUSED(itemRange)
+    Q_UNUSED(movedToIndexes)
 
     // The visible items might have changed.
     startUpdating();
@@ -417,7 +417,7 @@ void KFileItemModelRolesUpdater::slotItemsMoved(const KItemRange& itemRange, QLi
 void KFileItemModelRolesUpdater::slotItemsChanged(const KItemRangeList& itemRanges,
                                                   const QSet<QByteArray>& roles)
 {
-    Q_UNUSED(roles);
+    Q_UNUSED(roles)
 
     // Find out if slotItemsChanged() has been done recently. If that is the
     // case, resolving the roles is postponed until a timer has exceeded
@@ -445,8 +445,8 @@ void KFileItemModelRolesUpdater::slotItemsChanged(const KItemRangeList& itemRang
 void KFileItemModelRolesUpdater::slotSortRoleChanged(const QByteArray& current,
                                                      const QByteArray& previous)
 {
-    Q_UNUSED(current);
-    Q_UNUSED(previous);
+    Q_UNUSED(current)
+    Q_UNUSED(previous)
 
     if (m_resolvableRoles.contains(current)) {
         m_pendingSortRoleItems.clear();
@@ -495,14 +495,9 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
 
     QPixmap scaledPixmap = pixmap;
 
-    const QString mimeType = item.mimetype();
-    const int slashIndex = mimeType.indexOf(QLatin1Char('/'));
-    const bool isFontPreview = mimeType.rightRef(slashIndex).contains(QLatin1String("font"));
-    const bool isFolderPreview = item.isDir();
-    const bool isWindowsExePreview = mimeType == QLatin1String("application/x-ms-dos-executable") ||
-                                     mimeType == QLatin1String("application/x-msdownload");
-
-    if (!isFolderPreview && !isFontPreview && !isWindowsExePreview) {
+    if (!pixmap.hasAlpha()
+        && m_iconSize.width()  > KIconLoader::SizeSmallMedium
+        && m_iconSize.height() > KIconLoader::SizeSmallMedium) {
         if (m_enlargeSmallPreviews) {
             KPixmapModifier::applyFrame(scaledPixmap, m_iconSize);
         } else {
@@ -526,13 +521,14 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
                                    scaledPixmap);
                 scaledPixmap = largeFrame;
             } else {
-                // The image must be shrinked as it is too large to fit into
+                // The image must be shrunk as it is too large to fit into
                 // the available icon size
                 KPixmapModifier::applyFrame(scaledPixmap, m_iconSize);
             }
         }
     } else {
-        KPixmapModifier::scale(scaledPixmap, m_iconSize);
+        KPixmapModifier::scale(scaledPixmap, m_iconSize * qApp->devicePixelRatio());
+        scaledPixmap.setDevicePixelRatio(qApp->devicePixelRatio());
     }
 
     QHash<QByteArray, QVariant> data = rolesData(item);
@@ -714,6 +710,8 @@ void KFileItemModelRolesUpdater::applyChangedBalooRoles(const QString& file)
         return;
     }
     applyChangedBalooRolesForItem(item);
+#else
+    Q_UNUSED(file)
 #endif
 }
 
@@ -747,7 +745,7 @@ void KFileItemModelRolesUpdater::applyChangedBalooRolesForItem(const KFileItem &
             this,    &KFileItemModelRolesUpdater::slotItemsChanged);
 #else
 #ifndef Q_CC_MSVC
-    Q_UNUSED(item);
+    Q_UNUSED(item)
 #endif
 #endif
 }
@@ -1152,7 +1150,7 @@ QList<int> KFileItemModelRolesUpdater::indexesToResolve() const
 
     // We need a reasonable upper limit for number of items to resolve after
     // and before the visible range. m_maximumVisibleItems can be quite large
-    // when using Compace View.
+    // when using Compact View.
     const int readAheadItems = qMin(ReadAheadPages * m_maximumVisibleItems, ResolveAllItemsLimit / 2);
 
     // Add items after the visible range.