Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-24 09:22:11

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 // Qt-Security score:significant reason:default
0004 
0005 #ifndef QABSTRACTITEMDELEGATE_H
0006 #define QABSTRACTITEMDELEGATE_H
0007 
0008 #include <QtWidgets/qtwidgetsglobal.h>
0009 #include <QtCore/qobject.h>
0010 #include <QtWidgets/qstyleoption.h>
0011 
0012 QT_REQUIRE_CONFIG(itemviews);
0013 
0014 QT_BEGIN_NAMESPACE
0015 
0016 class QPainter;
0017 class QModelIndex;
0018 class QAbstractItemModel;
0019 class QAbstractItemView;
0020 class QHelpEvent;
0021 class QAbstractItemDelegatePrivate;
0022 
0023 class Q_WIDGETS_EXPORT QAbstractItemDelegate : public QObject
0024 {
0025     Q_OBJECT
0026 
0027 public:
0028 
0029     enum EndEditHint {
0030         NoHint,
0031         EditNextItem,
0032         EditPreviousItem,
0033         SubmitModelCache,
0034         RevertModelCache
0035     };
0036 
0037     explicit QAbstractItemDelegate(QObject *parent = nullptr);
0038     virtual ~QAbstractItemDelegate();
0039 
0040     // painting
0041     virtual void paint(QPainter *painter,
0042                        const QStyleOptionViewItem &option,
0043                        const QModelIndex &index) const = 0;
0044 
0045     virtual QSize sizeHint(const QStyleOptionViewItem &option,
0046                            const QModelIndex &index) const = 0;
0047 
0048     // editing
0049     virtual QWidget *createEditor(QWidget *parent,
0050                                   const QStyleOptionViewItem &option,
0051                                   const QModelIndex &index) const;
0052 
0053     virtual void destroyEditor(QWidget *editor, const QModelIndex &index) const;
0054 
0055     virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
0056 
0057     virtual void setModelData(QWidget *editor,
0058                               QAbstractItemModel *model,
0059                               const QModelIndex &index) const;
0060 
0061     virtual void updateEditorGeometry(QWidget *editor,
0062                                       const QStyleOptionViewItem &option,
0063                                       const QModelIndex &index) const;
0064 
0065     // for non-widget editors
0066     virtual bool editorEvent(QEvent *event,
0067                              QAbstractItemModel *model,
0068                              const QStyleOptionViewItem &option,
0069                              const QModelIndex &index);
0070     // for widget editors
0071     bool handleEditorEvent(QObject *object, QEvent *event);
0072 
0073     virtual bool helpEvent(QHelpEvent *event,
0074                            QAbstractItemView *view,
0075                            const QStyleOptionViewItem &option,
0076                            const QModelIndex &index);
0077 
0078     virtual QList<int> paintingRoles() const;
0079 
0080 Q_SIGNALS:
0081     void commitData(QWidget *editor);
0082     void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint = NoHint);
0083     void sizeHintChanged(const QModelIndex &);
0084 
0085 protected:
0086     QAbstractItemDelegate(QObjectPrivate &, QObject *parent = nullptr);
0087 
0088 private:
0089     Q_DECLARE_PRIVATE(QAbstractItemDelegate)
0090     Q_DISABLE_COPY(QAbstractItemDelegate)
0091     Q_PRIVATE_SLOT(d_func(), void _q_commitDataAndCloseEditor(QWidget*))
0092 };
0093 
0094 QT_END_NAMESPACE
0095 
0096 #endif // QABSTRACTITEMDELEGATE_H