spinetoolbox.widgets.tabular_view_mixin
¶
Contains TabularViewMixin class.
author: |
|
---|---|
date: | 1.11.2018 |
Module Contents¶
-
class
spinetoolbox.widgets.tabular_view_mixin.
TabularViewMixin
(*args, **kwargs)[source]¶ Provides the pivot table and its frozen table for the DS form.
Adds toggle view actions to View menu.
-
static
_is_class_index
(index, class_type)[source]¶ Returns whether or not the given tree index is a class index.
Parameters: - index (QModelIndex) – index from object or relationship tree
- class_type (str) –
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 set 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: set(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)[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) – 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
-
get_pivot_preferences
(self, selection_key)[source]¶ Returns saved or default pivot preferences.
Parameters: selection_key (tuple(int,str,str)) – Tuple of class id, class type, and input type. - Returns
- list: indexes in rows list: indexes in columns list: frozen indexes tuple: selection in frozen table
-
reload_pivot_table
(self, text='')[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 (int) –
- 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.