20 : QAbstractItemDelegate(
parent)
27 const QStyleOptionViewItem &option,
28 const QModelIndex &index)
const
34 const bool isSelected = option.state & QStyle::State_Selected;
38 QString
name = qvariant_cast<QString>(index.data(Qt::DisplayRole));
40 painter->fillRect(option.rect, option.palette.highlight());
43 painter->setBrush(QBrush(Qt::lightGray));
44 painter->drawText(paintRect, name);
47 QRect paintRect = option.rect;
49 painter->fillRect(option.rect, option.palette.highlight());
53 QBrush brush = qvariant_cast<QBrush>(index.data(Qt::BackgroundRole));
54 painter->fillRect(paintRect, brush);
56 QBrush lightBrush(Qt::gray);
57 QBrush darkBrush(Qt::darkGray);
58 painter->fillRect(paintRect, lightBrush);
59 painter->fillRect(QRect(paintRect.topLeft(), paintRect.center()), darkBrush);
60 painter->fillRect(QRect(paintRect.center(), paintRect.bottomRight()), darkBrush);
63 QString
name = qvariant_cast<QString>(index.data(Qt::DisplayRole));
67 QRect crossRect =
kisGrowRect(option.rect, -qBound(2, option.rect.width() / 6, 4));
70 painter->setRenderHint(QPainter::Antialiasing,
true);
71 painter->setPen(QPen(Qt::white, 2.5));
72 painter->drawLine(crossRect.topLeft(), crossRect.bottomRight());
73 painter->setPen(QPen(Qt::red, 1.0));
74 painter->drawLine(crossRect.topLeft(), crossRect.bottomRight());
84 const QModelIndex &)
const
86 return option.decorationSize;
KisPaletteDelegate(QObject *parent=0)
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &) const override
~KisPaletteDelegate() override
static const int BORDER_WIDTH
void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override
T kisGrowRect(const T &rect, U offset)
const char * name(StandardAction id)
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)