spinetoolbox.spine_db_editor.widgets.tabular_view_mixin
¶
Contains TabularViewMixin class.
- author
Vennström (VTT)
- date
1.11.2018
Module Contents¶
Classes¶
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.
- 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_db_map_entities(self)[source]¶
Returns a dict mapping db maps to a list of dict entity items in the current class.
- Returns
dict
- load_empty_relationship_data(self, db_map_class_objects=None)[source]¶
Returns a dict containing all possible relationships in the current class.
- Parameters
db_map_class_objects (dict) –
- Returns
Key is db_map-object_id tuple, value is None.
- Return type
dict
- load_full_relationship_data(self, db_map_relationships=None, action='add')[source]¶
Returns a dict of relationships in the current class.
- Parameters
db_map_relationships (dict) –
- Returns
Key is db_map-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
- load_scenario_alternative_data(self, db_map_scenarios=None, db_map_alternatives=None)[source]¶
Returns a dict containing all scenario alternatives.
- Returns
Key is db_map-id tuple, value is None or rank.
- Return type
dict
- _get_parameter_value_or_def_ids(self, item_type)[source]¶
Returns a dict mapping db maps to a list of integer parameter (value or def) ids from the current class.
- Parameters
item_type (str) – either “parameter_value” or “parameter_definition”
- Returns
dict
- _get_db_map_parameter_values_or_defs(self, item_type)[source]¶
Returns a dict mapping db maps to list of dict parameter (value or def) items from the current class.
- Parameters
item_type (str) – either “parameter_value” or “parameter_definition”
- Returns
dict
- load_empty_parameter_value_data(self, db_map_entities=None, db_map_parameter_ids=None, db_map_alternative_ids=None)[source]¶
Returns a dict containing all possible combinations of entities and parameters for the current class in all db_maps.
- Parameters
db_map_entities (dict, optional) – if given, only load data for these db maps and entities
db_map_parameter_ids (dict, optional) – if given, only load data for these db maps and parameter definitions
db_map_alternative_ids (dict, optional) – if given, only load data for these db maps and alternatives
- Returns
Key is a tuple object_id, …, parameter_id, value is None.
- Return type
dict
- load_full_parameter_value_data(self, db_map_parameter_values=None, action='add')[source]¶
Returns a dict of parameter values for the current class.
- Parameters
db_map_parameter_values (list, optional) –
action (str) –
- Returns
Key is a tuple object_id, …, parameter_id, value is the parameter_value.
- Return type
dict
- load_empty_expanded_parameter_value_data(self, db_map_entities=None, db_map_parameter_ids=None, db_map_alternative_ids=None)[source]¶
Makes a dict of expanded parameter values for the current class.
- Parameters
db_map_parameter_values (list, optional) –
action (str) –
- Returns
mapping from unique value id tuple to value tuple
- Return type
dict
- load_full_expanded_parameter_value_data(self, db_map_parameter_values=None, action='add')[source]¶
Makes a dict of expanded parameter values for the current class.
- Parameters
db_map_parameter_values (list, optional) –
action (str) –
- Returns
mapping from unique value id tuple to value tuple
- 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_index=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.