61 lines
2.2 KiB
C++
61 lines
2.2 KiB
C++
/***************************************************************************
|
|
|
|
source::worx xtree
|
|
Copyright © 2024-2025 c.holzheuer
|
|
christoph.holzheuer@gmail.com
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
#ifndef XQITEMDELEGATE_H
|
|
#define XQITEMDELEGATE_H
|
|
|
|
#include <QStyledItemDelegate>
|
|
#include <xqappdata.h>
|
|
|
|
class XQItem;
|
|
class XQTreeView;
|
|
class XQModel;
|
|
|
|
/**
|
|
* @brief A specialized QItemDelegate class to draw different XQItem styles.
|
|
*/
|
|
|
|
class XQItemDelegate : public QStyledItemDelegate
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit XQItemDelegate(XQModel& modelView);
|
|
|
|
XQTreeView* treeView() const;
|
|
XQItem& xqItemFromIndex( const QModelIndex& index ) const;
|
|
|
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
|
QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
|
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
|
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
|
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
|
|
|
protected:
|
|
|
|
QWidget* prepareHeaderOption(const QStyleOptionViewItem& option, const QModelIndex& index, QStyleOptionHeader& headerOption) const;
|
|
|
|
void drawHeaderStyle(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
void drawProgressBarStyle(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
void drawComboBoxStyle(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
void drawSpinBoxStyle(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
|
|
XQModel& _modelView;
|
|
|
|
};
|
|
|
|
#endif // XQITEMDELEGATE_H
|