[vlc-devel] [PATCH] QT : MediaLibrary : avoid collapsing on search

Max Appel videolan at maxappel.de
Sun Jan 5 13:10:18 CET 2014


Added a gui-element to qt-gui to avoid MediaLibrary-TreeView
 beeing collapsed on search - added checkbox "keep expanded" to
 PlayList-Dialog - added (qt)setting "Playlist/keepExpanded" to save current
 state - changed StandardPL_Panel to behave according to this gui-element

---
 modules/gui/qt4/components/playlist/playlist.cpp      | 18 ++++++++++++++++++
 modules/gui/qt4/components/playlist/playlist.hpp      |  2 ++
 modules/gui/qt4/components/playlist/standardpanel.cpp | 18 ++++++++++++++++++
 modules/gui/qt4/components/playlist/standardpanel.hpp |  3 +++
 4 files changed, 41 insertions(+)

diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp
index 7c092d6..549f853 100644
--- a/modules/gui/qt4/components/playlist/playlist.cpp
+++ b/modules/gui/qt4/components/playlist/playlist.cpp
@@ -42,6 +42,7 @@
 #include <QSignalMapper>
 #include <QSlider>
 #include <QStackedWidget>
+#include <QCheckBox>
 
 /**********************************************************************
  * Playlist Widget. The embedded playlist
@@ -119,6 +120,22 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
     layout->addLayout( topbarLayout, 0, 1 );
     topbarLayout->setSpacing( 10 );
 
+    /* Checkbox to avoid collapsing of tree while searching */
+    expandAllCheckBox = new QCheckBox( this );
+    expandAllCheckBox->setText( qtr("keep expanded") );
+    getSettings()->beginGroup("Playlist");
+    if( getSettings()->value("keepExpanded", false).toBool() )
+    {
+      expandAllCheckBox->setCheckState( Qt::Checked );
+    }
+    else
+    {
+      expandAllCheckBox->setCheckState( Qt::Unchecked );
+    }
+    getSettings()->endGroup();
+    topbarLayout->addWidget( expandAllCheckBox );
+    CONNECT( expandAllCheckBox, toggled(bool), mainView, setExpandAll(bool) );
+
     /* Button to switch views */
     QToolButton *viewButton = new QToolButton( this );
     viewButton->setIcon( style()->standardIcon( QStyle::SP_FileDialogDetailedView ) );
@@ -184,6 +201,7 @@ PlaylistWidget::~PlaylistWidget()
     getSettings()->beginGroup("Playlist");
     getSettings()->setValue( "splitterSizes", split->saveState() );
     getSettings()->setValue( "leftSplitterGeometry", leftSplitter->saveState() );
+    getSettings()->setValue( "keepExpanded", expandAllCheckBox->isChecked() );
     getSettings()->endGroup();
     msg_Dbg( p_intf, "Playlist Destroyed" );
 }
diff --git a/modules/gui/qt4/components/playlist/playlist.hpp b/modules/gui/qt4/components/playlist/playlist.hpp
index 5b50420..26808a2 100644
--- a/modules/gui/qt4/components/playlist/playlist.hpp
+++ b/modules/gui/qt4/components/playlist/playlist.hpp
@@ -47,6 +47,7 @@ class SearchLineEdit;
 class QModelIndex;
 class QStackedWidget;
 class PLSelector;
+class QCheckBox;
 
 class PlaylistWidget : public QWidget
 {
@@ -65,6 +66,7 @@ private:
 
     PLSelector           *selector;
 
+    QCheckBox            *expandAllCheckBox;
     LocationBar          *locationBar;
     SearchLineEdit       *searchEdit;
 
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index 9642722..bcd240c 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -108,6 +108,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     /* Saved Settings */
     int i_savedViewMode = getSettings()->value( "Playlist/view-mode", TREE_VIEW ).toInt();
     i_zoom = getSettings()->value( "Playlist/zoom", 0 ).toInt();
+    expandAll = getSettings()->value( "Playlist/keepExpanded" ).toBool();
 
     showView( i_savedViewMode );
 
@@ -119,6 +120,9 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     CONNECT( model->sigs, rootIndexChanged(), this, browseInto() );
 
     setRootItem( p_root, false );
+
+    /* expand if needed */
+    setExpandAll(expandAll);
 }
 
 StandardPLPanel::~StandardPLPanel()
@@ -449,6 +453,9 @@ void StandardPLPanel::search( const QString& searchText )
         model->filter( searchText,
                        flat ? currentView->rootIndex() : QModelIndex(),
                        !flat );
+
+        if(currentView == treeView)
+            setExpandAll(expandAll);
     }
 }
 
@@ -467,6 +474,14 @@ void StandardPLPanel::searchDelayed( const QString& searchText )
     }
 }
 
+void StandardPLPanel::setExpandAll( bool expand )
+{
+    expandAll = expand;
+    if(!treeView) return;
+    if(expandAll) treeView->expandAll();
+    else treeView->collapseAll();
+}
+
 /* Set the root of the new Playlist */
 /* This activated by the selector selection */
 void StandardPLPanel::setRootItem( playlist_item_t *p_item, bool b )
@@ -486,6 +501,9 @@ void StandardPLPanel::setRootItem( playlist_item_t *p_item, bool b )
         if ( model->switchToModel( VLCProxyModel::PL_MODEL ) )
             model->rebuild( p_item );
     }
+
+    /* restore treeview expansion */
+    setExpandAll(expandAll);
 }
 
 void StandardPLPanel::browseInto( const QModelIndex &index )
diff --git a/modules/gui/qt4/components/playlist/standardpanel.hpp b/modules/gui/qt4/components/playlist/standardpanel.hpp
index ac8c7a8..9dbaea1 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.hpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.hpp
@@ -95,6 +95,8 @@ private:
 
     QSignalMapper *selectColumnsSigMapper;
 
+    bool expandAll;
+
     int lastActivatedPLItemId;
     int currentRootIndexPLId;
 
@@ -126,6 +128,7 @@ private slots:
 
     void search( const QString& searchText );
     void searchDelayed( const QString& searchText );
+    void setExpandAll( bool expand );
 
     void popupPlView( const QPoint & );
     void popupSelectColumn( QPoint );
-- 
1.8.1.4




More information about the vlc-devel mailing list