]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix layout issue for groups
authorPeter Penz <peter.penz19@gmail.com>
Sun, 30 Oct 2011 09:19:29 +0000 (10:19 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 30 Oct 2011 09:21:11 +0000 (10:21 +0100)
When enabling a group where the sort-role is retrieved
asynchronously (e.g. group by "type") the group-headers have
stayed invisible.

src/kitemviews/kfileitemmodel.cpp
src/kitemviews/kitemlistview.cpp
src/kitemviews/kitemlistview.h

index 60f1c72ce4ebdf7342ea38b2b01d9121f4e65025..523fb619d766c1ede5bab4f7af9cd363e3fefc97 100644 (file)
@@ -119,6 +119,9 @@ bool KFileItemModel::setData(int index, const QHash<QByteArray, QVariant>& value
         }
 
         if (!changedRoles.isEmpty()) {
+            if (groupedSorting() && changedRoles.contains(sortRole())) {
+                m_groups.clear();
+            }
             m_data[index] = currentValue;
             emit itemsChanged(KItemRangeList() << KItemRange(index, 1), changedRoles);
         }
index 24fb62aefb921d20eecd1c8ea73ac3c6abb97171..b11fe905dbb8ae77af0ec36947741a044c1b8606 100644 (file)
@@ -126,7 +126,7 @@ void KItemListView::setScrollOrientation(Qt::Orientation orientation)
         }
     }
 
-    updateLayout();
+    doLayout(Animation, 0, 0);
 
     onScrollOrientationChanged(orientation, previousOrientation);
     emit scrollOrientationChanged(orientation, previousOrientation);
@@ -158,7 +158,7 @@ void KItemListView::setItemSize(const QSizeF& itemSize)
     }
 
     m_sizeHintResolver->clearCache();
-    updateLayout();
+    doLayout(Animation, 0, 0);
     onItemSizeChanged(itemSize, previousSize);
 }
 
@@ -182,7 +182,6 @@ void KItemListView::setScrollOffset(qreal offset)
     m_animation->setScrollOffset(offset);
     if (!m_layoutTimer->isActive()) {
         doLayout(NoAnimation, 0, 0);
-        update();
     }
     onScrollOffsetChanged(offset, previousOffset);
 }
@@ -205,7 +204,6 @@ void KItemListView::setItemOffset(qreal offset)
     }
     if (!m_layoutTimer->isActive()) {
         doLayout(NoAnimation, 0, 0);
-        update();
     }
 }
 
@@ -242,7 +240,7 @@ void KItemListView::setVisibleRoles(const QList<QByteArray>& roles)
     }
 
     updateVisibleRolesSizes();
-    updateLayout();
+    doLayout(Animation, 0, 0);
 
     onVisibleRolesChanged(roles, previousRoles);
 }
@@ -313,7 +311,7 @@ void KItemListView::setStyleOption(const KItemListStyleOption& option)
     }
 
     m_sizeHintResolver->clearCache();
-    updateLayout();
+    doLayout(Animation, 0, 0);
     onStyleOptionChanged(option, previousOption);
 }
 
@@ -432,7 +430,7 @@ void KItemListView::endTransaction()
 
     if (m_activeTransactions == 0) {
         onTransactionEnd();
-        updateLayout();
+        doLayout(Animation, 0, 0);
     }
 }
 
@@ -836,6 +834,7 @@ void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges,
         if (updateSizeHints) {
             m_sizeHintResolver->itemsChanged(index, count, roles);
             m_layouter->markAsDirty();
+
             if (!m_layoutTimer->isActive()) {
                 m_layoutTimer->start();
             }
@@ -850,12 +849,22 @@ void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges,
             }
         }
 
+        if (m_grouped && roles.contains(m_model->sortRole())) {
+            // The sort-role has been changed which might result
+            // in modified group headers
+            updateVisibleGroupHeaders();
+            doLayout(NoAnimation, 0, 0);
+            if (!m_layoutTimer->isActive()) {
+                m_layoutTimer->start();
+            }
+        }
     }
 }
 
 void KItemListView::slotGroupedSortingChanged(bool current)
 {
     m_grouped = current;
+    m_layouter->markAsDirty();
 
     if (m_grouped) {
         // Apply the height of the header to the layouter
@@ -863,10 +872,8 @@ void KItemListView::slotGroupedSortingChanged(bool current)
                                         m_styleOption.margin * 2;
         m_layouter->setGroupHeaderHeight(groupHeaderHeight);
 
-        updateVisibleGroupHeaders(); // Triggers updateLayout()
+        updateVisibleGroupHeaders();
     } else {
-        m_layouter->markAsDirty();
-
         // Clear all visible headers
         QMutableHashIterator<KItemListWidget*, KItemListGroupHeader*> it (m_visibleGroups);
         while (it.hasNext()) {
@@ -874,9 +881,9 @@ void KItemListView::slotGroupedSortingChanged(bool current)
             recycleGroupHeaderForWidget(it.key());
         }
         Q_ASSERT(m_visibleGroups.isEmpty());
-
-        updateLayout();
     }
+
+    doLayout(Animation, 0, 0);
 }
 
 void KItemListView::slotSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous)
@@ -885,6 +892,7 @@ void KItemListView::slotSortOrderChanged(Qt::SortOrder current, Qt::SortOrder pr
     Q_UNUSED(previous);
     if (m_grouped) {
         updateVisibleGroupHeaders();
+        doLayout(Animation, 0, 0);
     }
 }
 
@@ -894,6 +902,7 @@ void KItemListView::slotSortRoleChanged(const QByteArray& current, const QByteAr
     Q_UNUSED(previous);
     if (m_grouped) {
         updateVisibleGroupHeaders();
+        doLayout(Animation, 0, 0);
     }
 }
 
@@ -1049,7 +1058,7 @@ void KItemListView::slotVisibleRoleWidthChanged(const QByteArray& role,
             widget->setVisibleRolesSizes(m_stretchedVisibleRolesSizes);
         }
 
-        updateLayout();
+        doLayout(Animation, 0, 0);
     }
 }
 
@@ -1186,12 +1195,6 @@ KItemListRubberBand* KItemListView::rubberBand() const
     return m_rubberBand;
 }
 
-void KItemListView::updateLayout()
-{
-    doLayout(Animation, 0, 0);
-    update();
-}
-
 void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int changedCount)
 {
     if (m_layoutTimer->isActive()) {
@@ -1561,8 +1564,6 @@ void KItemListView::updateVisibleGroupHeaders()
         it.next();
         updateGroupHeaderForWidget(it.value());
     }
-
-    updateLayout();
 }
 
 QHash<QByteArray, qreal> KItemListView::headerRolesWidths() const
index 397ecedf5764ba53fb02882ca99b1a57c80d7064..ff908000adcdb2051642cb4d9a89de2a2cf94eb9 100644 (file)
@@ -301,7 +301,6 @@ private:
 
     KItemListRubberBand* rubberBand() const;
 
-    void updateLayout();
     void doLayout(LayoutAnimationHint hint, int changedIndex, int changedCount);
     void doGroupHeadersLayout(LayoutAnimationHint hint, int changedIndex, int changedCount);
     void emitOffsetChanges();