1 | /* |
2 | This file is part of the KDE project |
3 | SPDX-FileCopyrightText: 2008 Rafael Fernández López <ereslibre@kde.org> |
4 | SPDX-FileCopyrightText: 2008 Kevin Ottens <ervin@kde.org> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-or-later |
7 | */ |
8 | |
9 | #ifndef KWIDGETITEMDELEGATEPOOL_P_H |
10 | #define KWIDGETITEMDELEGATEPOOL_P_H |
11 | |
12 | #include <QHash> |
13 | #include <QList> |
14 | #include <QPersistentModelIndex> |
15 | |
16 | class QWidget; |
17 | class QStyleOptionViewItem; |
18 | class KWidgetItemDelegate; |
19 | class KWidgetItemDelegatePoolPrivate; |
20 | |
21 | class KWidgetItemDelegatePool |
22 | { |
23 | public: |
24 | enum UpdateWidgetsEnum { |
25 | UpdateWidgets = 0, |
26 | NotUpdateWidgets, |
27 | }; |
28 | |
29 | KWidgetItemDelegatePool(KWidgetItemDelegate *delegate); |
30 | |
31 | ~KWidgetItemDelegatePool(); |
32 | |
33 | KWidgetItemDelegatePool(const KWidgetItemDelegatePool &) = delete; |
34 | KWidgetItemDelegatePool &operator=(const KWidgetItemDelegatePool &) = delete; |
35 | |
36 | /* |
37 | * Returns the widget associated to index and widget |
38 | * index The index to search into. |
39 | * option a QStyleOptionViewItem. |
40 | * Returns a QList of the pointers to the widgets found. |
41 | */ |
42 | QList<QWidget *> findWidgets(const QPersistentModelIndex &index, const QStyleOptionViewItem &option, UpdateWidgetsEnum updateWidgets = UpdateWidgets) const; |
43 | |
44 | QList<QWidget *> invalidIndexesWidgets() const; |
45 | |
46 | void fullClear(); |
47 | |
48 | private: |
49 | friend class KWidgetItemDelegate; |
50 | friend class KWidgetItemDelegatePrivate; |
51 | KWidgetItemDelegatePoolPrivate *const d; |
52 | }; |
53 | |
54 | class KWidgetItemDelegateEventListener; |
55 | |
56 | class KWidgetItemDelegatePoolPrivate |
57 | { |
58 | public: |
59 | KWidgetItemDelegatePoolPrivate(KWidgetItemDelegate *d); |
60 | |
61 | KWidgetItemDelegate *delegate; |
62 | KWidgetItemDelegateEventListener *eventListener; |
63 | |
64 | QHash<QPersistentModelIndex, QList<QWidget *>> usedWidgets; |
65 | QHash<QWidget *, QPersistentModelIndex> widgetInIndex; |
66 | |
67 | bool clearing = false; |
68 | }; |
69 | |
70 | #endif |
71 | |