File indexing completed on 2024-05-12 16:02:03

0001 /*
0002  *  SPDX-FileCopyrightText: 2016 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef __KIS_PALETTE_DELEGATE_H
0008 #define __KIS_PALETTE_DELEGATE_H
0009 
0010 #include <QAbstractItemDelegate>
0011 
0012 #include "kritawidgets_export.h"
0013 
0014 
0015 class KRITAWIDGETS_EXPORT KisPaletteDelegate : public QAbstractItemDelegate
0016 {
0017 private:
0018     static const int BORDER_WIDTH;
0019 public:
0020     KisPaletteDelegate(QObject * parent = 0);
0021     ~KisPaletteDelegate() override;
0022 
0023     void setCrossedKeyword(const QString &value)
0024     {
0025         m_crossedKeyword = value;
0026     }
0027 
0028     void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override;
0029     QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex &) const override;
0030 
0031     void paintSwatch() const;
0032     
0033 private:
0034     QString m_crossedKeyword;
0035     void paintCrossedLine(const QStyleOptionViewItem &option, QPainter *painter) const;
0036     void paintNonCrossed(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index, const bool isSelected) const;
0037     void paintGroupName(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index, const bool isSelected) const;
0038 };
0039 
0040 #endif /* __KIS_PALETTE_DELEGATE_H */