Commit de2c8c11 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: search implementation in the plugins list dialog for fast-seeing if a module is here or not.

parent 1664191a
......@@ -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" );
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment