1 /***************************************************************************
2 * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #ifndef KFILEITEMLISTVIEW_H
21 #define KFILEITEMLISTVIEW_H
23 #include "dolphin_export.h"
24 #include "kitemviews/kstandarditemlistview.h"
26 class KFileItemModelRolesUpdater
;
30 * @brief View that allows to show the content of file-items.
32 * The corresponding model set by the controller must be an instance
33 * of KFileItemModel. Per default KFileItemListWidget is set as widget creator
34 * value and KItemListGroupHeader as group-header creator value. Use
35 * KItemListView::setWidgetCreator() and KItemListView::setGroupHeaderCreator()
36 * to apply customized generators.
38 class DOLPHIN_EXPORT KFileItemListView
: public KStandardItemListView
43 explicit KFileItemListView(QGraphicsWidget
* parent
= nullptr);
44 ~KFileItemListView() override
;
46 void setPreviewsShown(bool show
);
47 bool previewsShown() const;
50 * If enabled a small preview gets upscaled to the icon size in case where
51 * the icon size is larger than the preview. Per default enlarging is
54 void setEnlargeSmallPreviews(bool enlarge
);
55 bool enlargeSmallPreviews() const;
58 * Sets the list of enabled thumbnail plugins that are used for previews.
59 * Per default all plugins enabled in the KConfigGroup "PreviewSettings"
62 * For a list of available plugins, call KServiceTypeTrader::self()->query("ThumbCreator").
66 void setEnabledPlugins(const QStringList
& list
);
69 * Returns the list of enabled thumbnail plugins.
70 * @see setEnabledPlugins
72 QStringList
enabledPlugins() const;
75 * Sets the maximum file size of local files for which
76 * previews will be generated (if enabled). A value of 0
77 * indicates no file size limit.
78 * Per default the value from KConfigGroup "PreviewSettings"
79 * MaximumSize is used, 0 otherwise.
82 void setLocalFileSizePreviewLimit(qlonglong size
);
83 qlonglong
localFileSizePreviewLimit() const;
85 QPixmap
createDragPixmap(const KItemSet
& indexes
) const override
;
88 KItemListWidgetCreatorBase
* defaultWidgetCreator() const override
;
89 void initializeItemListWidget(KItemListWidget
* item
) override
;
90 virtual void onPreviewsShownChanged(bool shown
);
91 void onItemLayoutChanged(ItemLayout current
, ItemLayout previous
) override
;
92 void onModelChanged(KItemModelBase
* current
, KItemModelBase
* previous
) override
;
93 void onScrollOrientationChanged(Qt::Orientation current
, Qt::Orientation previous
) override
;
94 void onItemSizeChanged(const QSizeF
& current
, const QSizeF
& previous
) override
;
95 void onScrollOffsetChanged(qreal current
, qreal previous
) override
;
96 void onVisibleRolesChanged(const QList
<QByteArray
>& current
, const QList
<QByteArray
>& previous
) override
;
97 void onStyleOptionChanged(const KItemListStyleOption
& current
, const KItemListStyleOption
& previous
) override
;
98 void onSupportsItemExpandingChanged(bool supportsExpanding
) override
;
99 void onTransactionBegin() override
;
100 void onTransactionEnd() override
;
101 void resizeEvent(QGraphicsSceneResizeEvent
* event
) override
;
104 void slotItemsRemoved(const KItemRangeList
& itemRanges
) override
;
105 void slotSortRoleChanged(const QByteArray
& current
, const QByteArray
& previous
) override
;
108 void triggerVisibleIndexRangeUpdate();
109 void updateVisibleIndexRange();
111 void triggerIconSizeUpdate();
112 void updateIconSize();
116 * Applies the roles defined by KItemListView::visibleRoles() to the
117 * KFileItemModel and KFileItemModelRolesUpdater. As the model does not
118 * distinct between visible and invisible roles also internal roles
119 * are applied that are mandatory for having a working KFileItemModel.
121 void applyRolesToModel();
124 * @return Size that is available for the icons. The size might be larger than specified by
125 * KItemListStyleOption::iconSize: With the IconsLayout also the empty left area left
126 * and right of an icon will be included.
128 QSize
availableIconSize() const;
131 KFileItemModelRolesUpdater
* m_modelRolesUpdater
;
132 QTimer
* m_updateVisibleIndexRangeTimer
;
133 QTimer
* m_updateIconSizeTimer
;
135 friend class KFileItemListViewTest
; // For unit testing