MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / paint

Method paint

launcher/ui/instanceview/InstanceDelegate.cpp:198–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198void ListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
199 const QModelIndex &index) const
200{
201 QStyleOptionViewItem opt = option;
202 initStyleOption(&opt, index);
203 painter->save();
204 painter->setClipRect(opt.rect);
205
206 opt.features |= QStyleOptionViewItem::WrapText;
207 opt.text = index.data().toString();
208 opt.textElideMode = Qt::ElideRight;
209 opt.displayAlignment = Qt::AlignTop | Qt::AlignHCenter;
210
211 QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
212
213 // const int iconSize = style->pixelMetric(QStyle::PM_IconViewIconSize);
214 const int iconSize = 48;
215 QRect iconbox = opt.rect;
216 const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, opt.widget) + 1;
217 QRect textRect = opt.rect;
218 QRect textHighlightRect = textRect;
219 // clip the decoration on top, remove width padding
220 textRect.adjust(textMargin, iconSize + textMargin + 5, -textMargin, 0);
221
222 textHighlightRect.adjust(0, iconSize + 5, 0, 0);
223
224 // draw background
225 {
226 // FIXME: unused
227 // QSize textSize = viewItemTextSize ( &opt );
228 drawSelectionRect(painter, opt, textHighlightRect);
229 /*
230 QPalette::ColorGroup cg;
231 QStyleOptionViewItem opt2(opt);
232
233 if ((opt.widget && opt.widget->isEnabled()) || (opt.state & QStyle::State_Enabled))
234 {
235 if (!(opt.state & QStyle::State_Active))
236 cg = QPalette::Inactive;
237 else
238 cg = QPalette::Normal;
239 }
240 else
241 {
242 cg = QPalette::Disabled;
243 }
244 */
245 /*
246 opt2.palette.setCurrentColorGroup(cg);
247
248 // fill in background, if any
249
250
251 if (opt.backgroundBrush.style() != Qt::NoBrush)
252 {
253 QPointF oldBO = painter->brushOrigin();
254 painter->setBrushOrigin(opt.rect.topLeft());
255 painter->fillRect(opt.rect, opt.backgroundBrush);

Callers 3

paintEventMethod · 0.45
renderToPixmapMethod · 0.45
drawBadgesFunction · 0.45

Calls 9

drawSelectionRectFunction · 0.85
drawBadgesFunction · 0.85
drawProgressOverlayFunction · 0.85
setFontMethod · 0.80
viewItemTextLayoutFunction · 0.70
saveMethod · 0.45
toStringMethod · 0.45
dataMethod · 0.45
setTextMethod · 0.45

Tested by

no test coverage detected