File indexing completed on 2024-05-05 05:40:57

0001 #ifndef FILEPATHDELEGATEITEM_H
0002 #define FILEPATHDELEGATEITEM_H
0003 
0004 #include "rwidgets_global.h"
0005 #include <QLabel>
0006 #include <QPushButton>
0007 #include <QStyledItemDelegate>
0008 namespace rwidgets
0009 {
0010 /**
0011  * @brief The FilePathDelegateItem class displays path for image in the treeview
0012  */
0013 class RWIDGET_EXPORT ImagePathDelegateItem : public QStyledItemDelegate
0014 {
0015     Q_OBJECT
0016 public:
0017     explicit ImagePathDelegateItem(const QString& root, QObject* parent= nullptr);
0018 
0019     virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
0020     void setEditorData(QWidget* editor, const QModelIndex& index) const;
0021     void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const;
0022     void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
0023     void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
0024     QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
0025 
0026 private:
0027     QPixmap m_pix;
0028     QString m_root;
0029 };
0030 } // namespace rwidgets
0031 #endif // FILEPATHDELEGATEITEM_H