| 469 | } |
| 470 | |
| 471 | void 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 |
nothing calls this directly
no test coverage detected