[Bf-extensions-cvs] [14bbd42f] master: Collection Manager: Refactor. Task: T69577

Ryan Inch noreply at git.blender.org
Tue Aug 11 06:53:35 CEST 2020


Commit: 14bbd42ff2abb7c480b373a88817095bf8c2ad4c
Author: Ryan Inch
Date:   Tue Aug 11 00:51:28 2020 -0400
Branches: master
https://developer.blender.org/rBA14bbd42ff2abb7c480b373a88817095bf8c2ad4c

Collection Manager: Refactor. Task: T69577

Change detection of the master collection from an ambiguous index
to an is_master_collection boolean.

===================================================================

M	object_collection_manager/__init__.py
M	object_collection_manager/operator_utils.py
M	object_collection_manager/operators.py
M	object_collection_manager/qcd_operators.py
M	object_collection_manager/ui.py

===================================================================

diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py
index d7b312a5..e5f6a9ec 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, 14, 0),
+    "version": (2, 14, 1),
     "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/operator_utils.py b/object_collection_manager/operator_utils.py
index 6f7ee83b..20c7dee7 100644
--- a/object_collection_manager/operator_utils.py
+++ b/object_collection_manager/operator_utils.py
@@ -469,8 +469,8 @@ def remove_collection(laycol, collection, context):
             cm.cm_list_index = laycol["row_index"]
 
 
-def select_collection_objects(collection_index, collection_name, replace, nested):
-    if collection_index == 0:
+def select_collection_objects(is_master_collection, collection_name, replace, nested):
+    if is_master_collection:
         target_collection = bpy.context.view_layer.layer_collection.collection
 
     else:
diff --git a/object_collection_manager/operators.py b/object_collection_manager/operators.py
index ff1bbf95..1e265e52 100644
--- a/object_collection_manager/operators.py
+++ b/object_collection_manager/operators.py
@@ -74,11 +74,11 @@ class SetActiveCollection(Operator):
     bl_idname = "view3d.set_active_collection"
     bl_options = {'UNDO'}
 
-    collection_index: IntProperty()
+    is_master_collection: BoolProperty()
     collection_name: StringProperty()
 
     def execute(self, context):
-        if self.collection_index == -1:
+        if self.is_master_collection:
             layer_collection = context.view_layer.layer_collection
 
         else:
@@ -227,7 +227,7 @@ class CMSelectCollectionObjectsOperator(Operator):
     bl_idname = "view3d.select_collection_objects"
     bl_options = {'REGISTER', 'UNDO'}
 
-    collection_index: IntProperty()
+    is_master_collection: BoolProperty()
     collection_name: StringProperty()
 
     def invoke(self, context, event):
@@ -235,7 +235,7 @@ class CMSelectCollectionObjectsOperator(Operator):
 
         if modifiers == {"shift"}:
             select_collection_objects(
-                collection_index=self.collection_index,
+                is_master_collection=self.is_master_collection,
                 collection_name=self.collection_name,
                 replace=False,
                 nested=False
@@ -243,7 +243,7 @@ class CMSelectCollectionObjectsOperator(Operator):
 
         elif modifiers == {"ctrl"}:
             select_collection_objects(
-                collection_index=self.collection_index,
+                is_master_collection=self.is_master_collection,
                 collection_name=self.collection_name,
                 replace=True,
                 nested=True
@@ -251,7 +251,7 @@ class CMSelectCollectionObjectsOperator(Operator):
 
         elif modifiers == {"ctrl", "shift"}:
             select_collection_objects(
-                collection_index=self.collection_index,
+                is_master_collection=self.is_master_collection,
                 collection_name=self.collection_name,
                 replace=False,
                 nested=True
@@ -259,7 +259,7 @@ class CMSelectCollectionObjectsOperator(Operator):
 
         else:
             select_collection_objects(
-                collection_index=self.collection_index,
+                is_master_collection=self.is_master_collection,
                 collection_name=self.collection_name,
                 replace=True,
                 nested=False
@@ -277,11 +277,11 @@ class CMSetCollectionOperator(Operator):
     bl_idname = "view3d.set_collection"
     bl_options = {'REGISTER', 'UNDO'}
 
-    collection_index: IntProperty()
+    is_master_collection: BoolProperty()
     collection_name: StringProperty()
 
     def invoke(self, context, event):
-        if self.collection_index == 0:
+        if self.is_master_collection:
             target_collection = context.view_layer.layer_collection.collection
 
         else:
diff --git a/object_collection_manager/qcd_operators.py b/object_collection_manager/qcd_operators.py
index 4ffec562..b64c87f8 100644
--- a/object_collection_manager/qcd_operators.py
+++ b/object_collection_manager/qcd_operators.py
@@ -166,7 +166,7 @@ class ViewMoveQCDSlot(Operator):
 
         elif modifiers == {"alt"}:
             select_collection_objects(
-                collection_index=None,
+                is_master_collection=False,
                 collection_name=qcd_slots.get_name(self.slot),
                 replace=True,
                 nested=False
@@ -174,7 +174,7 @@ class ViewMoveQCDSlot(Operator):
 
         elif modifiers == {"alt", "shift"}:
             select_collection_objects(
-                collection_index=None,
+                is_master_collection=False,
                 collection_name=qcd_slots.get_name(self.slot),
                 replace=False,
                 nested=False
diff --git a/object_collection_manager/ui.py b/object_collection_manager/ui.py
index 0f2703cb..4c1eb077 100644
--- a/object_collection_manager/ui.py
+++ b/object_collection_manager/ui.py
@@ -159,7 +159,7 @@ class CollectionManager(Operator):
 
         prop = c_icon.operator("view3d.set_active_collection",
                                               text='', icon='GROUP', depress=highlight)
-        prop.collection_index = -1
+        prop.is_master_collection = True
         prop.collection_name = 'Master Collection'
 
         master_collection_row.separator()
@@ -200,7 +200,7 @@ class CollectionManager(Operator):
 
         prop = row_setcol.operator("view3d.set_collection", text="",
                                    icon=icon, emboss=False)
-        prop.collection_index = 0
+        prop.is_master_collection = True
         prop.collection_name = 'Master Collection'
 
         copy_icon = 'COPYDOWN'
@@ -559,7 +559,7 @@ class CM_UL_items(UIList):
         prop = c_icon.operator("view3d.set_active_collection", text='', icon='GROUP',
                                               emboss=highlight, depress=highlight)
 
-        prop.collection_index = laycol["row_index"]
+        prop.is_master_collection = False
         prop.collection_name = item.name
 
         if prefs.enable_qcd:
@@ -599,7 +599,7 @@ class CM_UL_items(UIList):
 
         prop = set_obj_col.operator("view3d.set_collection", text="",
                                    icon=icon, emboss=False)
-        prop.collection_index = laycol["id"]
+        prop.is_master_collection = False
         prop.collection_name = item.name



More information about the Bf-extensions-cvs mailing list