| 499 | } |
| 500 | |
| 501 | void 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 | } |
nothing calls this directly
no test coverage detected