Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:09:31

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