Added support for deleting empty groups from the property bag's group tracking.
This commit is contained in:
@@ -72,7 +72,7 @@ class PropertyBag(object):
|
||||
obj.setEditorMode(self.CustomPropertyGroups, 2) # hide
|
||||
|
||||
def getCustomProperties(self):
|
||||
'''Return a list of all custom properties created in this container.'''
|
||||
'''getCustomProperties() ... Return a list of all custom properties created in this container.'''
|
||||
return [p for p in self.obj.PropertiesList if self.obj.getGroupOfProperty(p) in self.obj.CustomPropertyGroups]
|
||||
|
||||
def addCustomProperty(self, propertyType, name, group=None, desc=None):
|
||||
@@ -87,6 +87,16 @@ class PropertyBag(object):
|
||||
self.obj.CustomPropertyGroups = groups
|
||||
self.obj.addProperty(propertyType, name, group, desc)
|
||||
|
||||
def refreshCustomPropertyGroups(self):
|
||||
'''refreshCustomPropertyGroups() ... removes empty property groups, should be called after deleting properties.'''
|
||||
customGroups = []
|
||||
for p in self.obj.PropertiesList:
|
||||
group = self.obj.getGroupOfProperty(p)
|
||||
if group in self.obj.CustomPropertyGroups and not group in customGroups:
|
||||
customGroups.append(group)
|
||||
self.obj.CustomPropertyGroups = customGroups
|
||||
|
||||
|
||||
def Create(name = 'PropertyBag'):
|
||||
obj = FreeCAD.ActiveDocument.addObject('App::FeaturePython', name)
|
||||
obj.Proxy = PropertyBag(obj)
|
||||
|
||||
@@ -130,6 +130,7 @@ class PropertyCreate(object):
|
||||
self.obj = obj
|
||||
self.form = FreeCADGui.PySideUic.loadUi(":panels/PropertyCreate.ui")
|
||||
|
||||
obj.Proxy.refreshCustomPropertyGroups()
|
||||
for g in sorted(obj.CustomPropertyGroups):
|
||||
self.form.propertyGroup.addItem(g)
|
||||
if grp:
|
||||
|
||||
Reference in New Issue
Block a user