2 * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #ifndef KFILEITEMLISTVIEW_H
8 #define KFILEITEMLISTVIEW_H
10 #include "dolphin_export.h"
11 #include "kitemviews/kstandarditemlistview.h"
15 class KFileItemModelRolesUpdater
;
19 * @brief View that allows to show the content of file-items.
21 * The corresponding model set by the controller must be an instance
22 * of KFileItemModel. Per default KFileItemListWidget is set as widget creator
23 * value and KItemListGroupHeader as group-header creator value. Use
24 * KItemListView::setWidgetCreator() and KItemListView::setGroupHeaderCreator()
25 * to apply customized generators.
27 class DOLPHIN_EXPORT KFileItemListView
: public KStandardItemListView
32 explicit KFileItemListView(QGraphicsWidget
* parent
= nullptr);
33 ~KFileItemListView() override
;
35 void setPreviewsShown(bool show
);
36 bool previewsShown() const;
39 * If enabled a small preview gets upscaled to the icon size in case where
40 * the icon size is larger than the preview. Per default enlarging is
43 void setEnlargeSmallPreviews(bool enlarge
);
44 bool enlargeSmallPreviews() const;
47 * Sets the list of enabled thumbnail plugins that are used for previews.
48 * Per default all plugins enabled in the KConfigGroup "PreviewSettings"
51 * For a list of available plugins, call KIO::PreviewJob::availableThumbnailerPlugins().
55 void setEnabledPlugins(const QStringList
& list
);
58 * Returns the list of enabled thumbnail plugins.
59 * @see setEnabledPlugins
61 QStringList
enabledPlugins() const;
64 * Sets the maximum file size of local files for which
65 * previews will be generated (if enabled). A value of 0
66 * indicates no file size limit.
67 * Per default the value from KConfigGroup "PreviewSettings"
68 * MaximumSize is used, 0 otherwise.
71 void setLocalFileSizePreviewLimit(qlonglong size
);
72 qlonglong
localFileSizePreviewLimit() const;
75 * If set to true, directories contents are scanned to determine their size
78 void setScanDirectories(bool enabled
);
79 bool scanDirectories();
81 QPixmap
createDragPixmap(const KItemSet
& indexes
) const override
;
84 * Notifies the view of a change in the hover state on an item.
86 * @param itemUrl URL of the item that is hovered, or an empty URL if no item is hovered.
87 * @param seqIdx The current hover sequence index. While an item is hovered,
88 * this method will be called repeatedly with increasing values
91 void setHoverSequenceState(const QUrl
& itemUrl
, int seqIdx
);
94 KItemListWidgetCreatorBase
* defaultWidgetCreator() const override
;
95 void initializeItemListWidget(KItemListWidget
* item
) override
;
96 virtual void onPreviewsShownChanged(bool shown
);
97 void onItemLayoutChanged(ItemLayout current
, ItemLayout previous
) override
;
98 void onModelChanged(KItemModelBase
* current
, KItemModelBase
* previous
) override
;
99 void onScrollOrientationChanged(Qt::Orientation current
, Qt::Orientation previous
) override
;
100 void onItemSizeChanged(const QSizeF
& current
, const QSizeF
& previous
) override
;
101 void onScrollOffsetChanged(qreal current
, qreal previous
) override
;
102 void onVisibleRolesChanged(const QList
<QByteArray
>& current
, const QList
<QByteArray
>& previous
) override
;
103 void onStyleOptionChanged(const KItemListStyleOption
& current
, const KItemListStyleOption
& previous
) override
;
104 void onSupportsItemExpandingChanged(bool supportsExpanding
) override
;
105 void onTransactionBegin() override
;
106 void onTransactionEnd() override
;
107 void resizeEvent(QGraphicsSceneResizeEvent
* event
) override
;
110 void slotItemsRemoved(const KItemRangeList
& itemRanges
) override
;
111 void slotSortRoleChanged(const QByteArray
& current
, const QByteArray
& previous
) override
;
114 void triggerVisibleIndexRangeUpdate();
115 void updateVisibleIndexRange();
117 void triggerIconSizeUpdate();
118 void updateIconSize();
122 * Applies the roles defined by KItemListView::visibleRoles() to the
123 * KFileItemModel and KFileItemModelRolesUpdater. As the model does not
124 * distinct between visible and invisible roles also internal roles
125 * are applied that are mandatory for having a working KFileItemModel.
127 void applyRolesToModel();
130 * @return Size that is available for the icons. The size might be larger than specified by
131 * KItemListStyleOption::iconSize: With the IconsLayout also the empty left area left
132 * and right of an icon will be included.
134 QSize
availableIconSize() const;
137 KFileItemModelRolesUpdater
* m_modelRolesUpdater
;
138 QTimer
* m_updateVisibleIndexRangeTimer
;
139 QTimer
* m_updateIconSizeTimer
;
140 bool m_scanDirectories
;
142 friend class KFileItemListViewTest
; // For unit testing