X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/ec38f1cdb641f0b277100edd92b268ec856e2ece..87e8d0ba:/src/kitemviews/kfileitemlistview.h diff --git a/src/kitemviews/kfileitemlistview.h b/src/kitemviews/kfileitemlistview.h index 125c86142..c7fdf972d 100644 --- a/src/kitemviews/kfileitemlistview.h +++ b/src/kitemviews/kfileitemlistview.h @@ -20,9 +20,9 @@ #ifndef KFILEITEMLISTVIEW_H #define KFILEITEMLISTVIEW_H -#include +#include "dolphin_export.h" -#include +#include class KFileItemModelRolesUpdater; class QTimer; @@ -36,51 +36,63 @@ class QTimer; * KItemListView::setWidgetCreator() and KItemListView::setGroupHeaderCreator() * to apply customized generators. */ -class LIBDOLPHINPRIVATE_EXPORT KFileItemListView : public KItemListView +class DOLPHIN_EXPORT KFileItemListView : public KStandardItemListView { Q_OBJECT public: - enum Layout - { - IconsLayout, - CompactLayout, - DetailsLayout - }; - - KFileItemListView(QGraphicsWidget* parent = 0); - virtual ~KFileItemListView(); + explicit KFileItemListView(QGraphicsWidget* parent = nullptr); + ~KFileItemListView() override; void setPreviewsShown(bool show); bool previewsShown() const; - void setItemLayout(Layout layout); - Layout itemLayout() const; - - /** @reimp */ - virtual QSizeF itemSizeHint(int index) const; - - /** @reimp */ - virtual QHash visibleRolesSizes(const KItemRangeList& itemRanges) const; - - /** @reimp */ - virtual QPixmap createDragPixmap(const QSet& indexes) const; + /** + * If enabled a small preview gets upscaled to the icon size in case where + * the icon size is larger than the preview. Per default enlarging is + * enabled. + */ + void setEnlargeSmallPreviews(bool enlarge); + bool enlargeSmallPreviews() const; + + /** + * Sets the list of enabled thumbnail plugins that are used for previews. + * Per default all plugins enabled in the KConfigGroup "PreviewSettings" + * are used. + * + * For a list of available plugins, call KServiceTypeTrader::self()->query("ThumbCreator"). + * + * @see enabledPlugins + */ + void setEnabledPlugins(const QStringList& list); + + /** + * Returns the list of enabled thumbnail plugins. + * @see setEnabledPlugins + */ + QStringList enabledPlugins() const; + + QPixmap createDragPixmap(const KItemSet& indexes) const override; protected: - virtual void initializeItemListWidget(KItemListWidget* item); - virtual bool itemSizeHintUpdateRequired(const QSet& changedRoles) const; - virtual void onModelChanged(KItemModelBase* current, KItemModelBase* previous); - virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous); - virtual void onItemSizeChanged(const QSizeF& current, const QSizeF& previous); - virtual void onScrollOffsetChanged(qreal current, qreal previous); - virtual void onVisibleRolesChanged(const QList& current, const QList& previous); - virtual void onStyleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous); - virtual void onTransactionBegin(); - virtual void onTransactionEnd(); - virtual void resizeEvent(QGraphicsSceneResizeEvent* event); + KItemListWidgetCreatorBase* defaultWidgetCreator() const override; + void initializeItemListWidget(KItemListWidget* item) override; + virtual void onPreviewsShownChanged(bool shown); + void onItemLayoutChanged(ItemLayout current, ItemLayout previous) override; + void onModelChanged(KItemModelBase* current, KItemModelBase* previous) override; + void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous) override; + void onItemSizeChanged(const QSizeF& current, const QSizeF& previous) override; + void onScrollOffsetChanged(qreal current, qreal previous) override; + void onVisibleRolesChanged(const QList& current, const QList& previous) override; + void onStyleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous) override; + void onSupportsItemExpandingChanged(bool supportsExpanding) override; + void onTransactionBegin() override; + void onTransactionEnd() override; + void resizeEvent(QGraphicsSceneResizeEvent* event) override; protected slots: - virtual void slotItemsRemoved(const KItemRangeList& itemRanges); + void slotItemsRemoved(const KItemRangeList& itemRanges) override; + void slotSortRoleChanged(const QByteArray& current, const QByteArray& previous) override; private slots: void triggerVisibleIndexRangeUpdate(); @@ -90,21 +102,26 @@ private slots: void updateIconSize(); private: - QSizeF visibleRoleSizeHint(int index, const QByteArray& role) const; - void updateLayoutOfVisibleItems(); - void updateTimersInterval(); - void updateMinimumRolesWidths(); + /** + * Applies the roles defined by KItemListView::visibleRoles() to the + * KFileItemModel and KFileItemModelRolesUpdater. As the model does not + * distinct between visible and invisible roles also internal roles + * are applied that are mandatory for having a working KFileItemModel. + */ + void applyRolesToModel(); + + /** + * @return Size that is available for the icons. The size might be larger than specified by + * KItemListStyleOption::iconSize: With the IconsLayout also the empty left area left + * and right of an icon will be included. + */ + QSize availableIconSize() const; private: - Layout m_itemLayout; - KFileItemModelRolesUpdater* m_modelRolesUpdater; QTimer* m_updateVisibleIndexRangeTimer; QTimer* m_updateIconSizeTimer; - // Cache for calculating visibleRoleSizes() in a fast way - QHash m_minimumRolesWidths; - friend class KFileItemListViewTest; // For unit testing };