[vlc-commits] Qt: hotkeys: allow filtering by field (fix #7931)

Francois Cartegnie git at videolan.org
Sat Dec 22 17:24:30 CET 2012


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Dec 22 17:17:13 2012 +0100| [28d465e81563ca495d1466a60451c743e3f69791] | committer: Francois Cartegnie

Qt: hotkeys: allow filtering by field (fix #7931)

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

 modules/gui/qt4/components/preferences_widgets.cpp |   30 ++++++++++++++++----
 modules/gui/qt4/components/preferences_widgets.hpp |    5 +++-
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/modules/gui/qt4/components/preferences_widgets.cpp b/modules/gui/qt4/components/preferences_widgets.cpp
index 77302a7..14e7366 100644
--- a/modules/gui/qt4/components/preferences_widgets.cpp
+++ b/modules/gui/qt4/components/preferences_widgets.cpp
@@ -1134,8 +1134,15 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
     searchLabel = new QLabel( qtr( "Search" ), p );
     actionSearch = new SearchLineEdit();
 
+    searchOptionLabel = new QLabel( qtr("in") );
+    searchOption = new QComboBox();
+    searchOption->addItem( qtr("Any field"), ANY_COL );
+    searchOption->addItem( qtr("Actions"), ACTION_COL );
+    searchOption->addItem( qtr("Hotkeys"), HOTKEY_COL );
+    searchOption->addItem( qtr("Global Hotkeys"), GLOBAL_HOTKEY_COL );
+
     table = new QTreeWidget( p );
-    table->setColumnCount(3);
+    table->setColumnCount( ANY_COL );
     table->headerItem()->setText( ACTION_COL, qtr( "Action" ) );
     table->headerItem()->setText( HOTKEY_COL, qtr( "Hotkey" ) );
     table->headerItem()->setToolTip( HOTKEY_COL, qtr( "Application level hotkey" ) );
@@ -1161,10 +1168,12 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
 void KeySelectorControl::fillGrid( QGridLayout *l, int line )
 {
     QGridLayout *gLayout = new QGridLayout();
-    gLayout->addWidget( label, 0, 0, 1, 4 );
+    gLayout->addWidget( label, 0, 0, 1, 5 );
     gLayout->addWidget( searchLabel, 1, 0, 1, 2 );
-    gLayout->addWidget( actionSearch, 1, 2, 1, 2 );
-    gLayout->addWidget( table, 2, 0, 1, 4 );
+    gLayout->addWidget( actionSearch, 1, 2, 1, 1 );
+    gLayout->addWidget( searchOptionLabel, 1, 3, 1, 1 );
+    gLayout->addWidget( searchOption, 1, 4, 1, 1 );
+    gLayout->addWidget( table, 2, 0, 1, 5 );
     l->addLayout( gLayout, line, 0, 1, -1 );
 }
 
@@ -1264,8 +1273,17 @@ void KeySelectorControl::finish()
 
 void KeySelectorControl::filter( const QString &qs_search )
 {
-    QList<QTreeWidgetItem *> resultList =
-            table->findItems( qs_search, Qt::MatchContains, ACTION_COL );
+    int i_column = searchOption->itemData( searchOption->currentIndex() ).toInt();
+    QList<QTreeWidgetItem *> resultList;
+    if ( i_column == ANY_COL )
+    {
+        for( int i = 0; i < ANY_COL; i++ )
+            resultList << table->findItems( qs_search, Qt::MatchContains, i );
+    }
+    else
+    {
+        resultList = table->findItems( qs_search, Qt::MatchContains, i_column );
+    }
     for( int i = 0; i < table->topLevelItemCount(); i++ )
     {
         table->topLevelItem( i )->setHidden(
diff --git a/modules/gui/qt4/components/preferences_widgets.hpp b/modules/gui/qt4/components/preferences_widgets.hpp
index 47391cf..dee0c78 100644
--- a/modules/gui/qt4/components/preferences_widgets.hpp
+++ b/modules/gui/qt4/components/preferences_widgets.hpp
@@ -507,6 +507,8 @@ private:
     QLabel *label;
     QLabel *searchLabel;
     SearchLineEdit *actionSearch;
+    QComboBox *searchOption;
+    QLabel *searchOptionLabel;
     QTreeWidget *table;
     QList<module_config_t *> values;
     QSet<QString> existingkeys;
@@ -514,7 +516,8 @@ private:
     {
         ACTION_COL = 0,
         HOTKEY_COL = 1,
-        GLOBAL_HOTKEY_COL = 2
+        GLOBAL_HOTKEY_COL = 2,
+        ANY_COL = 3 // == count()
     };
 
 private slots:



More information about the vlc-commits mailing list