Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
9b80d194
Commit
9b80d194
authored
Jul 26, 2011
by
Yuval Tze
Committed by
Francois Cartegnie
Jul 29, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: Preferences tree filter
add filter function to expand and show matched tree items and hide the rest
parent
a27faa4c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
+72
-0
modules/gui/qt4/components/complete_preferences.cpp
modules/gui/qt4/components/complete_preferences.cpp
+69
-0
modules/gui/qt4/components/complete_preferences.hpp
modules/gui/qt4/components/complete_preferences.hpp
+3
-0
No files found.
modules/gui/qt4/components/complete_preferences.cpp
View file @
9b80d194
...
...
@@ -343,6 +343,75 @@ void PrefsTree::doAll( bool doclean )
}
}
/* apply filter on tree item and recursively on its sub items
* returns whether the item was filtered */
bool
PrefsTree
::
filterItems
(
QTreeWidgetItem
*
item
,
const
QString
&
text
,
Qt
::
CaseSensitivity
cs
)
{
bool
sub_filtered
=
true
;
for
(
int
i
=
0
;
i
<
item
->
childCount
();
i
++
)
{
QTreeWidgetItem
*
sub_item
=
item
->
child
(
i
);
if
(
!
filterItems
(
sub_item
,
text
,
cs
)
)
{
/* not all the sub items were filtered */
sub_filtered
=
false
;
}
}
PrefsItemData
*
data
=
item
->
data
(
0
,
Qt
::
UserRole
).
value
<
PrefsItemData
*>
();
bool
filtered
=
sub_filtered
&&
!
data
->
contains
(
text
,
cs
);
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
(
QTreeWidgetItem
*
item
)
{
bool
sub_collapsed
=
true
;
for
(
int
i
=
0
;
i
<
item
->
childCount
();
i
++
)
{
QTreeWidgetItem
*
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
;
}
/* apply filter on tree */
void
PrefsTree
::
filter
(
const
QString
&
text
)
{
bool
clear_filter
=
text
.
isEmpty
();
for
(
int
i
=
0
;
i
<
topLevelItemCount
();
i
++
)
{
QTreeWidgetItem
*
cat_item
=
topLevelItem
(
i
);
if
(
clear_filter
)
{
collapseUnselectedItems
(
cat_item
);
}
else
{
filterItems
(
cat_item
,
text
,
Qt
::
CaseInsensitive
);
}
}
}
/* go over the module config items and search text in psz_text
* also search the module name and head */
bool
PrefsItemData
::
contains
(
const
QString
&
text
,
Qt
::
CaseSensitivity
cs
)
...
...
modules/gui/qt4/components/complete_preferences.hpp
View file @
9b80d194
...
...
@@ -72,9 +72,12 @@ public:
void
applyAll
();
void
cleanAll
();
void
filter
(
const
QString
&
text
);
private:
void
doAll
(
bool
);
bool
filterItems
(
QTreeWidgetItem
*
item
,
const
QString
&
text
,
Qt
::
CaseSensitivity
cs
);
bool
collapseUnselectedItems
(
QTreeWidgetItem
*
item
);
intf_thread_t
*
p_intf
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment