spinetoolbox.mvcmodels.entity_tree_models

Models to represent entities in a tree.

authors:
  1. Vennström (VTT), M. Marin (KTH)
date:

11.3.2019

Module Contents

class spinetoolbox.mvcmodels.entity_tree_models.EntityTreeModel(parent, db_mngr, *db_maps)[source]

Bases: spinetoolbox.mvcmodels.minimal_tree_model.MinimalTreeModel

Base class for all entity tree models.

Init class.

Parameters:
  • parent (DataStoreForm) –
  • db_mngr (SpineDBManager) – A manager for the given db_maps
  • db_maps (iter) – DiffDatabaseMapping instances
remove_selection_requested[source]
root_item_type[source]

Implement in subclasses to create a model specific to any entity type.

root_item[source]
root_index[source]
build_tree(self)[source]

Builds tree.

columnCount(self, parent=QModelIndex())[source]
data(self, index, role=Qt.DisplayRole)[source]
headerData(self, section, orientation, role)[source]
_select_index(self, index)[source]

Marks the index as selected.

select_indexes(self, indexes)[source]

Marks given indexes as selected.

find_leaves(self, db_map, *ids_path, parent_items=(), fetch=False)[source]

Returns leaf-nodes following the given path of ids, where each element in ids_path is a set of ids to jump from one level in the tree to the next. Optionally fetches nodes as it goes.

class spinetoolbox.mvcmodels.entity_tree_models.ObjectTreeModel(*args, **kwargs)[source]

Bases: spinetoolbox.mvcmodels.entity_tree_models.EntityTreeModel

An ‘object-oriented’ tree model.

root_item_type[source]
selected_object_class_indexes[source]
selected_object_indexes[source]
selected_relationship_class_indexes[source]
selected_relationship_indexes[source]
_group_object_data(self, db_map_data)[source]

Takes given object data and returns the same data keyed by parent tree-item.

Parameters:db_map_data (dict) – maps DiffDatabaseMapping instances to list of items as dict
Returns:maps parent tree-items to DiffDatabaseMapping instances to list of item ids
Return type:result (dict)
_group_relationship_class_data(self, db_map_data)[source]

Takes given relationship class data and returns the same data keyed by parent tree-item.

Parameters:db_map_data (dict) – maps DiffDatabaseMapping instances to list of items as dict
Returns:maps parent tree-items to DiffDatabaseMapping instances to list of item ids
Return type:result (dict)
_group_relationship_data(self, db_map_data)[source]

Takes given relationship data and returns the same data keyed by parent tree-item.

Parameters:db_map_data (dict) – maps DiffDatabaseMapping instances to list of items as dict
Returns:maps parent tree-items to DiffDatabaseMapping instances to list of item ids
Return type:result (dict)
add_object_classes(self, db_map_data)[source]
add_objects(self, db_map_data)[source]
add_relationship_classes(self, db_map_data)[source]
add_relationships(self, db_map_data)[source]
remove_object_classes(self, db_map_data)[source]
remove_objects(self, db_map_data)[source]
remove_relationship_classes(self, db_map_data)[source]
remove_relationships(self, db_map_data)[source]
update_object_classes(self, db_map_data)[source]
update_objects(self, db_map_data)[source]
update_relationship_classes(self, db_map_data)[source]
update_relationships(self, db_map_data)[source]
find_next_relationship_index(self, index)[source]

Find and return next ocurrence of relationship item.

class spinetoolbox.mvcmodels.entity_tree_models.RelationshipTreeModel(*args, **kwargs)[source]

Bases: spinetoolbox.mvcmodels.entity_tree_models.EntityTreeModel

A relationship-oriented tree model.

root_item_type[source]
selected_relationship_class_indexes[source]
selected_relationship_indexes[source]
_group_relationship_data(self, db_map_data)[source]

Takes given relationship data and returns the same data keyed by parent tree-item.

Parameters:db_map_data (dict) – maps DiffDatabaseMapping instances to list of items as dict
Returns:maps parent tree-items to DiffDatabaseMapping instances to list of item ids
Return type:result (dict)
add_relationship_classes(self, db_map_data)[source]
add_relationships(self, db_map_data)[source]
remove_relationship_classes(self, db_map_data)[source]
remove_relationships(self, db_map_data)[source]
update_relationship_classes(self, db_map_data)[source]
update_relationships(self, db_map_data)[source]