Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Inch <mythologylover75@gmail.com>2020-10-20 10:08:47 +0300
committerRyan Inch <mythologylover75@gmail.com>2020-10-20 10:08:47 +0300
commitb66e1363a07d7945efb0aa470a031bb18eaedf0f (patch)
tree4db31398ee6a5ad0a8e981df9b472897a7d95f5c
parent52fb8e51ac81d21c62d85b63500a7b7ea3213193 (diff)
Collection Manager: Improve filtering 2. Task: T69577
Allow filters to be combined with each other.
-rw-r--r--object_collection_manager/__init__.py2
-rw-r--r--object_collection_manager/ui.py48
2 files changed, 35 insertions, 15 deletions
diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py
index 7c33c0e1..1439be2f 100644
--- a/object_collection_manager/__init__.py
+++ b/object_collection_manager/__init__.py
@@ -22,7 +22,7 @@ bl_info = {
"name": "Collection Manager",
"description": "Manage collections and their objects",
"author": "Ryan Inch",
- "version": (2, 16, 0),
+ "version": (2, 17, 0),
"blender": (2, 80, 0),
"location": "View3D - Object Mode (Shortcut - M)",
"warning": '', # used for warning icon and text in addons panel
diff --git a/object_collection_manager/ui.py b/object_collection_manager/ui.py
index 4e1cd2d8..a32f33c9 100644
--- a/object_collection_manager/ui.py
+++ b/object_collection_manager/ui.py
@@ -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