File indexing completed on 2025-01-05 04:59:46

0001 /*
0002  * SPDX-FileCopyrightText: 2014 Kevin Ottens <ervin@kde.org>
0003  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004  */
0005 
0006 
0007 
0008 #ifndef WIDGETS_ITEMDELEGATE_H
0009 #define WIDGETS_ITEMDELEGATE_H
0010 
0011 #include <QStyledItemDelegate>
0012 
0013 namespace Widgets {
0014 
0015 class ItemDelegate : public QStyledItemDelegate
0016 {
0017     Q_OBJECT
0018 public:
0019     explicit ItemDelegate(QObject *parent = nullptr);
0020 
0021     QSize sizeHint(const QStyleOptionViewItem &option,
0022                    const QModelIndex &index) const override;
0023     void paint(QPainter *painter,
0024                const QStyleOptionViewItem &option,
0025                const QModelIndex &index) const override;
0026 
0027     QWidget *createEditor(QWidget *parent,
0028                           const QStyleOptionViewItem &option,
0029                           const QModelIndex &index) const override;
0030     void setModelData(QWidget *editor,
0031                       QAbstractItemModel *model,
0032                       const QModelIndex &index) const override;
0033     void setEditorData(QWidget *editor, const QModelIndex &index) const override;
0034 
0035 private:
0036     enum class EditingState { NotEditing, JustCreatedEditor, Editing };
0037     mutable EditingState m_editingState = EditingState::NotEditing;
0038 };
0039 
0040 }
0041 
0042 #endif // WIDGETS_ITEMDELEGATE_H