spinetoolbox.spine_db_editor.widgets.custom_menus

Classes for custom context menus and pop-up menus.

Module Contents

Classes

MainMenu

AutoFilterMenu

Filter menu.

TabularViewFilterMenuBase

Filter menu.

TabularViewDBItemFilterMenu

Filter menu to use together with FilterWidget in TabularViewMixin.

TabularViewCodenameFilterMenu

Filter menu to filter database codenames in Pivot table.

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

Bases: PySide6.QtWidgets.QMenu

event(ev)[source]

Intercepts shortcuts 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 underlined on Windows.

class spinetoolbox.spine_db_editor.widgets.custom_menus.AutoFilterMenu(parent, db_mngr, db_maps, item_type, field, show_empty=True)[source]

Bases: spinetoolbox.widgets.custom_menus.FilterMenuBase

Filter menu.

Parameters
  • parent (SpineDBEditor) –

  • db_mngr (SpineDBManager) –

  • db_maps (Sequence of DatabaseMapping) –

  • item_type (str) –

  • field (str) – the field name

filterChanged[source]
set_filter_accepted_values(accepted_values)[source]
set_filter_rejected_values(rejected_values)[source]
_get_value(item, db_map)[source]
_get_display_value(item, db_map)[source]
_handle_items_added(db_map_data)[source]
_handle_items_removed(db_map_data)[source]
_build_auto_filter(valid_values)[source]

Builds the auto filter given valid values.

Parameters

valid_values (Sequence) – Values accepted by the filter.

Returns

mapping (db_map, entity_class_id) to set of valid values

Return type

dict

emit_filter_changed(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.TabularViewFilterMenuBase(parent, identifier)[source]

Bases: spinetoolbox.widgets.custom_menus.FilterMenuBase

Filter menu.

Parameters
  • parent (SpineDBEditor) – parent widget

  • identifier (str) – header identifier

filterChanged[source]
showEvent(event)[source]
class spinetoolbox.spine_db_editor.widgets.custom_menus.TabularViewDBItemFilterMenu(parent, db_mngr, db_maps, item_type, accepts_item, identifier, show_empty=True)[source]

Bases: TabularViewFilterMenuBase

Filter menu to use together with FilterWidget in TabularViewMixin.

Parameters
  • parent (SpineDBEditor) – parent widget

  • db_mngr (SpineDBManager) – database manager

  • db_maps (Sequence of DatabaseMapping) – database mappings

  • item_type (str) – database item type to filter

  • accepts_item (Callable) – callable that returns True when database item is accepted

  • identifier (str) – header identifier

  • show_empty (bool) – if True, an empty row will be added to the end of the item list

_handle_items_added(db_map_data)[source]
_get_values(db_map, item)[source]
_handle_items_removed(db_map_data)[source]
emit_filter_changed(valid_values)[source]
class spinetoolbox.spine_db_editor.widgets.custom_menus.TabularViewCodenameFilterMenu(parent, db_maps, identifier, show_empty=True)[source]

Bases: TabularViewFilterMenuBase

Filter menu to filter database codenames in Pivot table.

Parameters
  • parent (SpineDBEditor) – parent widget

  • db_maps (Sequence of DatabaseMapping) – database mappings

  • identifier (str) – header identifier

  • show_empty (bool) – if True, an empty row will be added to the end of the item list

emit_filter_changed(valid_values)[source]

See base class.