File indexing completed on 2024-05-12 17:18:47
0001 /* 0002 * SPDX-FileCopyrightText: 2012 Peter Penz <peter.penz19@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KSTANDARDITEMLISTVIEW_H 0008 #define KSTANDARDITEMLISTVIEW_H 0009 0010 #include "dolphin_export.h" 0011 #include "kitemviews/kitemlistview.h" 0012 0013 /** 0014 * @brief Provides layouts for icons-, compact- and details-view. 0015 * 0016 * Together with the KStandardItemModel lists for standard usecases 0017 * can be created in a straight forward way. 0018 * 0019 * Example code: 0020 * <code> 0021 * KStandardItemListView* view = new KStandardItemListView(); 0022 * KStandardItemModel* model = new KStandardItemModel(); 0023 * model->appendItem(new KStandardItem("Item 1")); 0024 * model->appendItem(new KStandardItem("Item 2")); 0025 * KItemListController* controller = new KItemListController(model, view); 0026 * KItemListContainer* container = new KItemListContainer(controller, parentWidget); 0027 * </code> 0028 */ 0029 class DOLPHIN_EXPORT KStandardItemListView : public KItemListView 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 enum ItemLayout { IconsLayout, CompactLayout, DetailsLayout }; 0035 0036 explicit KStandardItemListView(QGraphicsWidget *parent = nullptr); 0037 ~KStandardItemListView() override; 0038 0039 void setItemLayout(ItemLayout layout); 0040 ItemLayout itemLayout() const; 0041 0042 protected: 0043 KItemListWidgetCreatorBase *defaultWidgetCreator() const override; 0044 KItemListGroupHeaderCreatorBase *defaultGroupHeaderCreator() const override; 0045 void initializeItemListWidget(KItemListWidget *item) override; 0046 bool itemSizeHintUpdateRequired(const QSet<QByteArray> &changedRoles) const override; 0047 virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const; 0048 /** To be overriden by sub-classes to specify when full row highlighting should be enabled. */ 0049 virtual bool itemLayoutHighlightEntireRow(ItemLayout layout) const; 0050 virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous); 0051 void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous) override; 0052 void onSupportsItemExpandingChanged(bool supportsExpanding) override; 0053 void polishEvent() override; 0054 0055 private: 0056 void applyDefaultStyleOption(int iconSize, int padding, int horizontalMargin, int verticalMargin); 0057 void updateLayoutOfVisibleItems(); 0058 0059 private: 0060 ItemLayout m_itemLayout; 0061 }; 0062 0063 #endif