60{
61 if (!index.isValid()) {
62 return;
63 }
64
66
67 int minMargin = 3;
68 int textMargin = 10;
69
70 painter->save();
71
72
73 QColor bgColor = option.state & QStyle::State_Selected ?
74 qApp->palette().color(QPalette::Highlight) :
75 qApp->palette().color(QPalette::Base);
76
77 QBrush oldBrush(painter->brush());
78 QPen oldPen = painter->pen();
79
80 painter->setBrush(QBrush(bgColor));
81 painter->setPen(Qt::NoPen);
82 painter->drawRect(option.rect);
83
84 QRect paintRect =
kisGrowRect(option.rect, -minMargin);
85 int height = paintRect.height();
86
87
89
90 if (active) {
91 QColor borderColor = option.state & QStyle::State_Selected ?
92 qApp->palette().color(QPalette::HighlightedText) :
93 qApp->palette().color(QPalette::Text);
94 painter->setBrush(Qt::NoBrush);
95 painter->setPen(QPen(borderColor));
96
97 QRect borderRect =
kisGrowRect(paintRect, -painter->pen().widthF());
98
99 painter->drawRect(borderRect);
100
101 painter->setBrush(oldBrush);
102 painter->setPen(oldPen);
103
104 }
105
106
108
109 QRect iconRect = paintRect;
110 iconRect.setWidth(height);
111 painter->drawImage(iconRect, thumbnail);
112
113 QRect nameRect = paintRect;
114 nameRect.setX(paintRect.x() + height + textMargin);
115 nameRect.setWidth(paintRect.width() - height - 1.5*textMargin);
116
117 QColor textColor = option.state & QStyle::State_Selected ?
118 qApp->palette().color(QPalette::HighlightedText) :
119 qApp->palette().color(QPalette::Text);
120 painter->setPen(QPen(textColor));
121
122 QTextOption textCenterOption;
123 textCenterOption.setAlignment(Qt::AlignVCenter);
124 textCenterOption.setWrapMode(QTextOption::NoWrap);
126 painter->drawText(nameRect, name, textCenterOption);
127
128 painter->restore();
129
130}
static KisStorageModel * instance()
QVariant data(const QModelIndex &index, int role) const override
T kisGrowRect(const T &rect, U offset)
const char * name(StandardAction id)