spinetoolbox.spine_db_editor.widgets.custom_menus

Classes for custom context menus and pop-up menus.

author
  1. Marin (KTH)

date

13.5.2020

Module Contents

Classes

MainMenu

ParameterViewFilterMenu

Filter menu.

TabularViewFilterMenu

Filter menu to use together with FilterWidget in TabularViewMixin.

class spinetoolbox.spine_db_editor.widgets.custom_menus.MainMenu[source]

Bases: PySide2.QtWidgets.QMenu

event(self, ev)[source]

Intercepts shortcurts and instead sends an equivalent event with the ‘Alt’ modifier, so that mnemonics works with just the key. Also sends a key press event with the ‘Alt’ key when this menu shows, so that mnemonics are underligned on windows.

class spinetoolbox.spine_db_editor.widgets.custom_menus.ParameterViewFilterMenu(parent, source_model, field, show_empty=True)[source]

Bases: spinetoolbox.widgets.custom_menus.FilterMenuBase

Filter menu.

Parameters
filterChanged[source]
_handle_source_model_refreshed(self)[source]

Updates the menu to only present values that are actually shown in the source model.

set_filter_accepted_values(self, accepted_values)[source]
set_filter_rejected_values(self, rejected_values)[source]
_get_value_to_remove(self, action, db_map, db_item)[source]
_get_value_to_add(self, action, db_map, db_item)[source]
modify_menu_data(self, action, db_map, db_items)[source]

Modifies data in the menu.

Parameters
  • action (str) – either ‘add’, ‘remove’, or ‘update’

  • db_map (DiffDatabaseMapping) –

  • db_items (list(dict)) –

_build_auto_filter(self, valid_values)[source]

Builds the auto filter given valid values.

Parameters

valid_values (Sequence) – Values accepted by the filter.

Returns

mapping db_map, to entity_class_id, to set of accepted parameter_value/definition ids

Return type

dict

emit_filter_changed(self, valid_values)[source]

Builds auto filter and emits signal.

Parameters

valid_values (Sequence) – Values accepted by the filter.

class spinetoolbox.spine_db_editor.widgets.custom_menus.TabularViewFilterMenu(parent, identifier, data_to_value, show_empty=True)[source]

Bases: spinetoolbox.widgets.custom_menus.FilterMenuBase

Filter menu to use together with FilterWidget in TabularViewMixin.

Parameters
  • parent (SpineDBEditor) –

  • identifier (int) – index identifier

  • data_to_value (method) – a method to translate item data to a value for display role

filterChanged[source]
emit_filter_changed(self, valid_values)[source]
event(self, event)[source]