added any_parent_as_widget attribute

This commit is contained in:
iLLiCiTiT 2020-09-17 19:23:14 +02:00
parent c88e48f1af
commit 3544d81905

View file

@ -46,6 +46,7 @@ class SettingObject:
self._as_widget = False
self._is_group = False
self._any_parent_as_widget = None
self._any_parent_is_group = None
# Parent input
@ -81,6 +82,12 @@ class SettingObject:
# TODO not implemented yet
self._is_nullable = input_data.get("is_nullable", False)
any_parent_as_widget = parent.as_widget
if not any_parent_as_widget:
any_parent_as_widget = parent.any_parent_as_widget
self._any_parent_as_widget = any_parent_as_widget
any_parent_is_group = parent.is_group
if not any_parent_is_group:
any_parent_is_group = parent.any_parent_is_group
@ -130,6 +137,34 @@ class SettingObject:
"""
return self._has_studio_override or self._parent.has_studio_override
@property
def as_widget(self):
"""Item is used as widget in parent item.
Returns:
bool
"""
return self._as_widget
@property
def any_parent_as_widget(self):
"""Any parent of item is used as widget.
Attribute holding this information is set during creation and
stored to `_any_parent_as_widget`.
Why is this information useful: If any parent is used as widget then
modifications and override are not important for whole part.
Returns:
bool
"""
if self._any_parent_as_widget is None:
return super(SettingObject, self).any_parent_as_widget
return self._any_parent_as_widget
@property
def is_group(self):
"""Item represents key that can be overriden.