|
|
@ -234,6 +234,11 @@ class Container(Item[V]): |
|
|
|
def width(self): |
|
|
|
return 5 |
|
|
|
|
|
|
|
@property |
|
|
|
def _total_count(self) -> int: |
|
|
|
# 1 for self and all children |
|
|
|
return 1 + len(tuple(self.walk_children())) |
|
|
|
|
|
|
|
def _is_v2(self) -> bool: |
|
|
|
return True |
|
|
|
|
|
|
@ -313,10 +318,8 @@ class Container(Item[V]): |
|
|
|
if not isinstance(item, Item): |
|
|
|
raise TypeError(f'expected Item not {item.__class__.__name__}') |
|
|
|
|
|
|
|
if item._has_children() and self._view: |
|
|
|
self._view._add_count(len(tuple(item.walk_children()))) # type: ignore |
|
|
|
elif self._view: |
|
|
|
self._view._add_count(1) |
|
|
|
if self._view: |
|
|
|
self._view._add_count(item._total_count) |
|
|
|
|
|
|
|
self._children.append(item) |
|
|
|
item._update_view(self.view) |
|
|
@ -341,10 +344,7 @@ class Container(Item[V]): |
|
|
|
pass |
|
|
|
else: |
|
|
|
if self._view: |
|
|
|
if item._has_children(): |
|
|
|
self._view._add_count(-len(tuple(item.walk_children()))) # type: ignore |
|
|
|
else: |
|
|
|
self._view._add_count(-1) |
|
|
|
self._view._add_count(-item._total_count) |
|
|
|
return self |
|
|
|
|
|
|
|
def find_item(self, id: int, /) -> Optional[Item[V]]: |
|
|
|