spinetoolbox.spine_db_editor.widgets.tabular_view_mixin¶
Contains TabularViewMixin class.
| author: |
|
|---|---|
| date: | 1.11.2018 |
Module Contents¶
Classes¶
TabularViewMixin |
Provides the pivot table and its frozen table for the DS form. |
-
class
spinetoolbox.spine_db_editor.widgets.tabular_view_mixin.TabularViewMixin(*args, **kwargs)[source]¶ Provides the pivot table and its frozen table for the DS form.
Initialize self. See help(type(self)) for accurate signature.
Adds toggle view actions to View menu.
-
static
_is_class_index(index)[source]¶ Returns whether or not the given tree index is a class index.
Parameters: index (QModelIndex) – index from object or relationship tree Returns: bool
-
_get_entities(self, class_id=None, class_type=None)[source]¶ Returns a list of dict items from the object or relationship tree model corresponding to the given class id.
Parameters: - class_id (int) –
- class_type (str) –
Returns: list(dict)
-
load_empty_relationship_data(self, objects_per_class=None)[source]¶ Returns a dict containing all possible relationships in the current class.
Parameters: objects_per_class (dict) – Returns: Key is object id tuple, value is None. Return type: dict
-
load_full_relationship_data(self, relationships=None, action='add')[source]¶ Returns a dict of relationships in the current class.
Returns: Key is object id tuple, value is relationship id. Return type: dict
-
load_relationship_data(self)[source]¶ Returns a dict that merges empty and full relationship data.
Returns: Key is object id tuple, value is True if a relationship exists, False otherwise. Return type: dict
-
_get_parameter_value_or_def_ids(self, item_type)[source]¶ Returns a list of integer ids from the parameter model corresponding to the currently selected class and the given item type.
Parameters: item_type (str) – either “parameter_value” or “parameter_definition” Returns: list(int)
-
_get_parameter_values_or_defs(self, item_type)[source]¶ Returns a list of dict items from the parameter model corresponding to the currently selected class and the given item type.
Parameters: item_type (str) – either “parameter_value” or “parameter_definition” Returns: list(dict)
-
load_empty_parameter_value_data(self, entities=None, parameter_ids=None, alternative_ids=None)[source]¶ Returns a dict containing all possible combinations of entities and parameters for the current class.
Parameters: - entities (list, optional) – if given, only load data for these entities
- parameter_ids (set, optional) – if given, only load data for these parameter definitions
Returns: Key is a tuple object_id, …, parameter_id, value is None.
Return type: dict
-
load_full_parameter_value_data(self, parameter_values=None, action='add')[source]¶ Returns a dict of parameter values for the current class.
Parameters: - parameter_values (list, optional) –
- action (str) –
Returns: Key is a tuple object_id, …, parameter_id, value is the parameter_value.
Return type: dict
-
load_parameter_value_data(self)[source]¶ Returns a dict that merges empty and full parameter_value data.
Returns: Key is a tuple object_id, …, parameter_id, value is the parameter_value or None if not specified. Return type: dict
-
load_expanded_parameter_value_data(self)[source]¶ Returns all permutations of entities as well as parameter indexes and values for the current class.
Returns: Key is a tuple object_id, …, index, while value is None. Return type: dict
-
get_pivot_preferences(self)[source]¶ Returns saved pivot preferences.
Returns: pivot tuple, or None if no preference stored Return type: tuple, NoneType
-
reload_pivot_table(self, current=None)[source]¶ Updates current class (type and id) and reloads pivot table for it.
-
make_pivot_headers(self)[source]¶ Turns top left indexes in the pivot table into TabularViewHeaderWidget.
-
make_frozen_headers(self)[source]¶ Turns indexes in the first row of the frozen table into TabularViewHeaderWidget.
Returns a filter menu for given given object_class identifier.
Parameters: identifier (int) – Returns: TabularViewFilterMenu
-
create_header_widget(self, identifier, area, with_menu=True)[source]¶ Returns a TabularViewHeaderWidget for given object_class identifier.
Parameters: - identifier (str) –
- area (str) –
- with_menu (bool) –
Returns: TabularViewHeaderWidget
-
static
_get_insert_index(pivot_list, catcher, position)[source]¶ Returns an index for inserting a new element in the given pivot list.
Returns: int
-
handle_header_dropped(self, dropped, catcher, position='')[source]¶ Updates pivots when a header is dropped.
Parameters: - dropped (TabularViewHeaderWidget) –
- catcher (TabularViewHeaderWidget, PivotTableHeaderView, FrozenTableView) –
- position (str) – either “before”, “after”, or “”
-
get_frozen_value(self, index)[source]¶ Returns the value in the frozen table corresponding to the given index.
Parameters: index (QModelIndex) – Returns: tuple
-
change_frozen_value(self, current, previous)[source]¶ Sets the frozen value from selection in frozen table.
-
reload_frozen_table(self)[source]¶ Resets the frozen model according to new selection in entity trees.
-
find_frozen_values(self, frozen)[source]¶ Returns a list of tuples containing unique values (object ids) for the frozen indexes (object_class ids).
Parameters: frozen (tuple(int)) – A tuple of currently frozen indexes Returns: list(tuple(list(int)))
-
receive_parameter_definitions_added(self, db_map_data)[source]¶ Reacts to parameter definitions added event.
-
receive_relationship_classes_updated(self, db_map_data)[source]¶ Reacts to relationship classes updated event.
-
receive_parameter_values_updated(self, db_map_data)[source]¶ Reacts to parameter values added event.
-
receive_parameter_definitions_updated(self, db_map_data)[source]¶ Reacts to parameter definitions updated event.
-
receive_relationship_classes_removed(self, db_map_data)[source]¶ Reacts to relationship classes remove event.
-
receive_parameter_definitions_removed(self, db_map_data)[source]¶ Reacts to parameter definitions removed event.