def _isDefinitionVisible(self, definition: SettingDefinition, **kwargs: Any) -> bool: key = definition.key # If it is in the list of things to exclude it is never going to be visible. if key in self._exclude: return False # If any of its ancestors is in the list of things to exclude it also should never be visible. if definition.getAncestors() & self._exclude: return False # If its parent is not expanded we should not show the setting. if definition.parent and not definition.parent.key in self._expanded: return False # If it is not marked as visible we do not have to show it. if not self._show_all and key not in self._visible: return False # If it does not match the current filter, it should not be shown. filter = self._filter_dict.copy() filter["i18n_catalog"] = self._i18n_catalog if self._filter_dict and not definition.matchesFilter(**filter): if self._show_ancestors: if self._isAnyDescendantFiltered(definition): return True return False # We should not show categories that are empty if definition.type == "category": if not self._isAnyDescendantVisible(definition): return False return True