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

List:       kde-core-devel
Subject:    Re: Patch for KDirOperator: make columns in detailled view resizable
From:       Anders Lund <anders () alweb ! dk>
Date:       2007-10-04 9:43:42
Message-ID: 200710041143.42735.anders () alweb ! dk
[Download RAW message or body]

On Thursday 04 October 2007, Anders Lund wrote:
> One thing that could improve it would be to manually adjust the size of the
> name column, to make the view appear as desired. I can try to provide a
> patch doing that during the day.

Here... Uses your code to initially adjust the name row, but the rowcount 
instead of the timer.

Also sets stretchLastSection to false, so that the last column will keep its 
required width if other columns are resized.

For me this is a resonable compromise between beauty and functionality, and 
davids answer just above in this thread makes me feel that there is light at 
the end of the tunnel ;)

-- 
Anders

www: http://www.alweb.dk
jabber: anderslund@jabber.dk

["kdiroperatordetailview.patch" (text/x-diff)]

Index: kdiroperatordetailview_p.h
===================================================================
--- kdiroperatordetailview_p.h	(revision 720852)
+++ kdiroperatordetailview_p.h	(working copy)
@@ -38,9 +38,6 @@ protected:
     virtual void dragEnterEvent(QDragEnterEvent *event);
     virtual void resizeEvent(QResizeEvent *event);
 
-private slots:
-    void disableColumnResizing();
-
 private:
     bool m_resizeColumns;
 };
Index: kdiroperatordetailview.cpp
===================================================================
--- kdiroperatordetailview.cpp	(revision 720852)
+++ kdiroperatordetailview.cpp	(working copy)
@@ -47,6 +47,7 @@ bool KDirOperatorDetailView::event(QEven
         QHeaderView *headerView = header();
         headerView->setResizeMode(QHeaderView::Interactive);
         headerView->resizeSections(QHeaderView::ResizeToContents);
+        headerView->setStretchLastSection(false);
         headerView->setMovable(false);
 
         hideColumn(KDirModel::Permissions);
@@ -57,7 +58,6 @@ bool KDirOperatorDetailView::event(QEven
         // would only be done after the user has changed the width of at least
         // one column. But QHeaderView::sectionMoved() does not differ between
         // user based resizing and internal resizing...
-        QTimer::singleShot(300, this, SLOT(disableColumnResizing()));
     }
 
     return QTreeView::event(event);
@@ -74,7 +74,7 @@ void KDirOperatorDetailView::resizeEvent
 {
     QTreeView::resizeEvent(event);
 
-    if (m_resizeColumns) {
+    if (m_resizeColumns && model()->rowCount() > 0) {
         QHeaderView *headerView = header();
         headerView->resizeSections(QHeaderView::ResizeToContents);
 
@@ -91,10 +91,7 @@ void KDirOperatorDetailView::resizeEvent
             nameColumnWidth = oldNameColumnWidth;
         }
         headerView->resizeSection(KDirModel::Name, nameColumnWidth);
+        m_resizeColumns = false;
     }
 }
 
-void KDirOperatorDetailView::disableColumnResizing()
-{
-    m_resizeColumns = false;
-}


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

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