remove BIMGroupProperties.is_adding attribute to avoid confusion

The problem with that attribute was that object's and project's group ui section were both using groups loaded to BIMGroupProperties.groups.

So you could run into situation when you try to load object's groups ui and it would show empty list because user never loaded the groups from the project's ui...

So it was either caching groups twice or just using same `is_editing` flag to check whether groups were previously loaded and I went with the single flag.
This commit is contained in:
Andrej730
2023-11-08 15:09:17 +05:00
parent c0d8467154
commit ebfc8ef619
4 changed files with 3 additions and 15 deletions
@@ -29,7 +29,6 @@ classes = (
operator.LoadGroups,
operator.RemoveGroup,
operator.SelectGroupProducts,
operator.ToggleAssigningGroup,
operator.ToggleGroup,
operator.UnassignGroup,
operator.UpdateGroup,
@@ -173,16 +173,6 @@ class DisableEditingGroup(bpy.types.Operator, tool.Ifc.Operator):
return {"FINISHED"}
class ToggleAssigningGroup(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.toggle_assigning_group"
bl_label = "Toggle Assigning Group"
bl_options = {"REGISTER", "UNDO"}
def _execute(self, context):
context.scene.BIMGroupProperties.is_adding = not context.scene.BIMGroupProperties.is_adding
return {"FINISHED"}
class AssignGroup(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.assign_group"
bl_label = "Assign Group"
@@ -49,7 +49,6 @@ class Group(PropertyGroup):
class BIMGroupProperties(PropertyGroup):
group_attributes: CollectionProperty(name="Group Attributes", type=Attribute)
is_editing: BoolProperty(name="Is Editing", default=False)
is_adding: BoolProperty(name="Is Adding", default=False)
groups: CollectionProperty(name="Groups", type=Group)
active_group_index: IntProperty(name="Active Group Index")
active_group_id: IntProperty(name="Active Group Id")
@@ -89,9 +89,9 @@ class BIM_PT_object_groups(Panel):
ObjectGroupsData.load()
self.props = context.scene.BIMGroupProperties
row = self.layout.row(align=True)
if self.props.is_adding:
if self.props.is_editing:
row.label(text="Adding Groups", icon="OUTLINER")
row.operator("bim.toggle_assigning_group", text="", icon="CANCEL")
row.operator("bim.disable_group_editing_ui", text="", icon="CANCEL")
self.layout.template_list(
"BIM_UL_object_groups",
"",
@@ -102,7 +102,7 @@ class BIM_PT_object_groups(Panel):
)
else:
row.label(text=f"{ObjectGroupsData.data['total_groups']} Groups in IFC Project", icon="OUTLINER")
row.operator("bim.toggle_assigning_group", text="", icon="ADD")
row.operator("bim.load_groups", text="", icon="GREASEPENCIL")
for group in ObjectGroupsData.data["groups"]:
row = self.layout.row(align=True)