diff options
| author | Peter Penz <[email protected]> | 2012-02-22 18:28:11 +0100 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2012-02-22 18:31:03 +0100 |
| commit | dbc5fd7a491f95ca4084a113d0f902ea975478fd (patch) | |
| tree | f9c43d6008e48189f39bd58cd7f0982a5f177065 /src/kitemviews/kitemlistwidget.cpp | |
| parent | bdd0fdf2460232fe17b0e54e42fcda4cc18b811a (diff) | |
Fix alternate backgrounds when enabling grouping
Up to now the alternating backgrounds just have been calculated by
checking whether the item index is odd. This does not work well when
grouping is enabled: In this case the alternate background color
of the first item of a group should stay consistent.
Diffstat (limited to 'src/kitemviews/kitemlistwidget.cpp')
| -rw-r--r-- | src/kitemviews/kitemlistwidget.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp index 94eed6840..9d58a283e 100644 --- a/src/kitemviews/kitemlistwidget.cpp +++ b/src/kitemviews/kitemlistwidget.cpp @@ -40,7 +40,7 @@ KItemListWidget::KItemListWidget(QGraphicsItem* parent) : m_selected(false), m_current(false), m_hovered(false), - m_alternatingBackgroundColors(false), + m_alternateBackground(false), m_enabledSelectionToggle(false), m_data(), m_visibleRoles(), @@ -105,7 +105,7 @@ void KItemListWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* o { Q_UNUSED(option); - if (m_alternatingBackgroundColors && (m_index & 0x1)) { + if (m_alternateBackground) { const QColor backgroundColor = m_styleOption.palette.color(QPalette::AlternateBase); const QRectF backgroundRect(0, 0, size().width(), size().height()); painter->fillRect(backgroundRect, backgroundColor); @@ -276,18 +276,18 @@ bool KItemListWidget::isHovered() const return m_hovered; } -void KItemListWidget::setAlternatingBackgroundColors(bool enable) +void KItemListWidget::setAlternateBackground(bool enable) { - if (m_alternatingBackgroundColors != enable) { - m_alternatingBackgroundColors = enable; - alternatingBackgroundColorsChanged(enable); + if (m_alternateBackground != enable) { + m_alternateBackground = enable; + alternateBackgroundChanged(enable); update(); } } -bool KItemListWidget::alternatingBackgroundColors() const +bool KItemListWidget::alternateBackground() const { - return m_alternatingBackgroundColors; + return m_alternateBackground; } void KItemListWidget::setEnabledSelectionToggle(bool enable) @@ -381,7 +381,7 @@ void KItemListWidget::hoveredChanged(bool hovered) Q_UNUSED(hovered); } -void KItemListWidget::alternatingBackgroundColorsChanged(bool enabled) +void KItemListWidget::alternateBackgroundChanged(bool enabled) { Q_UNUSED(enabled); } |
