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
16class QWidget;
17class QStyleOptionViewItem;
18class KWidgetItemDelegate;
19class KWidgetItemDelegatePoolPrivate;
20
21/**
22 * @internal
23 */
24class KWidgetItemDelegatePool
25{
26public:
27 enum UpdateWidgetsEnum {
28 UpdateWidgets = 0,
29 NotUpdateWidgets,
30 };
31
32 /**
33 * Creates a new ItemDelegatePool.
34 *
35 * @param delegate the ItemDelegate for this pool.
36 */
37
38 KWidgetItemDelegatePool(KWidgetItemDelegate *delegate);
39
40 /**
41 * Destroys an ItemDelegatePool.
42 */
43 ~KWidgetItemDelegatePool();
44
45 KWidgetItemDelegatePool(const KWidgetItemDelegatePool &) = delete;
46 KWidgetItemDelegatePool &operator=(const KWidgetItemDelegatePool &) = delete;
47
48 /**
49 * @brief Returns the widget associated to @p index and @p widget
50 * @param index The index to search into.
51 * @param option a QStyleOptionViewItem.
52 * @return A QList of the pointers to the widgets found.
53 * @internal
54 */
55 QList<QWidget *> findWidgets(const QPersistentModelIndex &index, const QStyleOptionViewItem &option, UpdateWidgetsEnum updateWidgets = UpdateWidgets) const;
56
57 /**
58 * @internal
59 */
60 QList<QWidget *> invalidIndexesWidgets() const;
61
62 /**
63 * @internal
64 */
65 void fullClear();
66
67private:
68 friend class KWidgetItemDelegate;
69 friend class KWidgetItemDelegatePrivate;
70 KWidgetItemDelegatePoolPrivate *const d;
71};
72
73class KWidgetItemDelegateEventListener;
74
75/**
76 * @internal
77 */
78class KWidgetItemDelegatePoolPrivate
79{
80public:
81 KWidgetItemDelegatePoolPrivate(KWidgetItemDelegate *d);
82
83 KWidgetItemDelegate *delegate;
84 KWidgetItemDelegateEventListener *eventListener;
85
86 QList<QList<QWidget *>> allocatedWidgets;
87 QHash<QPersistentModelIndex, QList<QWidget *>> usedWidgets;
88 QHash<QWidget *, QPersistentModelIndex> widgetInIndex;
89
90 bool clearing = false;
91};
92
93#endif
94

source code of kitemviews/src/kwidgetitemdelegatepool_p.h