]> git.sesse.net Git - vlc/commitdiff
Qt: search implementation in the plugins list dialog for fast-seeing if a module...
authorJean-Baptiste Kempf <jb@videolan.org>
Sat, 3 Jan 2009 15:58:09 +0000 (16:58 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Sat, 3 Jan 2009 15:58:09 +0000 (16:58 +0100)
modules/gui/qt4/dialogs/plugins.cpp
modules/gui/qt4/dialogs/plugins.hpp

index 5e888ff46ea9c497c2a3dc29798914cdf8560c8b..fc653f5347cee77c31f683b74a77892b49ac9b31 100644 (file)
@@ -33,6 +33,8 @@
 #include <QStringList>
 #include <QHeaderView>
 #include <QDialogButtonBox>
+#include <QLineEdit>
+#include <QLabel>
 
 PluginDialog::PluginDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
 {
@@ -66,10 +68,19 @@ PluginDialog::PluginDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
     treePlugins->setSortingEnabled( true );
     treePlugins->sortByColumn( 1, Qt::AscendingOrder );
 
+    QLabel *label = new QLabel( _("&Search:"), this );
+    edit = new QLineEdit;
+    label->setBuddy( edit );
+
+    layout->addWidget( label, 1, 0 );
+    layout->addWidget( edit, 1, 1, 1, -1 );
+    CONNECT( edit, textChanged( QString ),
+            this, search( QString ) );
+
     QDialogButtonBox *box = new QDialogButtonBox;
     QPushButton *okButton = new QPushButton( "ok", this );
     box->addButton( okButton, QDialogButtonBox::AcceptRole );
-    layout->addWidget( box, 1, 2 );
+    layout->addWidget( box, 2, 2 );
 
     BUTTONACT( okButton, close() );
 
@@ -94,6 +105,19 @@ inline void PluginDialog::FillTree()
     }
 }
 
+void PluginDialog::search( const QString qs )
+{
+    QList<QTreeWidgetItem *> items = treePlugins->findItems( qs, Qt::MatchContains );
+    items += treePlugins->findItems( qs, Qt::MatchContains, 1 );
+
+    QTreeWidgetItem *item = NULL;
+    for( int i = 0; i < treePlugins->topLevelItemCount(); i++ )
+    {
+        item = treePlugins->topLevelItem( i );
+        item->setHidden( !items.contains( item ) );
+    }
+}
+
 PluginDialog::~PluginDialog()
 {
     writeSettings( "Plugins" );
index b2232ea30c7c3b553504ed6ec596fccb134b1933..cd0c107ef1d0dc73eb1a6009c25fb8d4cce02923 100644 (file)
@@ -27,6 +27,7 @@
 #include "util/qvlcframe.hpp"
 
 class QTreeWidget;
+class QLineEdit;
 
 class PluginDialog : public QVLCFrame
 {
@@ -38,6 +39,9 @@ private:
     virtual ~PluginDialog();
 
     QTreeWidget *treePlugins;
+    QLineEdit *edit;
+private slots:
+    void search( const QString );
 };
 
 #endif