[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kio] src/filewidgets: Make it clearer that all of this is just about the name column.
From:       Andreas Hartmetz <ahartmetz () gmail ! com>
Date:       2016-11-12 18:22:07
Message-ID: E1c5cwJ-0006PS-GT () code ! kde ! org
[Download RAW message or body]

Git commit 5c8330ff68651ce59c22b292eca4ae794b23dc86 by Andreas Hartmetz.
Committed on 12/11/2016 at 18:19.
Pushed by ahartmetz into branch 'master'.

Make it clearer that all of this is just about the name column.

M  +6    -10   src/filewidgets/kdiroperatordetailview.cpp
M  +1    -1    src/filewidgets/kdiroperatordetailview_p.h

http://commits.kde.org/kio/5c8330ff68651ce59c22b292eca4ae794b23dc86

diff --git a/src/filewidgets/kdiroperatordetailview.cpp b/src/filewidgets/kdiroperatordetailview.cpp
index 247f97c..e6becae 100644
--- a/src/filewidgets/kdiroperatordetailview.cpp
+++ b/src/filewidgets/kdiroperatordetailview.cpp
@@ -63,7 +63,7 @@ void KDirOperatorDetailView::setModel(QAbstractItemModel *model)
         resetResizing();
     }
 
-    connect(model, SIGNAL(layoutChanged()), this, SLOT(slotLayoutChanged()));
+    connect(model, SIGNAL(layoutChanged()), this, SLOT(expandNameColumn()));
 
     QTreeView::setModel(model);
 }
@@ -162,25 +162,21 @@ void KDirOperatorDetailView::disableColumnResizing()
     m_resizeColumns = false;
 }
 
-void KDirOperatorDetailView::slotLayoutChanged()
+void KDirOperatorDetailView::expandNameColumn()
 {
     if (m_resizeColumns) {
         QHeaderView *headerView = header();
         headerView->resizeSections(QHeaderView::ResizeToContents);
 
-        // calculate the required width for all columns except the name column
-        int requiredWidth = 0;
+        int notNameWidth = 0;
         const int count = headerView->count();
         for (int i = 1; i < count; ++i) {
-            requiredWidth += headerView->sectionSize(i);
+            notNameWidth += headerView->sectionSize(i);
         }
 
         // try to stretch the name column if enough width is available
-        int oldNameColumnWidth = headerView->sectionSize(KDirModel::Name);
-        int nameColumnWidth = viewport()->width() - requiredWidth;
-        if (nameColumnWidth < oldNameColumnWidth) {
-            nameColumnWidth = oldNameColumnWidth;
-        }
+        const int oldNameColumnWidth = headerView->sectionSize(KDirModel::Name);
+        const int nameColumnWidth = qMax(oldNameColumnWidth, viewport()->width() - notNameWidth);
         headerView->resizeSection(KDirModel::Name, nameColumnWidth);
     }
 }
diff --git a/src/filewidgets/kdiroperatordetailview_p.h b/src/filewidgets/kdiroperatordetailview_p.h
index 7945438..25a1ea1 100644
--- a/src/filewidgets/kdiroperatordetailview_p.h
+++ b/src/filewidgets/kdiroperatordetailview_p.h
@@ -53,7 +53,7 @@ protected:
 private Q_SLOTS:
     void resetResizing();
     void disableColumnResizing();
-    void slotLayoutChanged();
+    void expandNameColumn();
 
 private:
     bool m_resizeColumns;

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic