From 55f46ceb9ca128655f2f7859966b7c6d0c50f2ed Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Tue, 14 Feb 2012 20:57:17 +0100 Subject: [PATCH] Details view: Siblings fixes The siblings should only range within one group. --- src/kitemviews/kitemlistview.cpp | 35 ++++++++++++++++++++++++------ src/kitemviews/kitemlistwidget.cpp | 2 -- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp index de80819d7..247354419 100644 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@ -954,6 +954,13 @@ void KItemListView::slotItemsMoved(const KItemRange& itemRange, const QList } } + if (supportsItemExpanding()) { + // The siblings information only gets updated in KItemListView::doLayout() if + // items have been inserted or removed. In the case of just moving the items + // the siblings must be updated manually: + updateSiblingsInformation(firstVisibleMovedIndex, lastVisibleMovedIndex); + } + doLayout(NoAnimation); } @@ -2079,21 +2086,35 @@ void KItemListView::updateSiblingsInformation(int firstIndex, int lastIndex) bool KItemListView::hasSiblingSuccessor(int index) const { + bool hasSuccessor = false; const int parentsCount = m_model->expandedParentsCount(index); - ++index; + int successorIndex = index + 1; + // Search the next sibling const int itemCount = m_model->count(); - while (index < itemCount) { - const int currentParentsCount = m_model->expandedParentsCount(index); + while (successorIndex < itemCount) { + const int currentParentsCount = m_model->expandedParentsCount(successorIndex); if (currentParentsCount == parentsCount) { - return true; + hasSuccessor = true; + break; } else if (currentParentsCount < parentsCount) { - return false; + break; } - ++index; + ++successorIndex; } - return false; + if (m_grouped && hasSuccessor) { + // If the sibling is part of another group, don't mark it as + // successor as the group header is between the sibling connections. + for (int i = index + 1; i <= successorIndex; ++i) { + if (m_layouter->isFirstGroupItem(i)) { + hasSuccessor = false; + break; + } + } + } + + return hasSuccessor; } int KItemListView::calculateAutoScrollingIncrement(int pos, int range, int oldInc) diff --git a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp index 24a3f079a..94eed6840 100644 --- a/src/kitemviews/kitemlistwidget.cpp +++ b/src/kitemviews/kitemlistwidget.cpp @@ -105,8 +105,6 @@ void KItemListWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* o { Q_UNUSED(option); - painter->setRenderHint(QPainter::Antialiasing); - if (m_alternatingBackgroundColors && (m_index & 0x1)) { const QColor backgroundColor = m_styleOption.palette.color(QPalette::AlternateBase); const QRectF backgroundRect(0, 0, size().width(), size().height()); -- 2.47.3