QHeaderView: Fix painting vertical headers in rtl mode
In rtl mode, the headers were not painted correctly. The style option selectedPosition was not filled correctly and the paint rect needed to be adjusted by one pixel to fit the table grid. Task-number: QTBUG-56520 Change-Id: Ib92d5ab6ff730bba67eca35c83cd638e613f58b9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>bb10
parent
eff7a5f38c
commit
26aa20407d
|
|
@ -2319,18 +2319,20 @@ void QHeaderView::paintEvent(QPaintEvent *e)
|
|||
d->prepareSectionSelected(); // clear and resize the bit array
|
||||
|
||||
QRect currentSectionRect;
|
||||
int logical;
|
||||
const int width = d->viewport->width();
|
||||
const int height = d->viewport->height();
|
||||
const int rtlHorizontalOffset = d->reverse() ? 1 : 0;
|
||||
for (int i = start; i <= end; ++i) {
|
||||
if (d->isVisualIndexHidden(i))
|
||||
continue;
|
||||
painter.save();
|
||||
logical = logicalIndex(i);
|
||||
const int logical = logicalIndex(i);
|
||||
if (d->orientation == Qt::Horizontal) {
|
||||
currentSectionRect.setRect(sectionViewportPosition(logical), 0, sectionSize(logical), height);
|
||||
currentSectionRect.setRect(sectionViewportPosition(logical) + rtlHorizontalOffset,
|
||||
0, sectionSize(logical), height);
|
||||
} else {
|
||||
currentSectionRect.setRect(0, sectionViewportPosition(logical), width, sectionSize(logical));
|
||||
currentSectionRect.setRect(0, sectionViewportPosition(logical),
|
||||
width, sectionSize(logical));
|
||||
}
|
||||
currentSectionRect.translate(offset);
|
||||
|
||||
|
|
@ -2776,9 +2778,9 @@ void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int logical
|
|||
if (first && last)
|
||||
opt.position = QStyleOptionHeader::OnlyOneSection;
|
||||
else if (first)
|
||||
opt.position = QStyleOptionHeader::Beginning;
|
||||
opt.position = d->reverse() ? QStyleOptionHeader::End : QStyleOptionHeader::Beginning;
|
||||
else if (last)
|
||||
opt.position = QStyleOptionHeader::End;
|
||||
opt.position = d->reverse() ? QStyleOptionHeader::Beginning : QStyleOptionHeader::End;
|
||||
else
|
||||
opt.position = QStyleOptionHeader::Middle;
|
||||
opt.orientation = d->orientation;
|
||||
|
|
|
|||
Loading…
Reference in New Issue