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 125 of file KisPaletteChooser.cpp.

126 : QAbstractItemDelegate(parent)
127{ }

◆ ~Delegate()

KisPaletteChooserPrivate::Delegate::~Delegate ( )
virtual

Definition at line 129 of file KisPaletteChooser.cpp.

130{ }

Member Function Documentation

◆ paint()

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

Definition at line 132 of file KisPaletteChooser.cpp.

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

167{
168 return option.decorationSize;
169}

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