| 797 | } |
| 798 | |
| 799 | void RDHeaderView::paintEvent(QPaintEvent *e) |
| 800 | { |
| 801 | if(!m_customSizing) |
| 802 | return QHeaderView::paintEvent(e); |
| 803 | |
| 804 | if(count() == 0) |
| 805 | return; |
| 806 | |
| 807 | QPainter painter(viewport()); |
| 808 | |
| 809 | int start = qMax(visualIndexAt(e->rect().left()), 0); |
| 810 | int end = visualIndexAt(e->rect().right()); |
| 811 | |
| 812 | if(end == -1) |
| 813 | end = count() - 1; |
| 814 | |
| 815 | // make sure we always paint the whole header for any merged headers |
| 816 | while(start > 0 && !hasGroupTitle(start - 1)) |
| 817 | start--; |
| 818 | while(end < m_sections.count() && !hasGroupTitle(end)) |
| 819 | end++; |
| 820 | |
| 821 | QRect accumRect; |
| 822 | for(int i = start; i <= end; ++i) |
| 823 | { |
| 824 | int pos = sectionViewportPosition(i); |
| 825 | int size = sectionSize(i); |
| 826 | |
| 827 | if(!hasGroupGap(i) && pos < 0) |
| 828 | { |
| 829 | size += pos; |
| 830 | pos = 0; |
| 831 | } |
| 832 | |
| 833 | // either set or accumulate this section's rect |
| 834 | if(accumRect.isEmpty()) |
| 835 | accumRect.setRect(pos, 0, size, viewport()->height()); |
| 836 | else |
| 837 | accumRect.setWidth(accumRect.width() + size); |
| 838 | |
| 839 | if(hasGroupTitle(i)) |
| 840 | { |
| 841 | painter.save(); |
| 842 | |
| 843 | if(accumRect.left() < m_pinnedWidth && i >= m_pinnedColumns) |
| 844 | accumRect.setLeft(m_pinnedWidth); |
| 845 | |
| 846 | paintSection(&painter, accumRect, i); |
| 847 | painter.restore(); |
| 848 | |
| 849 | // if we have more sections to go, reset so we can accumulate the next group |
| 850 | if(i < end) |
| 851 | accumRect = QRect(); |
| 852 | } |
| 853 | } |
| 854 | |
| 855 | // clear the remainder of the header if there's a gap |
| 856 | if(accumRect.right() < e->rect().right()) |
nothing calls this directly
no test coverage detected