Files
xtree/src/items/xqitemdelegate.h
2025-09-13 22:44:33 +02:00

61 lines
2.1 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 <QCommonStyle>
#include <xqappdata.h>
class XQItem;
class XQTreeTable;
class XQViewModel;
/**
* @brief A specialized QItemDelegate class to draw different XQItem styles.
*/
class XQItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit XQItemDelegate(XQViewModel& viewModel);
XQTreeTable* treeTable() 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:
void drawHeaderStyle(QPainter* painter, const QStyleOptionViewItem& option, const XQItem& item ) const;
void drawColorBarStyle(QPainter* painter, const QStyleOptionViewItem& option, const XQItem& item) const;
void drawComboBoxStyle(QPainter* painter, const QStyleOptionViewItem& option, const XQItem& item) const;
void drawSpinBoxStyle(QPainter* painter, const QStyleOptionViewItem& option, const XQItem& item) const;
XQViewModel& _modelView;
QCommonStyle _commonStyle;
};
#endif // XQITEMDELEGATE_H