]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Details view: Expand the name-column like in Dolphin 1.x
authorPeter Penz <peter.penz19@gmail.com>
Thu, 22 Mar 2012 14:39:07 +0000 (15:39 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 22 Mar 2012 14:47:01 +0000 (15:47 +0100)
With the new view-engine the name-column always has been expanded
to the maximum width of all available names. But this makes it
impossible to see other columns without scrolling when having long
filenames, so per default the Dolphin 1.x behavior has been applied
to the new view-engine so that the name-column-width gets decreased
to be able to show the other columns.

This patch will be released with KDE applications 4.8.2. For
Dolphin 2.1 (KDE applications 4.9) user-modified widths of the
columns will be remembered per directory also between different
sessions.

CCBUG: 264434

src/kitemviews/kfileitemlistview.cpp
src/kitemviews/kitemlistheader.cpp
src/kitemviews/kitemlistheader_p.h
src/kitemviews/kitemlistview.cpp

index 796a45099cd4818e6f3b50b6c5e9638dac02d62f..54d858c1e5ba34c3fe2aee47fd1dfe0124351689 100644 (file)
@@ -513,7 +513,7 @@ QSizeF KFileItemListView::visibleRoleSizeHint(int index, const QByteArray& role)
     if (role == "name") {
         // Increase the width by the expansion-toggle and the current expansion level
         const int expandedParentsCount = values.value("expandedParentsCount", 0).toInt();
     if (role == "name") {
         // Increase the width by the expansion-toggle and the current expansion level
         const int expandedParentsCount = values.value("expandedParentsCount", 0).toInt();
-        width += option.padding + expandedParentsCount * itemSize().height() + KIconLoader::SizeSmall;
+        width += option.padding + (expandedParentsCount + 1) * itemSize().height() + KIconLoader::SizeSmall;
 
         // Increase the width by the required space for the icon
         width += option.padding * 2 + option.iconSize;
 
         // Increase the width by the required space for the icon
         width += option.padding * 2 + option.iconSize;
index dfe76bc95eb52bd7dec8b376a9d67fd96d3359a6..ea714c96fc7d1e400728304d3efadb1a28d9c808 100644 (file)
@@ -95,7 +95,7 @@ QList<QByteArray> KItemListHeader::visibleRoles() const
     return m_visibleRoles;
 }
 
     return m_visibleRoles;
 }
 
-void KItemListHeader::setVisibleRolesWidths(const QHash<QByteArray, qreal> rolesWidths)
+void KItemListHeader::setVisibleRolesWidths(const QHash<QByteArray, qreal>& rolesWidths)
 {
     m_visibleRolesWidths = rolesWidths;
 
 {
     m_visibleRolesWidths = rolesWidths;
 
index 364a5f1c04bc1a75e1b18b2677134c515cc9900f..a0e54f5e315f0f78b93b3cb12348a83009a533a5 100644 (file)
@@ -44,7 +44,7 @@ public:
     void setVisibleRoles(const QList<QByteArray>& roles);
     QList<QByteArray> visibleRoles() const;
 
     void setVisibleRoles(const QList<QByteArray>& roles);
     QList<QByteArray> visibleRoles() const;
 
-    void setVisibleRolesWidths(const QHash<QByteArray, qreal> rolesWidths);
+    void setVisibleRolesWidths(const QHash<QByteArray, qreal>& rolesWidths);
     QHash<QByteArray, qreal> visibleRolesWidths() const;
 
     qreal minimumRoleWidth() const;
     QHash<QByteArray, qreal> visibleRolesWidths() const;
 
     qreal minimumRoleWidth() const;
index 678b09bffc8672c6f656eb3e22b298f3dde892a6..0880687e12b7cda0b9c10f3c22dc9dd453f99015 100644 (file)
@@ -1998,7 +1998,7 @@ void KItemListView::updateStretchedVisibleRolesSizes()
 
     // Calculate the maximum size of an item by considering the
     // visible role sizes and apply them to the layouter. If the
 
     // Calculate the maximum size of an item by considering the
     // visible role sizes and apply them to the layouter. If the
-    // size does not use the available view-size it the size of the
+    // size does not use the available view-size the size of the
     // first role will get stretched.
     m_stretchedVisibleRolesSizes = m_visibleRolesSizes;
     const QByteArray role = m_visibleRoles.first();
     // first role will get stretched.
     m_stretchedVisibleRolesSizes = m_visibleRolesSizes;
     const QByteArray role = m_visibleRoles.first();
@@ -2009,25 +2009,25 @@ void KItemListView::updateStretchedVisibleRolesSizes()
     if (dynamicItemSize.width() <= 0) {
         const qreal requiredWidth = visibleRolesSizesWidthSum();
         const qreal availableWidth = size().width();
     if (dynamicItemSize.width() <= 0) {
         const qreal requiredWidth = visibleRolesSizesWidthSum();
         const qreal availableWidth = size().width();
-        if (requiredWidth < availableWidth) {
-            // Stretch the first role to use the whole width for the item
+        if (requiredWidth != availableWidth) {
+            // Stretch the first role to use the whole remaining width
             firstRoleSize.rwidth() += availableWidth - requiredWidth;
             firstRoleSize.rwidth() += availableWidth - requiredWidth;
-            m_stretchedVisibleRolesSizes.insert(role, firstRoleSize);
-        }
-        dynamicItemSize.setWidth(qMax(requiredWidth, availableWidth));
-    }
 
 
-    if (dynamicItemSize.height() <= 0) {
-        const qreal requiredHeight = visibleRolesSizesHeightSum();
-        const qreal availableHeight = size().height();
-        if (requiredHeight < availableHeight) {
-            // Stretch the first role to use the whole height for the item
-            firstRoleSize.rheight() += availableHeight - requiredHeight;
+            // TODO: A proper calculation of the minimum width depends on the implementation
+            // of KItemListWidget. Probably a kind of minimum size-hint should be introduced
+            // later.
+            const qreal minWidth = m_styleOption.iconSize * 2 + 200;
+            if (firstRoleSize.width() < minWidth) {
+                firstRoleSize.rwidth() = minWidth;
+            }
             m_stretchedVisibleRolesSizes.insert(role, firstRoleSize);
         }
             m_stretchedVisibleRolesSizes.insert(role, firstRoleSize);
         }
-        dynamicItemSize.setHeight(qMax(requiredHeight, availableHeight));
+        dynamicItemSize.rwidth() = qMax(requiredWidth, availableWidth);
     }
 
     }
 
+    // TODO: A dynamic item height (dynamicItemSize.height() <= 0)
+    // is not handled currently
+
     m_layouter->setItemSize(dynamicItemSize);
 
     if (m_header) {
     m_layouter->setItemSize(dynamicItemSize);
 
     if (m_header) {