Qt: activate the searching for the Hotkeys Preferences.
authorJean-Baptiste Kempf <jb@videolan.org>
Sat, 2 May 2009 22:27:47 +0000 (00:27 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Sat, 2 May 2009 22:27:47 +0000 (00:27 +0200)
Close #2530

modules/gui/qt4/components/preferences_widgets.cpp
modules/gui/qt4/components/preferences_widgets.hpp

index d1e255d..ec56611 100644 (file)
@@ -1138,9 +1138,8 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
     label = new QLabel(
             qtr( "Select an action to change the associated hotkey") );
 
-    /* Deactivated for now
     QLabel *searchLabel = new QLabel( qtr( "Search" ) );
-    QLineEdit *actionSearch = new QLineEdit;*/
+    actionSearch = new SearchLineEdit( keyContainer );
 
     table = new QTreeWidget;
     table->setColumnCount(3);
@@ -1158,9 +1157,8 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
     finish();
 
     gLayout->addWidget( label, 0, 0, 1, 4 );
-  /* deactivated for now
     gLayout->addWidget( searchLabel, 1, 0, 1, 2 );
-    gLayout->addWidget( actionSearch, 1, 2, 1, 2 ); */
+    gLayout->addWidget( actionSearch, 1, 2, 1, 2 );
     gLayout->addWidget( table, 2, 0, 1, 4 );
     gLayout->addWidget( clearButton, 3, 0, 1, 1 );
     gLayout->addWidget( shortcutValue, 3, 1, 1, 2 );
@@ -1171,6 +1169,8 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
     CONNECT( clearButton, clicked(), shortcutValue, clear() );
     CONNECT( clearButton, clicked(), this, setTheKey() );
     BUTTONACT( setButton, setTheKey() );
+    CONNECT( actionSearch, textChanged( const QString& ),
+             this, filter( const QString& ) );
 }
 
 void KeySelectorControl::finish()
@@ -1244,6 +1244,17 @@ void KeySelectorControl::finish()
     CONNECT( shortcutValue, pressed(), this, selectKey() );
 }
 
+void KeySelectorControl::filter( const QString &qs_search )
+{
+    QList<QTreeWidgetItem *> resultList =
+            table->findItems( qs_search, Qt::MatchContains, 0 );
+    for( int i = 0; i < table->topLevelItemCount(); i++ )
+    {
+        table->topLevelItem( i )->setHidden(
+                !resultList.contains( table->topLevelItem( i ) ) );
+    }
+}
+
 /* Show the key selected from the table in the keySelector */
 void KeySelectorControl::select1Key()
 {
@@ -1354,7 +1365,7 @@ void KeyInputDialog::checkForConflicts( int i_vlckey )
         /* Avoid 0 or -1 that are the "Unset" states */
     {
         warning->setText( qtr("Warning: the key is already assigned to \"") +
-          conflictList[0]->text( 0 ) + "\"" );
+                          conflictList[0]->text( 0 ) + "\"" );
         warning->show();
         buttonBox->show();
 
index 99aea1c..9baadb8 100644 (file)
@@ -434,6 +434,7 @@ signals:
     void pressed();
 };
 
+class SearchLineEdit;
 class KeySelectorControl : public ConfigControl
 {
     Q_OBJECT;
@@ -451,10 +452,12 @@ private:
     QTreeWidget *table;
     KeyShortcutEdit *shortcutValue;
     QList<module_config_t *> values;
+    SearchLineEdit *actionSearch;
 private slots:
     void setTheKey();
     void selectKey( QTreeWidgetItem * = NULL );
     void select1Key();
+    void filter( const QString & );
 };
 
 class KeyInputDialog : public QDialog