From de2c8c118476dd42dcdc2eae7af9250655aa61e6 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Sat, 3 Jan 2009 16:58:09 +0100 Subject: [PATCH] Qt: search implementation in the plugins list dialog for fast-seeing if a module is here or not. --- modules/gui/qt4/dialogs/plugins.cpp | 26 +++++++++++++++++++++++++- modules/gui/qt4/dialogs/plugins.hpp | 4 ++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/modules/gui/qt4/dialogs/plugins.cpp b/modules/gui/qt4/dialogs/plugins.cpp index 5e888ff46e..fc653f5347 100644 --- a/modules/gui/qt4/dialogs/plugins.cpp +++ b/modules/gui/qt4/dialogs/plugins.cpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include 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 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" ); diff --git a/modules/gui/qt4/dialogs/plugins.hpp b/modules/gui/qt4/dialogs/plugins.hpp index b2232ea30c..cd0c107ef1 100644 --- a/modules/gui/qt4/dialogs/plugins.hpp +++ b/modules/gui/qt4/dialogs/plugins.hpp @@ -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 -- 2.39.5