[vlc-commits] Qt: Preferences tree filter, UI

Yuval Tze git at videolan.org
Fri Jul 29 13:06:16 CEST 2011


vlc | branch: master | Yuval Tze <yuvaltze at gmail.com> | Tue Jul 26 22:03:26 2011 +0300| [cd56737fdf47b3c50ebdf0aa2f6ec3c4d8e830a5] | committer: Francois Cartegnie

Qt: Preferences tree filter, UI

add SearchLineEdit above the advanced tree that filters the tree items.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cd56737fdf47b3c50ebdf0aa2f6ec3c4d8e830a5
---

 modules/gui/qt4/dialogs/preferences.cpp |   25 ++++++++++++++++++++++++-
 modules/gui/qt4/dialogs/preferences.hpp |    5 ++++-
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/modules/gui/qt4/dialogs/preferences.cpp b/modules/gui/qt4/dialogs/preferences.cpp
index 20a11ca..1d2a3ae 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,19 @@ 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 +194,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 +346,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();



More information about the vlc-commits mailing list