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