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