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;
74 QPixmap
createDragPixmap(const KItemSet
&indexes
) const override
;
77 * Notifies the view of a change in the hover state on an item.
79 * @param itemUrl URL of the item that is hovered, or an empty URL if no item is hovered.
80 * @param seqIdx The current hover sequence index. While an item is hovered,
81 * this method will be called repeatedly with increasing values
84 void setHoverSequenceState(const QUrl
&itemUrl
, int seqIdx
);
87 KItemListWidgetCreatorBase
*defaultWidgetCreator() const override
;
88 void initializeItemListWidget(KItemListWidget
*item
) override
;
89 virtual void onPreviewsShownChanged(bool shown
);
90 void onItemLayoutChanged(ItemLayout current
, ItemLayout previous
) override
;
91 void onModelChanged(KItemModelBase
*current
, KItemModelBase
*previous
) override
;
92 void onScrollOrientationChanged(Qt::Orientation current
, Qt::Orientation previous
) override
;
93 void onItemSizeChanged(const QSizeF
¤t
, const QSizeF
&previous
) override
;
94 void onScrollOffsetChanged(qreal current
, qreal previous
) override
;
95 void onVisibleRolesChanged(const QList
<QByteArray
> ¤t
, const QList
<QByteArray
> &previous
) override
;
96 void onStyleOptionChanged(const KItemListStyleOption
¤t
, const KItemListStyleOption
&previous
) override
;
97 void onSupportsItemExpandingChanged(bool supportsExpanding
) override
;
98 void onTransactionBegin() override
;
99 void onTransactionEnd() override
;
100 void resizeEvent(QGraphicsSceneResizeEvent
*event
) override
;
101 void focusInEvent(QFocusEvent
*event
) override
;
102 void focusOutEvent(QFocusEvent
*event
) override
;
105 void slotItemsRemoved(const KItemRangeList
&itemRanges
) override
;
106 void slotSortRoleChanged(const QByteArray
¤t
, const QByteArray
&previous
) override
;
109 void triggerVisibleIndexRangeUpdate();
110 void updateVisibleIndexRange();
112 void triggerIconSizeUpdate();
113 void updateIconSize();
117 * Applies the roles defined by KItemListView::visibleRoles() to the
118 * KFileItemModel and KFileItemModelRolesUpdater. As the model does not
119 * distinct between visible and invisible roles also internal roles
120 * are applied that are mandatory for having a working KFileItemModel.
122 void applyRolesToModel();
125 * @return Size that is available for the icons. The size might be larger than specified by
126 * KItemListStyleOption::iconSize: With the IconsLayout also the empty left area left
127 * and right of an icon will be included.
129 QSize
availableIconSize() const;
132 void updateSelectedWidgets();
134 KFileItemModelRolesUpdater
*m_modelRolesUpdater
;
135 QTimer
*m_updateVisibleIndexRangeTimer
;
136 QTimer
*m_updateIconSizeTimer
;
138 friend class KFileItemListViewTest
; // For unit testing
139 friend class DolphinMainWindowTest
; // For unit testing