diff options
| author | Frank Reininghaus <[email protected]> | 2013-07-22 19:04:14 +0200 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2013-07-22 19:04:14 +0200 |
| commit | 9d6d998a51316a5d15dc759d7d25a8331b922159 (patch) | |
| tree | b1e68b16de7f40c71b1887991586444f6ca851df /src/kitemviews/private/kitemlistheaderwidget.cpp | |
| parent | 0f853681ab9ccfd2ca53483b490e136ba29cf27d (diff) | |
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
Diffstat (limited to 'src/kitemviews/private/kitemlistheaderwidget.cpp')
| -rw-r--r-- | src/kitemviews/private/kitemlistheaderwidget.cpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/kitemviews/private/kitemlistheaderwidget.cpp b/src/kitemviews/private/kitemlistheaderwidget.cpp index 0f1f20b82..b55ba1eb5 100644 --- a/src/kitemviews/private/kitemlistheaderwidget.cpp +++ b/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) |
