29{
30 if (!index.isValid())
31 return;
32
33 painter->save();
34 const bool isSelected = option.state & QStyle::State_Selected;
35
37
38 QString
name = qvariant_cast<QString>(index.data(Qt::DisplayRole));
39 if (isSelected) {
40 painter->fillRect(option.rect, option.palette.highlight());
41 }
43 painter->setBrush(QBrush(Qt::lightGray));
44 painter->drawText(paintRect, name);
45 }
46 else {
47 QRect paintRect = option.rect;
48 if (isSelected) {
49 painter->fillRect(option.rect, option.palette.highlight());
51 }
53 QBrush brush = qvariant_cast<QBrush>(index.data(Qt::BackgroundRole));
54 painter->fillRect(paintRect, brush);
55 } else {
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);
61 }
62
63 QString
name = qvariant_cast<QString>(index.data(Qt::DisplayRole));
65
66
67 QRect crossRect =
kisGrowRect(option.rect, -qBound(2, option.rect.width() / 6, 4));
68
69 painter->save();
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());
75 painter->restore();
76
77 }
78 }
79
80 painter->restore();
81}
static const int BORDER_WIDTH
T kisGrowRect(const T &rect, U offset)
const char * name(StandardAction id)