Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPaletteChooserPrivate::Delegate Class Reference

#include <KisPaletteChooser_p.h>

+ Inheritance diagram for KisPaletteChooserPrivate::Delegate:

Public Member Functions

 Delegate (QObject *)
 
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 
QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &) const override
 
virtual ~Delegate ()
 

Detailed Description

Definition at line 44 of file KisPaletteChooser_p.h.

Constructor & Destructor Documentation

◆ Delegate()

KisPaletteChooserPrivate::Delegate::Delegate ( QObject * parent)

Definition at line 127 of file KisPaletteChooser.cpp.

128 : QAbstractItemDelegate(parent)
129{ }

◆ ~Delegate()

KisPaletteChooserPrivate::Delegate::~Delegate ( )
virtual

Definition at line 131 of file KisPaletteChooser.cpp.

132{ }

Member Function Documentation

◆ paint()

void KisPaletteChooserPrivate::Delegate::paint ( QPainter * painter,
const QStyleOptionViewItem & option,
const QModelIndex & index ) const
override

Definition at line 134 of file KisPaletteChooser.cpp.

137{
138 painter->save();
139 if (!index.isValid())
140 return;
141
142 QImage preview = index.data(Qt::UserRole + KisAbstractResourceModel::Thumbnail).value<QImage>();
143 QString name = index.data(Qt::UserRole + KisAbstractResourceModel::Name).toString();
144
145 QRect previewRect(option.rect.x() + 2,
146 option.rect.y() + 2,
147 option.rect.height() - 4,
148 option.rect.height() - 4);
149
150 painter->drawImage(previewRect, preview);
151
152 if (option.state & QStyle::State_Selected) {
153 painter->fillRect(option.rect, option.palette.highlight());
154 painter->drawImage(previewRect, preview);
155 painter->setPen(option.palette.highlightedText().color());
156 } else {
157 painter->setPen(option.palette.text().color());
158 }
159
160 painter->drawText(option.rect.x() + previewRect.width() + 10,
161 option.rect.y() + painter->fontMetrics().ascent() + 5,
162 name);
163
164 painter->restore();
165}
const char * name(StandardAction id)

References KisAbstractResourceModel::Name, and KisAbstractResourceModel::Thumbnail.

◆ sizeHint()

QSize KisPaletteChooserPrivate::Delegate::sizeHint ( const QStyleOptionViewItem & option,
const QModelIndex &  ) const
inlineoverride

Definition at line 167 of file KisPaletteChooser.cpp.

169{
170 return option.decorationSize;
171}

The documentation for this class was generated from the following files: