[vlc-commits] [Git][videolan/vlc][master] qt: adjust advanced prefs tree filtering behaviour
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Tue Mar 1 08:56:25 UTC 2022
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
40a4b4b4 by Lyndon Brown at 2022-03-01T07:35:40+00:00
qt: adjust advanced prefs tree filtering behaviour
The previous behaviour upon filter change was that:
- If the search string was not empty then everything visible was expanded.
- If empty, then everything would be collapsed except the selected node.
This is rather annoying IMO, for instance - from a default starting state
where top-level nodes are expanded and 2nd-level collapsed, if you apply a
filter and then subsequently remove it, you annoyingly end up with more
collapsed than you started with.
I feel that it works much better to just leave the expanded/collapsed state
untouched, preserving the initial state and any changes the user has made
before/after filtering, even though this forces users to expand any
2nd-level filter results they are interested in for themselves. It's also
much more simple.
- - - - -
2 changed files:
- modules/gui/qt/dialogs/preferences/complete_preferences.cpp
- modules/gui/qt/dialogs/preferences/complete_preferences.hpp
Changes:
=====================================
modules/gui/qt/dialogs/preferences/complete_preferences.cpp
=====================================
@@ -323,33 +323,16 @@ bool PrefsTree::filterItems( PrefsTreeItem *item, const QString &text,
bool filtered = sub_filtered && !item->contains( text, cs );
if ( b_show_only_loaded && sub_filtered && !item->module_is_loaded )
filtered = true;
- item->setExpanded( !sub_filtered );
item->setHidden( filtered );
return filtered;
}
-/* collapse item if it's not selected or one of its sub items
- * returns whether the item was collapsed */
-bool PrefsTree::collapseUnselectedItems( PrefsTreeItem *item )
+void PrefsTree::unfilterItems( PrefsTreeItem *item )
{
- bool sub_collapsed = true;
-
- for( int i = 0; i < item->childCount(); i++ )
- {
- PrefsTreeItem *sub_item = item->child( i );
- if ( !collapseUnselectedItems( sub_item ) )
- {
- /* not all the sub items were collapsed */
- sub_collapsed = false;
- }
- }
-
- bool collapsed = sub_collapsed && !item->isSelected();
- item->setExpanded( !sub_collapsed );
item->setHidden( false );
-
- return collapsed;
+ for( int i = 0; i < item->childCount(); i++ )
+ unfilterItems( item->child( i ) );
}
static void populateLoadedSet( QSet<QString> *loaded, vlc_object_t *p_node )
@@ -424,13 +407,9 @@ void PrefsTree::filter( const QString &text )
{
PrefsTreeItem *cat_item = topLevelItem( i );
if ( clear_filter )
- {
- collapseUnselectedItems( cat_item );
- }
+ unfilterItems( cat_item );
else
- {
filterItems( cat_item, text, Qt::CaseInsensitive );
- }
}
}
=====================================
modules/gui/qt/dialogs/preferences/complete_preferences.hpp
=====================================
@@ -106,7 +106,7 @@ private:
QTreeWidgetItem *findCatItem( enum vlc_config_cat cat );
QTreeWidgetItem *findSubcatItem( enum vlc_config_subcat subcat );
bool filterItems( PrefsTreeItem *item, const QString &text, Qt::CaseSensitivity cs );
- bool collapseUnselectedItems( PrefsTreeItem *item );
+ void unfilterItems( PrefsTreeItem *item );
void updateLoadedStatus( PrefsTreeItem *item , QSet<QString> *loaded );
qt_intf_t *p_intf;
module_t *main_module;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/40a4b4b4a9bbdd70fcbc4f491bc86051fe23162a
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/40a4b4b4a9bbdd70fcbc4f491bc86051fe23162a
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list