File indexing completed on 2025-01-05 05:23:46
0001 /* 0002 This file is part of the Okteta Kasten Framework, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2022 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 STRUCTUREITEMDELEGATE_HPP 0010 #define STRUCTUREITEMDELEGATE_HPP 0011 0012 // KF 0013 #include <KWidgetItemDelegate> 0014 0015 class QCheckBox; 0016 class QPushButton; 0017 0018 class StructureItemDelegate : public KWidgetItemDelegate 0019 { 0020 Q_OBJECT 0021 0022 public: 0023 StructureItemDelegate(QAbstractItemView* itemView, QObject* parent); 0024 ~StructureItemDelegate() override; 0025 0026 public: 0027 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; 0028 QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; 0029 0030 protected: 0031 QList<QWidget*> createItemWidgets(const QModelIndex& index) const override; 0032 void updateItemWidgets(const QList<QWidget*> widgets, const QStyleOptionViewItem& option, const QPersistentModelIndex& index) const override; 0033 0034 private Q_SLOTS: 0035 void handleAboutClicked(); 0036 void handleCheckClicked(bool checked); 0037 0038 private: 0039 enum LayoutMode { 0040 LayoutForActualSize, ///< layout with rects for where objects are exeactly placed 0041 LayoutForSizeHint, ///< layout with sizes set to hinted ones, positions are ignored 0042 }; 0043 void layoutItem(const QStyleOptionViewItem& option, 0044 const QModelIndex& index, 0045 QRect* checkBoxRect, QRect* iconRect, QRect* textRect, QRect* aboutButtonRect, 0046 int* focusFrameHMarginToUpdate, 0047 LayoutMode layoutMode) const; 0048 0049 private: 0050 std::unique_ptr<QCheckBox> m_sampleCheckBox; 0051 std::unique_ptr<QPushButton> m_sampleAboutButton; 0052 }; 0053 0054 #endif