From 25f208ebe31247f44f87ac83485389eff035ce16 Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Mon, 22 Jul 2013 19:04:14 +0200 Subject: [PATCH] Fix "truncated header" in Details View with non-Oxygen styles The code for painting the "empty header" was inconsistent with the headers of the other columns, which is probably the reason why the other styles got confused a) No QStyleOptionHeader is used b) Even if an empty header must be drawn, the last column is drawn with the option QStyleOptionHeader::End. According to Christoph, it still doesn't work with the Skulpture style, but it seems that the patch does at least not make things worse. BUG: 301800 FIXED-IN: 4.11.0 REVIEW: 111608 --- .../private/kitemlistheaderwidget.cpp | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/dolphin/src/kitemviews/private/kitemlistheaderwidget.cpp b/dolphin/src/kitemviews/private/kitemlistheaderwidget.cpp index 0f1f20b82b..b55ba1eb51 100644 --- a/dolphin/src/kitemviews/private/kitemlistheaderwidget.cpp +++ b/dolphin/src/kitemviews/private/kitemlistheaderwidget.cpp @@ -181,13 +181,6 @@ void KItemListHeaderWidget::paint(QPainter* painter, const QStyleOptionGraphicsI ++orderIndex; } - // Draw background without roles - QStyleOption opt; - opt.init(widget); - opt.rect = QRect(x, 0, size().width() - x, size().height()); - opt.state |= QStyle::State_Horizontal; - style()->drawControl(QStyle::CE_HeaderEmptyArea, &opt, painter); - if (!m_movingRole.pixmap.isNull()) { Q_ASSERT(m_roleOperation == MoveRoleOperation); painter->drawPixmap(m_movingRole.x, 0, m_movingRole.pixmap); @@ -405,12 +398,21 @@ void KItemListHeaderWidget::paintRole(QPainter* painter, } option.rect = rect.toRect(); + bool paintBackgroundForEmptyArea = false; + if (m_columns.count() == 1) { option.position = QStyleOptionHeader::OnlyOneSection; } else if (orderIndex == 0) { option.position = QStyleOptionHeader::Beginning; } else if (orderIndex == m_columns.count() - 1) { - option.position = QStyleOptionHeader::End; + // We are just painting the header for the last column. Check if there + // is some empty space to the right which needs to be filled. + if (rect.right() < size().width()) { + option.position = QStyleOptionHeader::Middle; + paintBackgroundForEmptyArea = true; + } else { + option.position = QStyleOptionHeader::End; + } } else { option.position = QStyleOptionHeader::Middle; } @@ -420,6 +422,20 @@ void KItemListHeaderWidget::paintRole(QPainter* painter, option.text = m_model->roleDescription(role); style()->drawControl(QStyle::CE_Header, &option, painter, widget); + + if (paintBackgroundForEmptyArea) { + option.state = QStyle::State_None | QStyle::State_Raised | QStyle::State_Horizontal; + option.section = m_columns.count(); + option.sortIndicator = QStyleOptionHeader::None; + + qreal backgroundRectX = rect.x() + rect.width(); + QRectF backgroundRect(backgroundRectX, 0.0, size().width() - backgroundRectX, rect.height()); + option.rect = backgroundRect.toRect(); + option.position = QStyleOptionHeader::End; + option.text = QString(); + + style()->drawControl(QStyle::CE_Header, &option, painter, widget); + } } void KItemListHeaderWidget::updatePressedRoleIndex(const QPointF& pos)