spinetoolbox.mvcmodels.minimal_tree_model
¶
Models to represent items in a tree.
- authors
Vennström (VTT), M. Marin (KTH)
- date
11.3.2019
Module Contents¶
Classes¶
A tree item that can fetch its children. |
|
Base class for all tree models. |
- class spinetoolbox.mvcmodels.minimal_tree_model.TreeItem(model=None)[source]¶
A tree item that can fetch its children.
Initializes item.
- Parameters
model (MinimalTreeModel, NoneType) – The model where the item belongs.
- property child_item_type(self)[source]¶
Returns the type of child items. Reimplement in subclasses to return something more meaningful.
- child_number(self)[source]¶
Returns the rank of this item within its parent or -1 if it’s an orphan.
- find_children(self, cond=lambda child: ...)[source]¶
Returns children that meet condition expressed as a lambda function.
- find_child(self, cond=lambda child: ...)[source]¶
Returns first child that meet condition expressed as a lambda function or None.
- insert_children(self, position, *children)[source]¶
Insert new children at given position. Returns a boolean depending on how it went.
- Parameters
position (int) – insert new items here
children (iter) – insert items from this iterable
- class spinetoolbox.mvcmodels.minimal_tree_model.MinimalTreeModel(parent)[source]¶
Bases:
PySide2.QtCore.QAbstractItemModel
Base class for all tree models.
Init class.
- Parameters
parent (SpineDBEditor) –
- visit_all(self, index=QModelIndex())[source]¶
Iterates all items in the model including and below the given index. Iterative implementation so we don’t need to worry about Python recursion limits.
- index(self, row, column, parent=QModelIndex())[source]¶
Returns the index of the item in the model specified by the given row, column and parent index.
- data(self, index, role=Qt.DisplayRole)[source]¶
Returns the data stored under the given role for the index.