]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinitemlistcontainer.cpp
Details view: Allow to turn off expandable folders like in Dolphin 1.7
[dolphin.git] / src / views / dolphinitemlistcontainer.cpp
index 299f32fabb9faca9dbe11c5e79d17ff0bf6da17f..1ece52093b1505a2444db8ea27ab0a4e5d4b4488 100644 (file)
@@ -48,7 +48,7 @@ DolphinItemListContainer::DolphinItemListContainer(KDirLister* dirLister,
     controller()->setModel(new KFileItemModel(dirLister, this));
 
     m_fileItemListView = new KFileItemListView();
-    m_fileItemListView->setWidgetCreator(new KItemListWidgetCreator<DolphinFileItemListWidget>());    
+    m_fileItemListView->setWidgetCreator(new KItemListWidgetCreator<DolphinFileItemListWidget>());
     m_fileItemListView->setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
     controller()->setView(m_fileItemListView);
 
@@ -60,7 +60,7 @@ DolphinItemListContainer::DolphinItemListContainer(KDirLister* dirLister,
 DolphinItemListContainer::~DolphinItemListContainer()
 {
     writeSettings();
-    
+
     controller()->setView(0);
     delete m_fileItemListView;
     m_fileItemListView = 0;
@@ -134,14 +134,17 @@ void DolphinItemListContainer::setItemLayout(KFileItemListView::Layout layout)
     case KFileItemListView::IconsLayout:
         m_fileItemListView->setScrollOrientation(Qt::Vertical);
         m_fileItemListView->setHeaderShown(false);
+        m_fileItemListView->setSupportsItemExpanding(false);
         break;
     case KFileItemListView::DetailsLayout:
         m_fileItemListView->setScrollOrientation(Qt::Vertical);
         m_fileItemListView->setHeaderShown(true);
+        m_fileItemListView->setSupportsItemExpanding(DetailsModeSettings::expandableFolders());
         break;
     case KFileItemListView::CompactLayout:
         m_fileItemListView->setScrollOrientation(Qt::Horizontal);
         m_fileItemListView->setHeaderShown(false);
+        m_fileItemListView->setSupportsItemExpanding(false);
         break;
     default:
         Q_ASSERT(false);
@@ -176,6 +179,11 @@ void DolphinItemListContainer::readSettings()
     beginTransaction();
 
     m_fileItemListView->setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
+
+    const bool expandableFolders = (itemLayout() && KFileItemListView::DetailsLayout) &&
+                                   DetailsModeSettings::expandableFolders();
+    m_fileItemListView->setSupportsItemExpanding(expandableFolders);
+
     updateAutoActivationDelay();
     updateFont();
     updateGridSize();
@@ -191,7 +199,7 @@ void DolphinItemListContainer::readSettings()
 }
 
 void DolphinItemListContainer::writeSettings()
-{  
+{
     IconsModeSettings::self()->writeConfig();
     CompactModeSettings::self()->writeConfig();
     DetailsModeSettings::self()->writeConfig();
@@ -206,7 +214,7 @@ void DolphinItemListContainer::updateGridSize()
     m_zoomLevel = ZoomLevelInfo::zoomLevelForIconSize(QSize(iconSize, iconSize));
     KItemListStyleOption styleOption = m_fileItemListView->styleOption();
 
-    int padding = 2;
+    const int padding = 2;
     int horizontalMargin = 0;
     int verticalMargin = 0;
 
@@ -217,7 +225,7 @@ void DolphinItemListContainer::updateGridSize()
     case KFileItemListView::IconsLayout: {
         const int minItemWidth = 48;
         itemWidth = minItemWidth + IconsModeSettings::textWidthIndex() * 64;
-        
+
         if (previewsShown()) {
             // Optimize the width for previews with a 3:2 aspect ratio instead
             // of a 1:1 ratio to avoid wasting too much vertical space when
@@ -225,12 +233,12 @@ void DolphinItemListContainer::updateGridSize()
             const int minWidth = iconSize * 3 / 2;
             itemWidth = qMax(itemWidth, minWidth);
         }
-        
+
         if (itemWidth < iconSize + padding * 2) {
             itemWidth = iconSize + padding * 2;
         }
         itemHeight = padding * 3 + iconSize + styleOption.fontMetrics.height();
-        
+
         horizontalMargin = 4;
         verticalMargin = 8;
         break;
@@ -239,14 +247,13 @@ void DolphinItemListContainer::updateGridSize()
         itemWidth = padding * 4 + iconSize + styleOption.fontMetrics.height() * 5;
         const int textLinesCount = m_fileItemListView->visibleRoles().count();
         itemHeight = padding * 2 + qMax(iconSize, textLinesCount * styleOption.fontMetrics.height());
-        
+
         horizontalMargin = 8;
         break;
     }
     case KFileItemListView::DetailsLayout: {
         itemWidth = -1;
         itemHeight = padding * 2 + qMax(iconSize, styleOption.fontMetrics.height());
-        padding = 3;
         break;
     }
     default: