File indexing completed on 2024-06-16 05:24:55

0001 /*
0002     This file is part of the Okteta Kasten module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #ifndef KASTEN_PODDELEGATE_HPP
0010 #define KASTEN_PODDELEGATE_HPP
0011 
0012 // Qt
0013 #include <QStyledItemDelegate>
0014 #include <QPointer>
0015 
0016 namespace Kasten {
0017 class PODDecoderTool;
0018 
0019 class PODDelegate : public QStyledItemDelegate
0020 {
0021     Q_OBJECT
0022 
0023 public:
0024     explicit PODDelegate(PODDecoderTool* tool, QObject* parent = nullptr);
0025 
0026     ~PODDelegate() override;
0027 
0028 public: // QAbstractItemDelegate
0029 //     virtual void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
0030 //     virtual QSize sizeHint( const QStyleOptionViewItem &option, const QModelIndex& index ) const;
0031 //     virtual void updateEditorGeometry( QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
0032 
0033     QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
0034 
0035     void setEditorData(QWidget* editor, const QModelIndex& index) const override;
0036     void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
0037 
0038 private Q_SLOTS:
0039     void onEditorDone();
0040     void onReadOnlyChanged(bool isReadOnly) const;
0041 
0042 private:
0043     PODDecoderTool* mTool;
0044 
0045     mutable QPointer<QWidget> mEditor = nullptr;
0046 };
0047 
0048 }
0049 
0050 #endif