tab_controller
freecad.datamanager_wb.domain.tab_controller
¶
Generic tab controller shared by VarSets and Aliases.
Implements filtering, only-unused logic, enable-state rules, and remove-unused
orchestration against a TabDataSource.
TabController(data_source)
¶
Tab-generic controller logic shared across domains.
This controller encapsulates behavior that is the same for both the VarSets and Aliases tabs:
- Normalizing filter inputs (glob vs substring).
- Filtering parents (VarSets / Spreadsheets).
- Filtering children (Variables / Aliases), optionally restricting to "only unused" by consulting expression reference counts.
- Enable/disable rules for the "remove unused" action.
- Orchestrating remove-unused and producing a post-mutation UI update.
The controller is intentionally UI-agnostic; it delegates all domain access
to a TabDataSource.
Source code in freecad/datamanager_wb/domain/tab_controller.py
can_remove_unused(*, only_unused, selected_items)
¶
Return whether the given selection is eligible for remove-unused.
This is a convenience wrapper that normalizes the selection and then
applies should_enable_remove_unused.
Source code in freecad/datamanager_wb/domain/tab_controller.py
get_expression_items(selected_child_items)
¶
Return expression items for the selection.
Delegates to the underlying data source.
Source code in freecad/datamanager_wb/domain/tab_controller.py
get_expression_reference_counts(selected_child_items)
¶
Return expression reference counts for the selection.
Source code in freecad/datamanager_wb/domain/tab_controller.py
get_filtered_child_items(*, selected_parents, child_filter_text, only_unused)
¶
Return child refs filtered by name and optionally by "unused".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
selected_parents
|
list[str]
|
Parent names currently selected in the UI. |
required |
child_filter_text
|
str
|
Filter text for child names. |
required |
only_unused
|
bool
|
When true, only children with zero expression references are returned. |
required |
Source code in freecad/datamanager_wb/domain/tab_controller.py
get_filtered_parents(*, filter_text, exclude_copy_on_change=False)
¶
Return parent names filtered by the given text.
The filter supports glob patterns. If the user provides no glob characters, the filter is treated as a substring match.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter_text
|
str
|
User-entered filter text. |
required |
exclude_copy_on_change
|
bool
|
Whether copy-on-change derived parents should be hidden. |
False
|
Source code in freecad/datamanager_wb/domain/tab_controller.py
get_post_remove_unused_update(*, selected_parents, child_filter_text, only_unused)
¶
Compute the post-mutation UI state after removing unused children.
Source code in freecad/datamanager_wb/domain/tab_controller.py
remove_unused_and_get_update(*, selected_child_items, selected_parents, child_filter_text, only_unused)
¶
Remove unused selected children and compute updated filtered lists.
Source code in freecad/datamanager_wb/domain/tab_controller.py
remove_unused_children(selected_child_items)
¶
Remove unused children from the underlying data source.
Source code in freecad/datamanager_wb/domain/tab_controller.py
should_enable_remove_unused(*, only_unused, selected_count)
¶
Return whether the remove-unused button should be enabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
only_unused
|
bool
|
Whether the tab is currently configured to show only unused children. |
required |
selected_count
|
int
|
Number of selected children. |
required |