MCPcopy Create free account
hub / github.com/MultiMC/Launcher / paintEvent

Method paintEvent

launcher/ui/instanceview/InstanceView.cpp:471–555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469}
470
471void InstanceView::paintEvent(QPaintEvent *event)
472{
473 executeDelayedItemsLayout();
474
475 QPainter painter(this->viewport());
476
477 QStyleOptionViewItem option(viewOptions());
478 option.widget = this;
479
480 int wpWidth = viewport()->width();
481 option.rect.setWidth(wpWidth);
482 for (int i = 0; i < m_groups.size(); ++i)
483 {
484 VisualGroup *category = m_groups.at(i);
485 int y = category->verticalPosition();
486 y -= verticalOffset();
487 QRect backup = option.rect;
488 int height = category->totalHeight();
489 option.rect.setTop(y);
490 option.rect.setHeight(height);
491 option.rect.setLeft(m_leftMargin);
492 option.rect.setRight(wpWidth - m_rightMargin);
493 category->drawHeader(&painter, option);
494 y += category->totalHeight() + m_categoryMargin;
495 option.rect = backup;
496 }
497
498 for (int i = 0; i < model()->rowCount(); ++i)
499 {
500 const QModelIndex index = model()->index(i, 0);
501 if (isIndexHidden(index))
502 {
503 continue;
504 }
505 Qt::ItemFlags flags = index.flags();
506 option.rect = visualRect(index);
507 option.features |= QStyleOptionViewItem::WrapText;
508 if (flags & Qt::ItemIsSelectable && selectionModel()->isSelected(index))
509 {
510 option.state |= selectionModel()->isSelected(index) ? QStyle::State_Selected
511 : QStyle::State_None;
512 }
513 else
514 {
515 option.state &= ~QStyle::State_Selected;
516 }
517 option.state |= (index == currentIndex()) ? QStyle::State_HasFocus : QStyle::State_None;
518 if (!(flags & Qt::ItemIsEnabled))
519 {
520 option.state &= ~QStyle::State_Enabled;
521 }
522 itemDelegate()->paint(&painter, option, index);
523 }
524
525 /*
526 * Drop indicators for manual reordering...
527 */
528#if 0

Callers

nothing calls this directly

Calls 11

verticalPositionMethod · 0.80
totalHeightMethod · 0.80
drawHeaderMethod · 0.80
isSelectedMethod · 0.80
sizeMethod · 0.45
atMethod · 0.45
rowCountMethod · 0.45
indexMethod · 0.45
flagsMethod · 0.45
paintMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected