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

Method paintEvent

launcher/ui/instanceview/InstanceView.cpp:501–590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499}
500
501void InstanceView::paintEvent(QPaintEvent *event)
502{
503 executeDelayedItemsLayout();
504
505 QPainter painter(this->viewport());
506
507#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
508 QStyleOptionViewItem option;
509 initViewItemOption(&option);
510#else
511 QStyleOptionViewItem option = viewOptions();
512#endif
513 option.widget = this;
514
515 int wpWidth = viewport()->width();
516 option.rect.setWidth(wpWidth);
517 for (int i = 0; i < m_groups.size(); ++i)
518 {
519 VisualGroup *category = m_groups.at(i);
520 int y = category->verticalPosition();
521 y -= verticalOffset();
522 QRect backup = option.rect;
523 int height = category->totalHeight();
524 option.rect.setTop(y);
525 option.rect.setHeight(height);
526 option.rect.setLeft(m_leftMargin);
527 option.rect.setRight(wpWidth - m_rightMargin);
528 category->drawHeader(&painter, option);
529 y += category->totalHeight() + m_categoryMargin;
530 option.rect = backup;
531 }
532
533 for (int i = 0; i < model()->rowCount(); ++i)
534 {
535 const QModelIndex index = model()->index(i, 0);
536 if (isIndexHidden(index))
537 {
538 continue;
539 }
540 Qt::ItemFlags flags = index.flags();
541 option.rect = visualRect(index);
542 option.features |= QStyleOptionViewItem::WrapText;
543 if (flags & Qt::ItemIsSelectable && selectionModel()->isSelected(index))
544 {
545 option.state |= selectionModel()->isSelected(index) ? QStyle::State_Selected
546 : QStyle::State_None;
547 }
548 else
549 {
550 option.state &= ~QStyle::State_Selected;
551 }
552 option.state |= (index == currentIndex()) ? QStyle::State_HasFocus : QStyle::State_None;
553 if (!(flags & Qt::ItemIsEnabled))
554 {
555 option.state &= ~QStyle::State_Enabled;
556 }
557 itemDelegate()->paint(&painter, option, index);
558 }

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