Commit 28d465e8 authored by Francois Cartegnie's avatar Francois Cartegnie

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

parent bfcafac5
...@@ -1134,8 +1134,15 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this, ...@@ -1134,8 +1134,15 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
searchLabel = new QLabel( qtr( "Search" ), p ); searchLabel = new QLabel( qtr( "Search" ), p );
actionSearch = new SearchLineEdit(); 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 = new QTreeWidget( p );
table->setColumnCount(3); table->setColumnCount( ANY_COL );
table->headerItem()->setText( ACTION_COL, qtr( "Action" ) ); table->headerItem()->setText( ACTION_COL, qtr( "Action" ) );
table->headerItem()->setText( HOTKEY_COL, qtr( "Hotkey" ) ); table->headerItem()->setText( HOTKEY_COL, qtr( "Hotkey" ) );
table->headerItem()->setToolTip( HOTKEY_COL, qtr( "Application level hotkey" ) ); table->headerItem()->setToolTip( HOTKEY_COL, qtr( "Application level hotkey" ) );
...@@ -1161,10 +1168,12 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this, ...@@ -1161,10 +1168,12 @@ KeySelectorControl::KeySelectorControl( vlc_object_t *_p_this,
void KeySelectorControl::fillGrid( QGridLayout *l, int line ) void KeySelectorControl::fillGrid( QGridLayout *l, int line )
{ {
QGridLayout *gLayout = new QGridLayout(); 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( searchLabel, 1, 0, 1, 2 );
gLayout->addWidget( actionSearch, 1, 2, 1, 2 ); gLayout->addWidget( actionSearch, 1, 2, 1, 1 );
gLayout->addWidget( table, 2, 0, 1, 4 ); 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 ); l->addLayout( gLayout, line, 0, 1, -1 );
} }
...@@ -1264,8 +1273,17 @@ void KeySelectorControl::finish() ...@@ -1264,8 +1273,17 @@ void KeySelectorControl::finish()
void KeySelectorControl::filter( const QString &qs_search ) void KeySelectorControl::filter( const QString &qs_search )
{ {
QList<QTreeWidgetItem *> resultList = int i_column = searchOption->itemData( searchOption->currentIndex() ).toInt();
table->findItems( qs_search, Qt::MatchContains, ACTION_COL ); 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++ ) for( int i = 0; i < table->topLevelItemCount(); i++ )
{ {
table->topLevelItem( i )->setHidden( table->topLevelItem( i )->setHidden(
......
...@@ -507,6 +507,8 @@ private: ...@@ -507,6 +507,8 @@ private:
QLabel *label; QLabel *label;
QLabel *searchLabel; QLabel *searchLabel;
SearchLineEdit *actionSearch; SearchLineEdit *actionSearch;
QComboBox *searchOption;
QLabel *searchOptionLabel;
QTreeWidget *table; QTreeWidget *table;
QList<module_config_t *> values; QList<module_config_t *> values;
QSet<QString> existingkeys; QSet<QString> existingkeys;
...@@ -514,7 +516,8 @@ private: ...@@ -514,7 +516,8 @@ private:
{ {
ACTION_COL = 0, ACTION_COL = 0,
HOTKEY_COL = 1, HOTKEY_COL = 1,
GLOBAL_HOTKEY_COL = 2 GLOBAL_HOTKEY_COL = 2,
ANY_COL = 3 // == count()
}; };
private slots: private slots:
......
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