seriesmarker.gui.model.tree_node module¶
-
class
TreeNode
(data, parent=None)[source]¶ Bases:
seriesmarker.gui.model.decorated_node.DecoratedNode
Base class to store series data in a
PySide.QtCore.QAbstractItemModel
.-
_adjust_caches
(delta_leaves, delta_checks)[source]¶ Adjusts cached values according to given deltas.
Note
By calling this method, the caches of all parents of the node (including parent’s parents) are also being adjusted.
Parameters: See also
leaf_count()
checked_count()
-
append
(node)[source]¶ Adds a node to the current one’s children.
Parameters: node ( TreeNode
) – The node to add.
-
check
(state, origin=None)[source]¶ Sets the checked state of the node.
The checked state indicates whether or not an episode has been watched. When the state is set, the tree of the node is traversed upwards to its root, and the cached count of watched episodes in its branch is updated accordingly.
Parameters: - state (
bool
) – The checked state to set. - origin – The node which initiated the check call. Used to determine when to traverse the tree upward.
Type: Returns: A (immutable) tuple of all changed nodes.
See also
- state (
-
checked
()[source]¶ Gets the checked state of the node.
Note
Derived classes have to define whatever the checked state describes and how it is determined.
Returns: The boolean value of the checked state, or None if the state is undefined.
-
checked_count
¶ Returns the number of checked nodes in the branch of the node.
The branch is traversed, beginning from the node to the leaf-level. All checked nodes are counted, including the starting node.
Note
Once counted, the number of checked nodes is cached for further usage.
Returns: The count of checked nodes in the node’s branch.
-
child
(index)[source]¶ Returns the node’s child at the given index.
Parameters: index ( int
) – The index of the child to return.Returns: The child TreeNode
with the given index.
-
child_index
()[source]¶ Returns the index of the node in it’s parent’s children.
Returns: The (integer) index of the node.
-
children
¶ Returns an immutable representation of the node’s children.
Returns: The children of the node in a tuple of TreeNode
.
-
insert
(index, node)[source]¶ Inserts a node to the current one’s children at a given position.
Parameters:
-
leaf_count
¶ Returns the number of leaves in the branch of the node.
Note
Once counted, the number of leaves is cached for further usage.
Returns: The count of nodes without children in the node’s branch.
-