Skip to content

tab_datasource

freecad.datamanager_wb.domain.tab_datasource

Tab data source protocol used by the generic tab controller.

Defines the TabDataSource protocol along with shared dataclasses used for remove-unused operations across different tabs (VarSets and Aliases).

PostRemoveUpdate(child_items, clear_expressions) dataclass

UI update instructions after a remove-unused mutation.

The generic controller computes a new list of child items (after filtering) and whether the expressions list should be cleared.

Attributes:

Name Type Description
child_items list[ParentChildRef]

The filtered list of child refs that should be shown.

clear_expressions bool

Whether the expressions list should be cleared.

child_items instance-attribute

clear_expressions instance-attribute

RemoveUnusedAndUpdateResult(remove_result, update) dataclass

Combined remove result and follow-up UI update.

remove_result instance-attribute

update instance-attribute

RemoveUnusedResult(removed, still_used, failed) dataclass

Outcome of a remove-unused operation.

Attributes:

Name Type Description
removed list[str]

Child identifiers that were removed successfully.

still_used list[str]

Child identifiers that were not removed because they were found to still have expression references.

failed list[str]

Child identifiers that could not be removed due to parsing, document errors, or other failures.

failed instance-attribute

removed instance-attribute

still_used instance-attribute

TabDataSource

Protocol implemented by each tab's data backend.

The TabController is pure, tab-generic logic. It depends on this protocol to obtain parents/children, compute expression references, and perform the remove-unused mutation.

Implementations should treat string child identifiers as the canonical Parent.Child form used by the UI.

get_child_refs(selected_parents)

Return all child refs for the given selected parents.

Source code in freecad/datamanager_wb/domain/tab_datasource.py
def get_child_refs(self, selected_parents: list[str]) -> list[ParentChildRef]:
    """Return all child refs for the given selected parents."""
    raise NotImplementedError

get_expression_items(selected_children)

Return expression items and per-child reference counts.

Returns:

Type Description
list[ExpressionItem]

A tuple of:

dict[str, int]
  • List of ExpressionItem objects suitable for populating the UI.
tuple[list[ExpressionItem], dict[str, int]]
  • Dict mapping each selected child identifier to a reference count.
Source code in freecad/datamanager_wb/domain/tab_datasource.py
def get_expression_items(
    self, selected_children: list[ParentChildRef] | list[str]
) -> tuple[list[ExpressionItem], dict[str, int]]:
    """Return expression items and per-child reference counts.

    Returns:
        A tuple of:
        - List of `ExpressionItem` objects suitable for populating the UI.
        - Dict mapping each selected child identifier to a reference count.
    """
    raise NotImplementedError

get_expression_reference_counts(selected_children)

Return only the reference counts for selected children.

Source code in freecad/datamanager_wb/domain/tab_datasource.py
def get_expression_reference_counts(
    self, selected_children: list[ParentChildRef] | list[str]
) -> dict[str, int]:
    """Return only the reference counts for selected children."""
    raise NotImplementedError

get_sorted_parents(*, exclude_copy_on_change=False)

Return parent names sorted for display.

Parameters:

Name Type Description Default
exclude_copy_on_change bool

Whether to filter out parents that belong to copy-on-change groups (domain-specific).

False
Source code in freecad/datamanager_wb/domain/tab_datasource.py
def get_sorted_parents(self, *, exclude_copy_on_change: bool = False) -> list[str]:
    """Return parent names sorted for display.

    Args:
        exclude_copy_on_change: Whether to filter out parents that belong to
            copy-on-change groups (domain-specific).
    """
    raise NotImplementedError

remove_unused_children(selected_children)

Remove the selected children if they are unused.

Implementations must not remove items that still have expression references.

Source code in freecad/datamanager_wb/domain/tab_datasource.py
def remove_unused_children(
    self, selected_children: list[ParentChildRef] | list[str]
) -> RemoveUnusedResult:
    """Remove the selected children if they are unused.

    Implementations must not remove items that still have expression
    references.
    """
    raise NotImplementedError