Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
b66e1363
Commit
b66e1363
authored
4 years ago
by
Ryan Inch
Browse files
Options
Downloads
Patches
Plain Diff
Collection Manager: Improve filtering 2. Task: T69577
Allow filters to be combined with each other.
parent
52fb8e51
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
object_collection_manager/__init__.py
+1
-1
1 addition, 1 deletion
object_collection_manager/__init__.py
object_collection_manager/ui.py
+34
-14
34 additions, 14 deletions
object_collection_manager/ui.py
with
35 additions
and
15 deletions
object_collection_manager/__init__.py
+
1
−
1
View file @
b66e1363
...
...
@@ -22,7 +22,7 @@ bl_info = {
"
name
"
:
"
Collection Manager
"
,
"
description
"
:
"
Manage collections and their objects
"
,
"
author
"
:
"
Ryan Inch
"
,
"
version
"
:
(
2
,
1
6
,
0
),
"
version
"
:
(
2
,
1
7
,
0
),
"
blender
"
:
(
2
,
80
,
0
),
"
location
"
:
"
View3D - Object Mode (Shortcut - M)
"
,
"
warning
"
:
''
,
# used for warning icon and text in addons panel
...
...
This diff is collapsed.
Click to expand it.
object_collection_manager/ui.py
+
34
−
14
View file @
b66e1363
...
...
@@ -772,44 +772,56 @@ class CM_UL_items(UIList):
subrow
.
prop
(
self
,
"
filter_by_qcd
"
,
text
=
""
,
icon
=
'
EVENT_Q
'
)
def
filter_items
(
self
,
context
,
data
,
propname
):
CM_UL_items
.
filtering
=
True
CM_UL_items
.
filtering
=
False
flt_flags
=
[]
flt_neworder
=
[]
list_items
=
getattr
(
data
,
propname
)
if
self
.
filter_name
:
flt_flags
=
filter_items_by_name_custom
(
self
.
filter_name
,
self
.
bitflag_filter_item
,
list_items
)
CM_UL_items
.
filtering
=
True
new_flt_flags
=
filter_items_by_name_custom
(
self
.
filter_name
,
self
.
bitflag_filter_item
,
list_items
)
elif
self
.
filter_by_selected
:
flt_flags
=
[
0
]
*
len
(
list_items
)
flt_flags
=
merge_flt_flags
(
flt_flags
,
new_flt_flags
)
if
self
.
filter_by_selected
:
CM_UL_items
.
filtering
=
True
new_flt_flags
=
[
0
]
*
len
(
list_items
)
for
idx
,
item
in
enumerate
(
list_items
):
collection
=
layer_collections
[
item
.
name
][
"
ptr
"
].
collection
# check if any of the selected objects are in the collection
if
not
set
(
context
.
selected_objects
).
isdisjoint
(
collection
.
objects
):
flt_flags
[
idx
]
|
=
self
.
bitflag_filter_item
new_
flt_flags
[
idx
]
=
self
.
bitflag_filter_item
# add in any recently created collections
if
item
.
name
in
CM_UL_items
.
new_collections
:
flt_flags
[
idx
]
|=
self
.
bitflag_filter_item
new_flt_flags
[
idx
]
=
self
.
bitflag_filter_item
flt_flags
=
merge_flt_flags
(
flt_flags
,
new_flt_flags
)
elif
self
.
filter_by_qcd
:
flt_flags
=
[
0
]
*
len
(
list_items
)
if
self
.
filter_by_qcd
:
CM_UL_items
.
filtering
=
True
new_flt_flags
=
[
0
]
*
len
(
list_items
)
for
idx
,
item
in
enumerate
(
list_items
):
if
item
.
qcd_slot_idx
:
flt_flags
[
idx
]
|
=
self
.
bitflag_filter_item
new_
flt_flags
[
idx
]
=
self
.
bitflag_filter_item
# add in any recently created collections
if
item
.
name
in
CM_UL_items
.
new_collections
:
flt_flags
[
idx
]
|
=
self
.
bitflag_filter_item
new_
flt_flags
[
idx
]
=
self
.
bitflag_filter_item
else
:
# display as treeview
CM_UL_items
.
filtering
=
False
CM_UL_items
.
new_collections
.
clear
()
flt_flags
=
merge_flt_flags
(
flt_flags
,
new_flt_flags
)
if
not
CM_UL_items
.
filtering
:
# display as treeview
CM_UL_items
.
new_collections
.
clear
()
flt_flags
=
[
self
.
bitflag_filter_item
]
*
len
(
list_items
)
for
idx
,
item
in
enumerate
(
list_items
):
...
...
@@ -817,9 +829,11 @@ class CM_UL_items(UIList):
flt_flags
[
idx
]
=
0
if
self
.
use_filter_invert
:
CM_UL_items
.
filtering
=
True
# invert can act as pseudo filtering
for
idx
,
flag
in
enumerate
(
flt_flags
):
flt_flags
[
idx
]
=
0
if
flag
else
self
.
bitflag_filter_item
# update visible items list
CM_UL_items
.
visible_items
.
clear
()
CM_UL_items
.
visible_items
.
extend
(
flt_flags
)
...
...
@@ -1107,3 +1121,9 @@ def filter_items_by_name_custom(pattern, bitflag, items, propname="name", flags=
flags
[
i
]
|=
bitflag
return
flags
def
merge_flt_flags
(
l1
,
l2
):
for
idx
,
_
in
enumerate
(
l1
):
l1
[
idx
]
&=
l2
.
pop
(
0
)
return
l1
+
l2
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment