]> git.sesse.net Git - vlc/commitdiff
qt4: playlist: allow to hide all but the index 0 column
authorJakob Leben <jleben@videolan.org>
Fri, 4 Sep 2009 01:06:26 +0000 (03:06 +0200)
committerJakob Leben <jleben@videolan.org>
Sat, 5 Sep 2009 15:50:26 +0000 (17:50 +0200)
In some circumstances QTreeView does not behave properly if the column index 0 can hide/reappear.

Precisely, when column 0 is hidden and an item get's subitems, those subitems can not be D&D-ed.
If column 0 is then unhidden, trying to D&D the subitems will fail or result in unexpected behaviour.

modules/gui/qt4/components/playlist/standardpanel.cpp

index c12baa4a554296e52ae5fedf6054c3ecee67eb5d..d7cabd4a12536412af9877425decfdb6351c3716 100644 (file)
@@ -269,8 +269,10 @@ void StandardPLPanel::popupSelectColumn( QPoint pos )
 {
     QMenu menu;
 
+    /* We do not offer the option to hide index 0 column, or
+    * QTreeView will behave weird */
     int i, j;
-    for( i = 1, j = 0; i < COLUMN_END; i <<= 1, j++ )
+    for( i = 1 << 1, j = 1; i < COLUMN_END; i <<= 1, j++ )
     {
         QAction* option = menu.addAction(
             qfu( psz_column_title( i ) ) );
@@ -284,19 +286,7 @@ void StandardPLPanel::popupSelectColumn( QPoint pos )
 
 void StandardPLPanel::toggleColumnShown( int i )
 {
-    if( view->isColumnHidden( i ) )
-    {
-        view->setColumnHidden( i, false );
-    }
-    else
-    {
-        int visible = 0;
-        int m, c;
-        for( m = 1, c = 0; m != COLUMN_END && visible < 2; m <<= 1, c++ )
-            if( !view->isColumnHidden( c ) ) visible++;
-        if( visible < 2 ) return;
-        view->setColumnHidden( i, true );
-    }
+    view->setColumnHidden( i, !view->isColumnHidden( i ) );
 }
 
 /* Search in the playlist */