]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Details view: Siblings fixes
authorPeter Penz <peter.penz19@gmail.com>
Tue, 14 Feb 2012 19:57:17 +0000 (20:57 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 14 Feb 2012 19:59:08 +0000 (20:59 +0100)
The siblings should only range within one group.

src/kitemviews/kitemlistview.cpp
src/kitemviews/kitemlistwidget.cpp

index de80819d7858704a15d152c424a49f6215da84c6..247354419e50c6ec1c6c3265933b419d5356e5c1 100644 (file)
@@ -954,6 +954,13 @@ void KItemListView::slotItemsMoved(const KItemRange& itemRange, const QList<int>
         }
     }
 
         }
     }
 
+    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);
 }
 
     doLayout(NoAnimation);
 }
 
@@ -2079,21 +2086,35 @@ void KItemListView::updateSiblingsInformation(int firstIndex, int lastIndex)
 
 bool KItemListView::hasSiblingSuccessor(int index) const
 {
 
 bool KItemListView::hasSiblingSuccessor(int index) const
 {
+    bool hasSuccessor = false;
     const int parentsCount = m_model->expandedParentsCount(index);
     const int parentsCount = m_model->expandedParentsCount(index);
-    ++index;
+    int successorIndex = index + 1;
 
 
+    // Search the next sibling
     const int itemCount = m_model->count();
     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) {
         if (currentParentsCount == parentsCount) {
-            return true;
+            hasSuccessor = true;
+            break;
         } else if (currentParentsCount < parentsCount) {
         } 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)
 }
 
 int KItemListView::calculateAutoScrollingIncrement(int pos, int range, int oldInc)
index 24a3f079a9005cd6dd790330cf7e3f92960ea1ef..94eed6840e833f5481204cbc41e67e583ef462e8 100644 (file)
@@ -105,8 +105,6 @@ void KItemListWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* o
 {
     Q_UNUSED(option);
 
 {
     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());
     if (m_alternatingBackgroundColors && (m_index & 0x1)) {
         const QColor backgroundColor = m_styleOption.palette.color(QPalette::AlternateBase);
         const QRectF backgroundRect(0, 0, size().width(), size().height());