From 0ebf2d1fe0c28f9b587629ecf0e57971880eeeb0 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 8 Oct 2011 23:05:03 +0200 Subject: [PATCH] Don't let KItemListView decide itself whether to show the header The header should be turned on or off by the user of the KItemListView classes. --- src/kitemviews/kitemlistview.cpp | 24 ++++++++++++------------ src/views/dolphinitemlistcontainer.cpp | 5 +++++ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp index 93baa1334c..6d1aeca24e 100644 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@ -148,7 +148,6 @@ void KItemListView::setItemSize(const QSizeF& itemSize) m_layouter->setItemSize(itemSize); } } - setHeaderShown(emptySize); m_sizeHintResolver->clearCache(); updateLayout(); @@ -1460,17 +1459,18 @@ void KItemListView::updateVisibleRolesSizes(const KItemRangeList& itemRanges) if (itemCount == rangesItemCount) { m_visibleRolesSizes = visibleRolesSizes(itemRanges); - - // Assure the the sizes are not smaller than the minimum defined by the header - // TODO: Currently only implemented for a top-aligned header - const qreal minHeaderRoleWidth = m_header->minimumRoleWidth(); - QMutableHashIterator it (m_visibleRolesSizes); - while (it.hasNext()) { - it.next(); - const QSizeF& size = it.value(); - if (size.width() < minHeaderRoleWidth) { - const QSizeF newSize(minHeaderRoleWidth, size.height()); - m_visibleRolesSizes.insert(it.key(), newSize); + if (m_header) { + // Assure the the sizes are not smaller than the minimum defined by the header + // TODO: Currently only implemented for a top-aligned header + const qreal minHeaderRoleWidth = m_header->minimumRoleWidth(); + QMutableHashIterator it (m_visibleRolesSizes); + while (it.hasNext()) { + it.next(); + const QSizeF& size = it.value(); + if (size.width() < minHeaderRoleWidth) { + const QSizeF newSize(minHeaderRoleWidth, size.height()); + m_visibleRolesSizes.insert(it.key(), newSize); + } } } } else { diff --git a/src/views/dolphinitemlistcontainer.cpp b/src/views/dolphinitemlistcontainer.cpp index 76096dece5..6a6a51fb58 100644 --- a/src/views/dolphinitemlistcontainer.cpp +++ b/src/views/dolphinitemlistcontainer.cpp @@ -189,11 +189,16 @@ void DolphinItemListContainer::setItemLayout(KFileItemListView::Layout layout) switch (layout) { case KFileItemListView::IconsLayout: + m_fileItemListView->setScrollOrientation(Qt::Vertical); + m_fileItemListView->setHeaderShown(false); + break; case KFileItemListView::DetailsLayout: m_fileItemListView->setScrollOrientation(Qt::Vertical); + m_fileItemListView->setHeaderShown(true); break; case KFileItemListView::CompactLayout: m_fileItemListView->setScrollOrientation(Qt::Horizontal); + m_fileItemListView->setHeaderShown(false); break; default: Q_ASSERT(false);