X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/362817d1834f2ada3ea4552a25fa39bbbb540f8c..87e8d0ba:/src/kitemviews/kfileitemlistview.h diff --git a/src/kitemviews/kfileitemlistview.h b/src/kitemviews/kfileitemlistview.h index a41d091b7..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,55 +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; + /** + * 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; - /** @reimp */ - virtual QHash visibleRolesSizes(const KItemRangeList& itemRanges) 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); - /** @reimp */ - virtual bool supportsItemExpanding() const; + /** + * Returns the list of enabled thumbnail plugins. + * @see setEnabledPlugins + */ + QStringList enabledPlugins() const; - /** @reimp */ - virtual QPixmap createDragPixmap(const QSet& indexes) 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); - virtual void slotSortRoleChanged(const QByteArray& current, const QByteArray& previous); + void slotItemsRemoved(const KItemRangeList& itemRanges) override; + void slotSortRoleChanged(const QByteArray& current, const QByteArray& previous) override; private slots: void triggerVisibleIndexRangeUpdate(); @@ -94,11 +102,6 @@ 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 @@ -107,16 +110,18 @@ private: */ void applyRolesToModel(); -private: - Layout m_itemLayout; + /** + * @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: 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 };