32{
33 painter->save();
34
35 if (! index.isValid())
36 return;
37
38 const bool isSelected = option.state & QStyle::State_Selected;
39 const int minSize = qMin(option.rect.width(), option.rect.height());
40 const int maxWidth = qBound(2, minSize / 6, 4);
41 const int width = isSelected ? maxWidth : 1;
42
43 if (qvariant_cast<bool>(index.data(KisPaletteModel::IsHeaderRole))) {
44 QString
name = qvariant_cast<QString>(index.data(Qt::DisplayRole));
45 if (isSelected) {
46 painter->fillRect(option.rect, option.palette.highlight());
47 }
49 painter->drawText(paintRect, name);
50 } else {
51 if (isSelected) {
52 painter->fillRect(option.rect, option.palette.highlight());
53 }
55 QBrush brush = qvariant_cast<QBrush>(index.data(Qt::BackgroundRole));
56 painter->fillRect(paintRect, brush);
57 }
58 painter->restore();
59
60 QString
name = qvariant_cast<QString>(index.data(Qt::DisplayRole));
62 QRect crossRect =
kisGrowRect(option.rect, -maxWidth);
63
64 painter->save();
65 painter->setRenderHint(QPainter::Antialiasing, true);
66 painter->setPen(QPen(Qt::white, 2.5));
67 painter->drawLine(crossRect.topLeft(), crossRect.bottomRight());
68 painter->setPen(QPen(Qt::red, 1.0));
69 painter->drawLine(crossRect.topLeft(), crossRect.bottomRight());
70 painter->restore();
71 }
72}
T kisGrowRect(const T &rect, U offset)
const char * name(StandardAction id)