digiKam
dwitemdelegate.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2007-11-15
7  * Description : widget item delegate for setup collection view
8  *
9  * Copyright (C) 2015-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2007-2008 by Rafael Fernández López <ereslibre at kde dot org>
11  * Copyright (C) 2008 by Kevin Ottens <ervin at kde dot org>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_DW_ITEM_DELEGATE_H
27 #define DIGIKAM_DW_ITEM_DELEGATE_H
28 
29 // Qt includes
30 
31 #include <QEvent>
32 #include <QList>
33 #include <QPersistentModelIndex>
34 #include <QAbstractItemDelegate>
35 
36 // Local includes
37 
38 #include "dwitemdelegate_p.h"
39 #include "digikam_export.h"
40 
41 class QObject;
42 class QPainter;
43 class QStyleOption;
44 class QStyleOptionViewItem;
45 class QAbstractItemView;
46 class QItemSelection;
47 
48 namespace Digikam
49 {
50 
51 class DWItemDelegatePool;
52 class DWItemDelegatePrivate;
53 
59 class DIGIKAM_GUI_EXPORT DWItemDelegate : public QAbstractItemDelegate
60 {
61  Q_OBJECT
62 
63 public:
64 
71  explicit DWItemDelegate(QAbstractItemView* const itemView, QObject* const parent = nullptr);
72  ~DWItemDelegate() override;
73 
79  QAbstractItemView* itemView() const;
80 
86  QPersistentModelIndex focusedIndex() const;
87 
88 protected:
89 
109  virtual QList<QWidget*> createItemWidgets(const QModelIndex& index) const = 0;
110 
124  virtual void updateItemWidgets(const QList<QWidget*>& widgets,
125  const QStyleOptionViewItem& option,
126  const QPersistentModelIndex& index) const = 0;
127 
137  void setBlockedEventTypes(QWidget* const widget, const QList<QEvent::Type>& types) const;
138 
146  QList<QEvent::Type> blockedEventTypes(QWidget* const widget) const;
147 
148 private:
149 
150  friend class DWItemDelegatePool;
151  friend class DWItemDelegateEventListener;
152 
153  DWItemDelegatePrivate* const d;
154 
155  Q_PRIVATE_SLOT(d, void slotDWRowsInserted(const QModelIndex&, int, int))
156  Q_PRIVATE_SLOT(d, void slotDWRowsAboutToBeRemoved(const QModelIndex&, int, int))
157  Q_PRIVATE_SLOT(d, void slotDWRowsRemoved(const QModelIndex&, int, int))
158  Q_PRIVATE_SLOT(d, void slotDWDataChanged(const QModelIndex&, const QModelIndex&))
159  Q_PRIVATE_SLOT(d, void slotDWLayoutChanged())
160  Q_PRIVATE_SLOT(d, void slotDWModelReset())
161  Q_PRIVATE_SLOT(d, void slotDWSelectionChanged(const QItemSelection&, const QItemSelection&))
162 };
163 
164 } // namespace Digikam
165 
166 Q_DECLARE_METATYPE(QList<QEvent::Type>)
167 
168 #endif // DIGIKAM_DW_ITEM_DELEGATE_H
Definition: dwitemdelegatepool.h:49
Definition: dwitemdelegate_p.h:43
Definition: dwitemdelegate.h:60
virtual void updateItemWidgets(const QList< QWidget * > &widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const =0
virtual QList< QWidget * > createItemWidgets(const QModelIndex &index) const =0
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43
Type
Definition: gpsitemcontainer.h:45