]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kfileitemlistview.cpp
Fix warnings about scaling pixmaps
[dolphin.git] / src / kitemviews / kfileitemlistview.cpp
index 80d85aa2e1e8e3e8cb809d19c940d158bb7b72d1..75eb1559e39abeaf3b8f093305a3a0cd519a3270 100644 (file)
@@ -1,21 +1,8 @@
-/***************************************************************************
- *   Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #include "kfileitemlistview.h"
 
@@ -116,6 +103,18 @@ QStringList KFileItemListView::enabledPlugins() const
     return m_modelRolesUpdater ? m_modelRolesUpdater->enabledPlugins() : QStringList();
 }
 
+void KFileItemListView::setLocalFileSizePreviewLimit(const qlonglong size)
+{
+    if (m_modelRolesUpdater) {
+        m_modelRolesUpdater->setLocalFileSizePreviewLimit(size);
+    }
+}
+
+qlonglong KFileItemListView::localFileSizePreviewLimit() const
+{
+    return m_modelRolesUpdater ? m_modelRolesUpdater->localFileSizePreviewLimit() : 0;
+}
+
 QPixmap KFileItemListView::createDragPixmap(const KItemSet& indexes) const
 {
     if (!model()) {
@@ -169,7 +168,12 @@ QPixmap KFileItemListView::createDragPixmap(const KItemSet& indexes) const
         QPixmap pixmap = model()->data(index).value("iconPixmap").value<QPixmap>();
         if (pixmap.isNull()) {
             QIcon icon = QIcon::fromTheme(model()->data(index).value("iconName").toString());
-            pixmap = icon.pixmap(size, size);
+            if (!icon.isNull()) {
+                pixmap = icon.pixmap(size, size);
+            } else {
+                pixmap = QPixmap(size, size);
+                pixmap.fill(Qt::transparent);
+            }
         } else {
             KPixmapModifier::scale(pixmap, QSize(size, size) * dpr);
         }
@@ -389,7 +393,8 @@ void KFileItemListView::applyRolesToModel()
 
     // KFileItemModel does not distinct between "visible" and "invisible" roles.
     // Add all roles that are mandatory for having a working KFileItemListView:
-    QSet<QByteArray> roles = visibleRoles().toSet();
+    const auto visibleRoles = this->visibleRoles();
+    auto roles = QSet<QByteArray>(visibleRoles.constBegin(), visibleRoles.constEnd());
     roles.insert("iconPixmap");
     roles.insert("iconName");
     roles.insert("text");