spinetoolbox.spine_db_editor.widgets.tabular_view_mixin

Contains TabularViewMixin class.

author
  1. Vennström (VTT)

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.

_PARAMETER_VALUE = &Value[source]
_INDEX_EXPANSION = &Index[source]
_RELATIONSHIP = Re&lationship[source]
_SCENARIO_ALTERNATIVE = &Scenario[source]
_PARAMETER = parameter[source]
_ALTERNATIVE = alternative[source]
_INDEX = index[source]
populate_pivot_action_group(self)[source]
connect_signals(self)[source]

Connects signals to slots.

init_models(self)[source]

Initializes models.

_set_model_data(self, index, value)[source]
property current_object_class_id_list(self)[source]
property current_object_class_name_list(self)[source]
property current_object_class_ids(self)[source]
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

_handle_pivot_table_visibility_changed(self, visible)[source]
_handle_frozen_table_visibility_changed(self, visible)[source]
_handle_object_tree_selection_changed(self, selected_indexes)[source]
_handle_relationship_tree_selection_changed(self, selected_indexes)[source]
_handle_entity_tree_current_changed(self, current_index)[source]
static _make_get_id(action)[source]

Returns a function to compute the db_map-id tuple of an item.

_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

_indexes(self, value)[source]
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.

static _get_current_class_item(current_index)[source]
_handle_pivot_action_triggered(self, action)[source]
do_reload_pivot_table(self)[source]

Reloads pivot table.

_can_build_pivot_table(self)[source]
clear_pivot_table(self)[source]
wipe_out_filter_menus(self)[source]
make_pivot_headers(self)[source]

Turns top left indexes in the pivot table into TabularViewHeaderWidget.

_resize_pivot_header_columns(self)[source]
make_frozen_headers(self)[source]

Turns indexes in the first row of the frozen table into TabularViewHeaderWidget.

create_filter_menu(self, identifier)[source]

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
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.

change_filter(self, identifier, valid_values, has_filter)[source]
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)))

static refresh_table_view(table_view)[source]
update_filter_menus(self, action)[source]
receive_objects_added_or_removed(self, db_map_data, action)[source]
receive_relationships_added_or_removed(self, db_map_data, action)[source]
receive_parameter_definitions_added_or_removed(self, db_map_data, action)[source]
receive_alternatives_added_or_removed(self, db_map_data, action)[source]
receive_parameter_values_added_or_removed(self, db_map_data, action)[source]
receive_scenarios_added_or_removed(self, db_map_data, action)[source]
receive_db_map_data_updated(self, db_map_data, get_class_id)[source]
receive_classes_updated(self, db_map_data)[source]
receive_classes_removed(self, db_map_data)[source]
receive_alternatives_added(self, db_map_data)[source]

Reacts to alternatives added event.

receive_scenarios_added(self, db_map_data)[source]

Reacts to scenarios added event.

receive_objects_added(self, db_map_data)[source]

Reacts to objects added event.

receive_relationships_added(self, db_map_data)[source]

Reacts to relationships added event.

receive_parameter_definitions_added(self, db_map_data)[source]

Reacts to parameter definitions added event.

receive_parameter_values_added(self, db_map_data)[source]

Reacts to parameter values added event.

receive_alternatives_updated(self, db_map_data)[source]

Reacts to alternatives updated event.

receive_object_classes_updated(self, db_map_data)[source]

Reacts to object classes updated event.

receive_relationship_classes_updated(self, db_map_data)[source]

Reacts to relationship classes updated event.

receive_objects_updated(self, db_map_data)[source]

Reacts to objects updated event.

receive_relationships_updated(self, db_map_data)[source]

Reacts to relationships 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_scenarios_updated(self, db_map_data)[source]
receive_alternatives_removed(self, db_map_data)[source]

Reacts to alternatives removed event.

receive_scenarios_removed(self, db_map_data)[source]

Reacts to scenarios removed event.

receive_object_classes_removed(self, db_map_data)[source]

Reacts to object classes removed event.

receive_relationship_classes_removed(self, db_map_data)[source]

Reacts to relationship classes remove event.

receive_objects_removed(self, db_map_data)[source]

Reacts to objects removed event.

receive_relationships_removed(self, db_map_data)[source]

Reacts to relationships removed event.

receive_parameter_definitions_removed(self, db_map_data)[source]

Reacts to parameter definitions removed event.

receive_parameter_values_removed(self, db_map_data)[source]

Reacts to parameter values removed event.

receive_session_rolled_back(self, db_maps)[source]

Reacts to session rolled back event.