File indexing completed on 2024-05-12 17:22:03
0001 /* 0002 SPDX-FileCopyrightText: 2009 Csaba Karai <cskarai@freemail.hu> 0003 SPDX-FileCopyrightText: 2009-2022 Krusader Krew <https://krusader.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef KRVIEWITEMDELEGATE_H 0009 #define KRVIEWITEMDELEGATE_H 0010 0011 // QtWidgets 0012 #include <QItemDelegate> 0013 0014 class KrViewItemDelegate : public QItemDelegate 0015 { 0016 public: 0017 explicit KrViewItemDelegate(QObject *parent = nullptr); 0018 0019 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0020 void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const override; 0021 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &sovi, const QModelIndex &index) const override; 0022 void setEditorData(QWidget *editor, const QModelIndex &index) const override; 0023 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0024 bool eventFilter(QObject *object, QEvent *event) override; 0025 0026 /// Set the next file name selection in the editor. 0027 void cycleEditorSelection(); 0028 0029 private: 0030 mutable int _currentlyEdited; 0031 mutable bool _dontDraw; 0032 mutable QWidget *_editor; 0033 0034 /// Init editor-related members when editor is closed. 0035 void onEditorClose() 0036 { 0037 _currentlyEdited = -1; 0038 _editor = nullptr; 0039 } 0040 }; 0041 0042 #endif