treeview_models
¶
Classes for handling models in tree and graph views.
authors: |
|
---|---|
date: | 28.6.2019 |
Module Contents¶
-
class
treeview_models.
ObjectClassListModel
(graph_view_form)[source]¶ Bases:
PySide2.QtGui.QStandardItemModel
A class to list object classes in the GraphViewForm.
-
class
treeview_models.
RelationshipClassListModel
(graph_view_form)[source]¶ Bases:
PySide2.QtGui.QStandardItemModel
A class to list relationship classes in the GraphViewForm.
-
class
treeview_models.
ObjectTreeModel
(parent, flat=False)[source]¶ Bases:
PySide2.QtGui.QStandardItemModel
A class to display Spine data structure in a treeview with object classes at the outer level.
-
data
(self, index, role=Qt.DisplayRole)[source]¶ Returns the data stored under the given role for the item referred to by the index.
-
static
backward_sweep
(index, call=None)[source]¶ Sweep the tree from the given index towards the root, and apply call on each.
-
forward_sweep
(self, index, call=None)[source]¶ Sweep the tree from the given index towards the leaves, and apply call on each.
-
new_relationship_class_row
(self, db_map, relationship_class)[source]¶ Returns new relationship class item.
-
add_relationship_classes
(self, db_map, relationship_classes)[source]¶ Add relationship class items to model.
-
update_object_classes
(self, db_map, object_classes)[source]¶ Update object classes in the model. This of course means updating the object class name in relationship class items.
-
update_objects
(self, db_map, objects)[source]¶ Update object in the model. This of course means updating the object name in relationship items.
-
update_relationship_classes
(self, db_map, relationship_classes)[source]¶ Update relationship classes in the model.
-
update_relationships
(self, db_map, relationships)[source]¶ Update relationships in the model. Move rows if the objects in the relationship change.
-
-
class
treeview_models.
RelationshipTreeModel
(parent)[source]¶ Bases:
PySide2.QtGui.QStandardItemModel
A class to display Spine data structure in a treeview with relationship classes at the outer level.
-
data
(self, index, role=Qt.DisplayRole)[source]¶ Returns the data stored under the given role for the item referred to by the index.
-
new_relationship_class_row
(self, db_map, relationship_class)[source]¶ Returns new relationship class item.
-
add_relationship_classes
(self, db_map, relationship_classes)[source]¶ Add relationship class items to the model.
-
update_object_classes
(self, db_map, object_classes)[source]¶ Update object classes in the model. This just means updating the object class name in relationship class items.
-
update_objects
(self, db_map, objects)[source]¶ Update object in the model. This just means updating the object name in relationship items.
-
update_relationship_classes
(self, db_map, relationship_classes)[source]¶ Update relationship classes in the model.
-
-
class
treeview_models.
SubParameterModel
(parent)[source]¶ Bases:
models.MinimalTableModel
A parameter model which corresponds to a slice of the entire table. The idea is to combine several of these into one big model. Allows specifying set of columns that are non-editable (e.g., object_class_name) TODO: how column insertion/removal impacts fixed_columns?
-
class
treeview_models.
SubParameterValueModel
(parent)[source]¶ Bases:
treeview_models.SubParameterModel
A parameter model which corresponds to a slice of an entire parameter value table. The idea is to combine several of these into one big model.
-
class
treeview_models.
SubParameterDefinitionModel
(parent)[source]¶ Bases:
treeview_models.SubParameterModel
A parameter model which corresponds to a slice of an entire parameter definition table. The idea is to combine several of these into one big model.
-
class
treeview_models.
EmptyParameterModel
(parent)[source]¶ Bases:
models.EmptyRowModel
An empty parameter model. It implements bath_set_data for all ‘EmptyParameter’ models.
-
class
treeview_models.
EmptyParameterValueModel
(parent)[source]¶ Bases:
treeview_models.EmptyParameterModel
An empty parameter value model. Implements add_items_to_db for both EmptyObjectParameterValueModel and EmptyRelationshipParameterValueModel.
-
class
treeview_models.
EmptyObjectParameterValueModel
(parent)[source]¶ Bases:
treeview_models.EmptyParameterValueModel
An empty object parameter value model. Implements items_to_add.
-
class
treeview_models.
EmptyRelationshipParameterValueModel
(parent)[source]¶ Bases:
treeview_models.EmptyParameterValueModel
An empty relationship parameter value model. Reimplements alsmot all methods from the super class EmptyParameterModel.
-
batch_set_data
(self, indexes, data)[source]¶ Batch set data for indexes. A little different from the base class implementation, since here we need to support creating relationships on the fly.
-
relationships_on_the_fly
(self, indexes)[source]¶ A dict of row (int) to relationship item (KeyedTuple), which can be either retrieved or added on the fly. Extend set of indexes as additional data is set.
-
-
class
treeview_models.
EmptyParameterDefinitionModel
(parent)[source]¶ Bases:
treeview_models.EmptyParameterModel
An empty parameter definition model.
-
class
treeview_models.
EmptyObjectParameterDefinitionModel
(parent)[source]¶ Bases:
treeview_models.EmptyParameterDefinitionModel
An empty object parameter definition model.
-
class
treeview_models.
EmptyRelationshipParameterDefinitionModel
(parent)[source]¶ Bases:
treeview_models.EmptyParameterDefinitionModel
An empty relationship parameter definition model.
-
class
treeview_models.
ObjectParameterModel
(parent=None)[source]¶ Bases:
models.MinimalTableModel
A model that concatenates several ‘sub’ object parameter models, one per object class.
-
flags
(self, index)[source]¶ Return flags for given index. Depending on the index’s row we will land on a specific model. Models whose object class id is not selected are skipped.
-
data
(self, index, role=Qt.DisplayRole)[source]¶ Return data for given index and role. Depending on the index’s row we will land on a specific model. Models whose object class id is not selected are skipped.
-
rowCount
(self, parent=QModelIndex())[source]¶ Return the sum of rows in all models. Skip models whose object class id is not selected.
-
batch_set_data
(self, indexes, data)[source]¶ Batch set data for indexes. Distribute indexes and data among the different submodels and call batch_set_data on each of them.
-
insertRows
(self, row, count, parent=QModelIndex())[source]¶ Find the right sub-model (or the empty model) and call insertRows on it.
-
removeRows
(self, row, count, parent=QModelIndex())[source]¶ Find the right sub-models (or empty model) and call removeRows on them.
-
auto_filter_values
(self, column)[source]¶ Return values to populate the auto filter of given column. Each ‘row’ in the returned value consists of: 1) The ‘checked’ state, True if the value hasn’t been filtered out 2) The value itself (an object name, a parameter name, a numerical value…) 3) A set of object class ids where the value is found.
Rename parameter tags in model.
Remove parameter tags from model.
-
-
class
treeview_models.
ObjectParameterValueModel
(parent=None)[source]¶ Bases:
treeview_models.ObjectParameterModel
A model that concatenates several ‘sub’ object parameter value models, one per object class.
-
class
treeview_models.
ObjectParameterDefinitionModel
(parent=None)[source]¶ Bases:
treeview_models.ObjectParameterModel
A model that concatenates several object parameter definition models (one per object class) vertically.
-
reset_model
(self, main_data=None)[source]¶ Reset model data. Each sub-model is filled with parameter definition data for a different object class.
-
move_rows_to_sub_models
(self, rows)[source]¶ Move rows from empty row model to a new sub_model. Called when the empty row model succesfully inserts new data in the db.
-
-
class
treeview_models.
RelationshipParameterModel
(parent=None)[source]¶ Bases:
models.MinimalTableModel
A model that combines several relationship parameter models (one per relationship class), one on top of the other.
-
add_object_class_id_lists
(self, db_map, wide_relationship_class_list)[source]¶ Populate a dictionary of object class id lists per relationship class.
-
flags
(self, index)[source]¶ Return flags for given index. Depending on the index’s row we will land on a specific model. Models whose relationship class id is not selected are skipped. Models whose object class id list doesn’t intersect the selected ones are also skipped.
-
data
(self, index, role=Qt.DisplayRole)[source]¶ Return data for given index and role. Depending on the index’s row we will land on a specific model. Models whose relationship class id is not selected are skipped. Models whose object class id list doesn’t intersect the selected ones are also skipped.
-
rowCount
(self, parent=QModelIndex())[source]¶ Return the sum of rows in all models. Models whose relationship class id is not selected are skipped. Models whose object class id list doesn’t intersect the selected ones are also skipped.
-
batch_set_data
(self, indexes, data)[source]¶ Batch set data for indexes. Distribute indexes and data among the different submodels and call batch_set_data on each of them.
-
insertRows
(self, row, count, parent=QModelIndex())[source]¶ Find the right sub-model (or the empty model) and call insertRows on it.
-
removeRows
(self, row, count, parent=QModelIndex())[source]¶ Find the right sub-models (or empty model) and call removeRows on them.
-
auto_filter_values
(self, column)[source]¶ Return values to populate the auto filter of given column. Each ‘row’ in the returned value consists of: 1) The ‘checked’ state, True if the value hasn’t been filtered out 2) The value itself (an object name, a parameter name, a numerical value…) 3) A set of relationship class ids where the value is found.
-
rename_relationship_classes
(self, db_map, relationship_classes)[source]¶ Rename relationship classes in model.
Rename parameter tags in model.
-
remove_relationship_classes
(self, db_map, relationship_classes)[source]¶ Remove relationship classes from model.
Remove parameter tags from model.
-
-
class
treeview_models.
RelationshipParameterValueModel
(parent=None)[source]¶ Bases:
treeview_models.RelationshipParameterModel
A model that combines several relationship parameter value models (one per relationship class), one on top of the other.
-
reset_model
(self, main_data=None)[source]¶ Reset model data. Each sub-model is filled with parameter value data for a different relationship class.
-
-
class
treeview_models.
RelationshipParameterDefinitionModel
(parent=None)[source]¶ Bases:
treeview_models.RelationshipParameterModel
A model that combines several relationship parameter definition models (one per relationship class), one on top of the other.
-
reset_model
(self, main_data=None)[source]¶ Reset model data. Each sub-model is filled with parameter definition data for a different relationship class.
-
move_rows_to_sub_models
(self, rows)[source]¶ Move rows from empty row model to a new sub_model. Called when the empty row model succesfully inserts new data in the db.
-
-
class
treeview_models.
ObjectParameterDefinitionFilterProxyModel
(parent, parameter_definition_id_column)[source]¶ Bases:
PySide2.QtCore.QSortFilterProxyModel
A filter proxy model for object parameter models.
-
class
treeview_models.
ObjectParameterValueFilterProxyModel
(parent, parameter_definition_id_column, object_id_column, db_column)[source]¶ Bases:
treeview_models.ObjectParameterDefinitionFilterProxyModel
A filter proxy model for object parameter value models.
-
class
treeview_models.
RelationshipParameterDefinitionFilterProxyModel
(parent, parameter_definition_id_column)[source]¶ Bases:
PySide2.QtCore.QSortFilterProxyModel
A filter proxy model for relationship parameter definition models.
-
class
treeview_models.
RelationshipParameterValueFilterProxyModel
(parent, parameter_definition_id_column, object_id_list_column, db_column)[source]¶ Bases:
treeview_models.RelationshipParameterDefinitionFilterProxyModel
A filter proxy model for relationship parameter value models.
-
class
treeview_models.
TreeNode
(parent, row, text=None, level=None, identifier=None)[source]¶ A helper class to use as the internalPointer of indexes in ParameterValueListModel.
- Attributes
- parent (TreeNode): the parent node row (int): the row, needed by ParameterValueListModel.parent() text (str, NoneType): the text to show level (int, NoneType): the level in the tree id (int, NoneType): the id from the db table
-
class
treeview_models.
ParameterValueListModel
(parent)[source]¶ Bases:
PySide2.QtCore.QAbstractItemModel
A class to display parameter value list data in a treeview.
-
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. Toplevel indexes get their pointer from the _root_nodes attribute; whereas inner indexes get their pointer from the child_nodes attribute of the parent node.
-
parent
(self, index)[source]¶ Returns the parent of the model item with the given index. Use the internal pointer to retrieve the parent node and use it to create the parent index.
-
rowCount
(self, parent=QModelIndex())[source]¶ Returns the number of rows under the given parent. Get it from the lenght of the appropriate list.
-
columnCount
(self, parent=QModelIndex())[source]¶ Returns the number of columns under the given parent. Always 1.
-
data
(self, index, role=Qt.DisplayRole)[source]¶ Returns the data stored under the given role for the item referred to by the index. Bold toplevel items. Get the DisplayRole from the text attribute of the internal pointer.
-
setData
(self, index, value, role=Qt.EditRole)[source]¶ Sets the role data for the item at index to value. Returns True if successful; otherwise returns False. Basically just update the text attribute of the internal pointer.
-
appendRows
(self, count, parent=QModelIndex())[source]¶ Append count rows into the model. Items in the new row will be children of the item represented by the parent model index.
-
_handle_data_changed
(self, top_left, bottom_right, roles=None)[source]¶ Called when data in the model changes.
-
append_empty_rows
(self, index)[source]¶ Append emtpy rows if index is the last children, so the user can continue editing the model.
-
-
class
treeview_models.
LazyLoadingArrayModel
(parent, stride=256)[source]¶ Bases:
models.EmptyRowModel
A model of array data, used by TreeViewForm.
-
parent
¶ the parent widget
Type: JSONEditor
-
stride
¶ The number of elements to fetch
Type: int
-