File indexing completed on 2024-05-19 04:27:45
0001 /* 0002 * SPDX-FileCopyrightText: 2023 Srirupa Datta <srirupa.sps@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 0008 #ifndef KISRESOURCEITEMLISTWIDGET_H 0009 #define KISRESOURCEITEMLISTWIDGET_H 0010 0011 #include <QWidget> 0012 #include <QListWidget> 0013 #include <QScopedPointer> 0014 0015 #include <KisKineticScroller.h> 0016 #include "kritaresourcewidgets_export.h" 0017 #include "ResourceListViewModes.h" 0018 0019 0020 class KRITARESOURCEWIDGETS_EXPORT KisResourceItemListWidget : public QListWidget 0021 { 0022 Q_OBJECT 0023 0024 public: 0025 KisResourceItemListWidget(QWidget *parent = nullptr); 0026 ~KisResourceItemListWidget() override; 0027 0028 void setListViewMode(ListViewMode layout); 0029 0030 /** 0031 * @brief setItemSize 0032 * convenience function which sets both the icon and the grid size 0033 * to the same value. 0034 * @param size - the size you wish either to be. 0035 */ 0036 void setItemSize(QSize size); 0037 0038 /** 0039 * @brief setStrictSelectionMode sets additional restrictions on the selection. 0040 * 0041 * When in QAbstractItemView::SingleSelection mode, this ensures that the 0042 * selection never gets transfered to another item. Instead, the selection 0043 * is cleared if the current item gets removed (filtered) from the model. 0044 * Furthermore, it prevents users from deselecting the current item with Ctrl+click. 0045 * This behavior is important for resource selectors. 0046 * @param enable Determines if strict mode is enabled. 0047 */ 0048 void setStrictSelectionMode(bool enable); 0049 0050 void setFixedToolTipThumbnailSize(const QSize &size); 0051 void setToolTipShouldRenderCheckers(bool value); 0052 0053 public Q_SLOTS: 0054 void slotScrollerStateChange(QScroller::State state){ KisKineticScroller::updateCursor(this, state); } 0055 0056 Q_SIGNALS: 0057 0058 void sigSizeChanged(); 0059 0060 void currentResourceChanged(const QModelIndex &); 0061 void currentResourceClicked(const QModelIndex &); 0062 0063 void contextMenuRequested(const QPoint &); 0064 0065 protected Q_SLOTS: 0066 void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override; 0067 void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override; 0068 0069 protected: 0070 QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index, const QEvent *event = nullptr) const override; 0071 void contextMenuEvent(QContextMenuEvent *event) override; 0072 0073 bool viewportEvent(QEvent *event) override; 0074 0075 private: 0076 void resizeEvent(QResizeEvent *event) override; 0077 0078 private: 0079 struct Private; 0080 const QScopedPointer<Private> m_d; 0081 }; 0082 0083 #endif // KISRESOURCEITEMLISTWIDGET_H 0084