]> cloud.milkyroute.net Git - dolphin.git/commitdiff
don't resize the columns automatically, as soon as the user has modified the column...
authorPeter Penz <peter.penz19@gmail.com>
Wed, 16 Jan 2008 22:14:34 +0000 (22:14 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Wed, 16 Jan 2008 22:14:34 +0000 (22:14 +0000)
BUG: 155760

svn path=/trunk/KDE/kdebase/apps/; revision=762385

src/dolphindetailsview.cpp
src/dolphindetailsview.h

index 4fdb76e1a777785690be48b194dcf027a88a73b7..6b15f1c41aff0fb507caae29b72f88bae121e929 100644 (file)
@@ -43,6 +43,7 @@
 
 DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* controller) :
     QTreeView(parent),
 
 DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* controller) :
     QTreeView(parent),
+       m_autoResize(true),
     m_controller(controller),
     m_font(),
     m_decorationSize(),
     m_controller(controller),
     m_font(),
     m_decorationSize(),
@@ -76,6 +77,10 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
     headerView->setContextMenuPolicy(Qt::CustomContextMenu);
     connect(headerView, SIGNAL(customContextMenuRequested(const QPoint&)),
             this, SLOT(configureColumns(const QPoint&)));
     headerView->setContextMenuPolicy(Qt::CustomContextMenu);
     connect(headerView, SIGNAL(customContextMenuRequested(const QPoint&)),
             this, SLOT(configureColumns(const QPoint&)));
+    connect(headerView, SIGNAL(sectionResized(int, int, int)),
+            this, SLOT(slotHeaderSectionResized(int, int, int)));
+    connect(headerView, SIGNAL(sectionHandleDoubleClicked(int)),
+            this, SLOT(disableAutoResizing()));
 
     connect(parent, SIGNAL(sortingChanged(DolphinView::Sorting)),
             this, SLOT(setSortIndicatorSection(DolphinView::Sorting)));
 
     connect(parent, SIGNAL(sortingChanged(DolphinView::Sorting)),
             this, SLOT(setSortIndicatorSection(DolphinView::Sorting)));
@@ -345,13 +350,7 @@ void DolphinDetailsView::keyPressEvent(QKeyEvent* event)
 void DolphinDetailsView::resizeEvent(QResizeEvent* event)
 {
     QTreeView::resizeEvent(event);
 void DolphinDetailsView::resizeEvent(QResizeEvent* event)
 {
     QTreeView::resizeEvent(event);
-
-    // TODO: There seems to be no easy way to find out whether the resize event
-    // has been triggered because of resizing the window or by adjusting the column-width
-    // by a left mouse-click (the columns should only be resized automatically when the window
-    // size is adjusted). The following workaround works well, but it should be
-    // considered solving this in a more transparent way.
-    if (!(QApplication::mouseButtons() & Qt::LeftButton)) {
+    if (m_autoResize) {
         resizeColumns();
     }
 }
         resizeColumns();
     }
 }
@@ -494,6 +493,21 @@ void DolphinDetailsView::updateColumnVisibility()
     resizeColumns();
 }
 
     resizeColumns();
 }
 
+void DolphinDetailsView::slotHeaderSectionResized(int logicalIndex, int oldSize, int newSize)
+{
+    Q_UNUSED(logicalIndex);
+    Q_UNUSED(oldSize);
+    Q_UNUSED(newSize);
+    if (QApplication::mouseButtons() & Qt::LeftButton) {
+        disableAutoResizing();
+    }
+}
+
+void DolphinDetailsView::disableAutoResizing()
+{
+    m_autoResize = false;
+}
+
 bool DolphinDetailsView::isZoomInPossible() const
 {
     DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
 bool DolphinDetailsView::isZoomInPossible() const
 {
     DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
index 086121f7ab78ca60264af9100be44163fd8097ca..a9201d8b3401b8f0d536bb51650d40b1764f4b6b 100644 (file)
@@ -118,6 +118,18 @@ private slots:
 
     void updateColumnVisibility();
 
 
     void updateColumnVisibility();
 
+    /**
+     * Disables the automatical resizing of columns, if the user has resized the columns
+     * with the mouse.
+     */
+    void slotHeaderSectionResized(int logicalIndex, int oldSize, int newSize);
+
+    /**
+     * Disables the automatical resizing of the columns. Per default all columns
+     * are resized to use the maximum available width of the view as good as possible.
+     */
+    void disableAutoResizing();
+
 private:
     bool isZoomInPossible() const;
     bool isZoomOutPossible() const;
 private:
     bool isZoomInPossible() const;
     bool isZoomOutPossible() const;
@@ -143,6 +155,8 @@ private:
     void resizeColumns();
 
 private:
     void resizeColumns();
 
 private:
+       bool m_autoResize;  // if true, the columns are resized automatically to the available width
+
     DolphinController* m_controller;
 
     QFont m_font;
     DolphinController* m_controller;
 
     QFont m_font;