X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/0d37038b407944a9b7ec05127b5b6d41dc1a496f..6072005ddce81b456fdcf2e77d5156a1d86f3686:/src/views/dolphinitemlistview.cpp diff --git a/src/views/dolphinitemlistview.cpp b/src/views/dolphinitemlistview.cpp index eb61ccb21..df28a0858 100644 --- a/src/views/dolphinitemlistview.cpp +++ b/src/views/dolphinitemlistview.cpp @@ -1,41 +1,23 @@ -/*************************************************************************** - * 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 "dolphinitemlistview.h" +#include "dolphin_compactmodesettings.h" +#include "dolphin_detailsmodesettings.h" #include "dolphin_generalsettings.h" #include "dolphin_iconsmodesettings.h" -#include "dolphin_detailsmodesettings.h" -#include "dolphin_compactmodesettings.h" #include "dolphinfileitemlistwidget.h" - -#include -#include -#include -#include - -#include - -#include - +#include "kitemviews/kfileitemmodel.h" +#include "kitemviews/kitemlistcontroller.h" +#include "views/viewmodecontroller.h" #include "zoomlevelinfo.h" +#include + DolphinItemListView::DolphinItemListView(QGraphicsWidget* parent) : KFileItemListView(parent), @@ -94,21 +76,17 @@ void DolphinItemListView::readSettings() updateFont(); updateGridSize(); - const KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings"); - const QStringList plugins = globalConfig.readEntry("Plugins", QStringList() - << "directorythumbnail" - << "imagethumbnail" - << "jpegthumbnail"); - setEnabledPlugins(plugins); - + const KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings"); + setEnabledPlugins(globalConfig.readEntry("Plugins", KIO::PreviewJob::defaultPlugins())); + setLocalFileSizePreviewLimit(globalConfig.readEntry("MaximumSize", 0)); endTransaction(); } void DolphinItemListView::writeSettings() { - IconsModeSettings::self()->writeConfig(); - CompactModeSettings::self()->writeConfig(); - DetailsModeSettings::self()->writeConfig(); + IconsModeSettings::self()->save(); + CompactModeSettings::self()->save(); + DetailsModeSettings::self()->save(); } KItemListWidgetCreatorBase* DolphinItemListView::defaultWidgetCreator() const @@ -133,7 +111,7 @@ void DolphinItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout pre void DolphinItemListView::onPreviewsShownChanged(bool shown) { - Q_UNUSED(shown); + Q_UNUSED(shown) updateGridSize(); } @@ -180,36 +158,23 @@ void DolphinItemListView::updateGridSize() // Calculate the item-width and item-height int itemWidth; int itemHeight; - QSize maxTextSize; + int maxTextLines = 0; + int maxTextWidth = 0; switch (itemLayout()) { case KFileItemListView::IconsLayout: { const int minItemWidth = 48; itemWidth = minItemWidth + IconsModeSettings::textWidthIndex() * 64; - if (previewsShown()) { - // Optimize the width for previews with a 3:2 aspect ratio instead - // of a 1:1 ratio to avoid wasting too much vertical space when - // showing photos. - const int minWidth = iconSize * 3 / 2; - itemWidth = qMax(itemWidth, minWidth); - } - if (itemWidth < iconSize + padding * 2) { itemWidth = iconSize + padding * 2; } itemHeight = padding * 3 + iconSize + option.fontMetrics.lineSpacing(); - if (IconsModeSettings::maximumTextLines() > 0) { - // A restriction is given for the maximum number of textlines (0 means - // having no restriction) - const int additionalInfoCount = visibleRoles().count() - 1; - const int maxAdditionalLines = additionalInfoCount + IconsModeSettings::maximumTextLines(); - maxTextSize.rheight() = option.fontMetrics.lineSpacing() * maxAdditionalLines; - } horizontalMargin = 4; verticalMargin = 8; + maxTextLines = IconsModeSettings::maximumTextLines(); break; } case KFileItemListView::CompactLayout: { @@ -220,8 +185,7 @@ void DolphinItemListView::updateGridSize() if (CompactModeSettings::maximumTextWidthIndex() > 0) { // A restriction is given for the maximum width of the text (0 means // having no restriction) - maxTextSize.rwidth() = option.fontMetrics.height() * 10 * - CompactModeSettings::maximumTextWidthIndex(); + maxTextWidth = option.fontMetrics.height() * 10 * CompactModeSettings::maximumTextWidthIndex(); } horizontalMargin = 8; @@ -244,7 +208,8 @@ void DolphinItemListView::updateGridSize() option.horizontalMargin = horizontalMargin; option.verticalMargin = verticalMargin; option.iconSize = iconSize; - option.maxTextSize = maxTextSize; + option.maxTextLines = maxTextLines; + option.maxTextWidth = maxTextWidth; beginTransaction(); setStyleOption(option); setItemSize(QSizeF(itemWidth, itemHeight)); @@ -267,4 +232,3 @@ ViewModeSettings::ViewMode DolphinItemListView::viewMode() const return mode; } -#include "dolphinitemlistview.moc"