X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/5f57256a2f293622c7a10844adae29190907b9eb..891ebf5758cd3569974c87f3c25f0546fe2613be:/src/kitemviews/kfileitemlistview.cpp diff --git a/src/kitemviews/kfileitemlistview.cpp b/src/kitemviews/kfileitemlistview.cpp index 41f8aeade..75eb1559e 100644 --- a/src/kitemviews/kfileitemlistview.cpp +++ b/src/kitemviews/kfileitemlistview.cpp @@ -1,42 +1,28 @@ -/*************************************************************************** - * Copyright (C) 2011 by Peter Penz * - * * - * 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 + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ #include "kfileitemlistview.h" -#include "kfileitemmodelrolesupdater.h" #include "kfileitemlistwidget.h" #include "kfileitemmodel.h" +#include "kfileitemmodelrolesupdater.h" #include "private/kpixmapmodifier.h" -#include #include -#include -#include #include #include +#include +#include // #define KFILEITEMLISTVIEW_DEBUG namespace { // If the visible index range changes, KFileItemModelRolesUpdater is not - // informed immediatetly, but with a short delay. This ensures that scrolling + // informed immediately, but with a short delay. This ensures that scrolling // always feels smooth and is not interrupted by icon loading (which can be // quite expensive if a disk access is required to determine the final icon). const int ShortInterval = 50; @@ -117,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()) { @@ -170,7 +168,12 @@ QPixmap KFileItemListView::createDragPixmap(const KItemSet& indexes) const QPixmap pixmap = model()->data(index).value("iconPixmap").value(); 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); } @@ -214,7 +217,7 @@ void KFileItemListView::initializeItemListWidget(KItemListWidget* item) void KFileItemListView::onPreviewsShownChanged(bool shown) { - Q_UNUSED(shown); + Q_UNUSED(shown) } void KFileItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous) @@ -247,8 +250,8 @@ void KFileItemListView::onScrollOrientationChanged(Qt::Orientation current, Qt:: void KFileItemListView::onItemSizeChanged(const QSizeF& current, const QSizeF& previous) { - Q_UNUSED(current); - Q_UNUSED(previous); + Q_UNUSED(current) + Q_UNUSED(previous) triggerVisibleIndexRangeUpdate(); } @@ -390,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 roles = visibleRoles().toSet(); + const auto visibleRoles = this->visibleRoles(); + auto roles = QSet(visibleRoles.constBegin(), visibleRoles.constEnd()); roles.insert("iconPixmap"); roles.insert("iconName"); roles.insert("text");