[vlc-devel] [PATCH 4/5] Qt: Preferences tree filter, UI

Yuval Tze yuvaltze at gmail.com
Tue Jul 26 23:17:36 CEST 2011


add SearchLineEdit above the advanced tree that filters the tree items.
---
 modules/gui/qt4/dialogs/preferences.cpp |   26 +++++++++++++++++++++++++-
 modules/gui/qt4/dialogs/preferences.hpp |    5 ++++-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/modules/gui/qt4/dialogs/preferences.cpp b/modules/gui/qt4/dialogs/preferences.cpp
index 20a11ca..df6e58c 100644
--- a/modules/gui/qt4/dialogs/preferences.cpp
+++ b/modules/gui/qt4/dialogs/preferences.cpp
@@ -32,6 +32,7 @@
 
 #include "components/complete_preferences.hpp"
 #include "components/simple_preferences.hpp"
+#include "util/searchlineedit.hpp"
 
 #include <QHBoxLayout>
 #include <QGroupBox>
@@ -54,7 +55,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
 
     /* Create Panels */
     tree_panel = new QWidget;
-    tree_panel_l = new QHBoxLayout;
+    tree_panel_l = new QVBoxLayout;
     tree_panel->setLayout( tree_panel_l );
     main_panel = new QWidget;
     main_panel_l = new QHBoxLayout;
@@ -75,6 +76,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
 
     /* Tree and panel initialisations */
     advanced_tree = NULL;
+    tree_filter = NULL;
     simple_tree = NULL;
     current_simple_panel  = NULL;
     advanced_panel = NULL;
@@ -138,6 +140,20 @@ void PrefsDialog::setAdvanced()
     if( simple_tree )
         if( simple_tree->isVisible() ) simple_tree->hide();
 
+    if ( !tree_filter )
+    {
+        tree_filter = new SearchLineEdit( tree_panel );
+        tree_filter->setMinimumHeight( 26 );
+
+        CONNECT( tree_filter,
+                textChanged( const QString &  ),
+                this, advancedTreeFilterChanged( const QString & ) );
+
+        tree_panel_l->addWidget( tree_filter );
+    }
+
+    tree_filter->show();
+
     /* If don't have already and advanced TREE, then create it */
     if( !advanced_tree )
     {
@@ -179,6 +195,9 @@ void PrefsDialog::setSmall()
     if( advanced_tree )
         if( advanced_tree->isVisible() ) advanced_tree->hide();
 
+    if( tree_filter )
+        if( tree_filter->isVisible() ) tree_filter->hide();
+
     /* If no simple_tree, create one, connect it */
     if( !simple_tree )
     {
@@ -328,3 +347,8 @@ void PrefsDialog::reset()
         accept();
     }
 }
+
+void PrefsDialog::advancedTreeFilterChanged( const QString & text )
+{
+    advanced_tree->filter( text );
+}
diff --git a/modules/gui/qt4/dialogs/preferences.hpp b/modules/gui/qt4/dialogs/preferences.hpp
index e141240..cd6595f 100644
--- a/modules/gui/qt4/dialogs/preferences.hpp
+++ b/modules/gui/qt4/dialogs/preferences.hpp
@@ -40,6 +40,7 @@ class QRadioButton;
 class QWidget;
 class QCheckBox;
 class QLabel;
+class SearchLineEdit;
 
 class PrefsDialog : public QVLCDialog
 {
@@ -63,10 +64,11 @@ private:
     SPrefsPanel *simple_panels[SPrefsMax];
 
     QWidget *tree_panel;
-    QHBoxLayout *tree_panel_l;
+    QVBoxLayout *tree_panel_l;
 
     SPrefsCatList *simple_tree;
     PrefsTree *advanced_tree;
+    SearchLineEdit *tree_filter;
 
     QGroupBox *types;
     QRadioButton *small,*all;
@@ -79,6 +81,7 @@ private slots:
 
     void changeAdvPanel( QTreeWidgetItem * );
     void changeSimplePanel( int );
+    void advancedTreeFilterChanged( const QString & );
 
     void save();
     void cancel();
-- 
1.7.4.1




More information about the vlc-devel mailing list