]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kfileitemlistview.cpp
Don't trigger assert when switching to details-view
[dolphin.git] / src / kitemviews / kfileitemlistview.cpp
index 03f379837cfcba418f080584250a5a5f1f4c5987..25f7738bfd9115ff93eed0e0d861d6b0986a14c7 100644 (file)
@@ -97,8 +97,17 @@ bool KFileItemListView::previewsShown() const
 void KFileItemListView::setItemLayout(Layout layout)
 {
     if (m_itemLayout != layout) {
+        const bool updateRoles = (m_itemLayout == DetailsLayout || layout == DetailsLayout);
         m_itemLayout = layout;
+        if (updateRoles) {
+            // The details-layout requires some invisible roles that
+            // must be added to the model if the new layout is "details".
+            // If the old layout was "details" the roles will get removed.
+            applyRolesToModel();
+        }
         updateLayoutOfVisibleItems();
+
+        setSupportsItemExpanding(m_itemLayout == DetailsLayout);
     }
 }
 
@@ -234,11 +243,6 @@ QHash<QByteArray, QSizeF> KFileItemListView::visibleRolesSizes(const KItemRangeL
     return sizes;
 }
 
-bool KFileItemListView::supportsItemExpanding() const
-{
-    return m_itemLayout == DetailsLayout;
-}
-
 QPixmap KFileItemListView::createDragPixmap(const QSet<int>& indexes) const
 {
     if (!model()) {