spinetoolbox.spine_db_editor.widgets.manage_items_dialogs

Classes for custom QDialogs to add, edit and remove database items.

Attributes

DB_ITEM_SEPARATOR

Display string to separate items such as entity names.

Classes

EntityClassItem

An entity_class item.

IconColorEditor

An editor to let the user select an icon and a color for an object_class.

CopyPasteTableView

Custom QTableView class with copy and paste methods.

DialogWithButtons

param parent:

data store widget

DialogWithTableAndButtons

param parent:

data store widget

ManageItemsDialog

A dialog with a CopyPasteTableView and a QDialogButtonBox. Base class for all

GetEntityClassesMixin

Provides a method to retrieve entity classes for AddEntitiesDialog and AddEntityClassesDialog.

GetEntitiesMixin

Provides a method to retrieve entities for AddEntitiesDialog and EditEntitiesDialog.

ShowIconColorEditorMixin

Provides methods to show an IconColorEditor upon request.

Functions

busy_effect(func)

Decorator to change the mouse cursor to 'busy' while a function is processed.

preferred_row_height(widget[, factor])

Module Contents

class spinetoolbox.spine_db_editor.widgets.manage_items_dialogs.EntityClassItem(model, db_map_ids=None)[source]

Bases: spinetoolbox.spine_db_editor.mvcmodels.multi_db_tree_item.MultiDBTreeItem

An entity_class item.

Parameters:
  • model (MinimalTreeModel, optional) – item’s model

  • db_map_ids (dict, optional) – maps instances of DatabaseMapping to the id of the item in that db

visual_key = ['name', 'dimension_name_list', 'superclass_name']
item_type = 'entity_class'
_fetch_index
property display_icon
Returns class icon.
property child_item_class
Returns the type of child items.
is_hidden()[source]
property _children_sort_key
Reimplemented so groups are above non-groups.
default_parameter_data()[source]

Return data to put as default in a parameter table when this item is selected.

property display_data
Returns the name for display.
property has_dimensions
data(column, role=Qt.ItemDataRole.DisplayRole)[source]

Returns data for given column and role.

_key_for_index(db_map)[source]
accepts_item(item, db_map)[source]
set_data(column, value, role)[source]

See base class.

_polish_children(children)[source]

See base class.

class spinetoolbox.spine_db_editor.widgets.manage_items_dialogs.IconColorEditor(parent)[source]

Bases: PySide6.QtWidgets.QDialog

An editor to let the user select an icon and a color for an object_class.

Parameters:

parent (QWidget) – parent widget

reset_pressed
showEvent(event)[source]
_proxy_model_filter_accepts_row(source_row, source_parent)[source]

Filters icons according to search terms.

Parameters:
  • source_row (int) – source row index

  • source_parent (QModelIndex) – parent index for source row

Returns:

True if row is accepted, False otherwise

Return type:

bool

connect_signals()[source]

Connects signals to slots.

set_data(data)[source]

Sets current icon data.

Parameters:

data (int) – database icon data

data()[source]

Gets current icon data.

Returns:

database icon data

Return type:

int

class spinetoolbox.spine_db_editor.widgets.manage_items_dialogs.CopyPasteTableView(parent=None)[source]

Bases: PySide6.QtWidgets.QTableView

Custom QTableView class with copy and paste methods.

init_copy_and_paste_actions()[source]

Initializes copy and paste actions and connects relevant signals.

set_external_copy_and_paste_actions(copy_action, paste_action)[source]

Sets the view to use external copy and paste actions.

Note that this doesn’t connect the actions’ trigger signals; the owner of the actions is responsible for handling them.

Parameters:
  • copy_action (QAction) – copy action

  • paste_action (QAction) – paste action

property copy_action
property paste_action
delete_content(_=False)[source]

Deletes content from editable indexes in current selection.

can_copy()[source]
copy(_=False)[source]

Copies current selection to clipboard in excel format.

can_paste()[source]
paste(_=False)[source]

Paste data from clipboard.

static _read_pasted_text(text)[source]

Parses a tab separated CSV text table.

Parameters:

text (str) – a CSV formatted table

Returns:

a list of rows

Return type:

list

paste_on_selection()[source]

Pastes clipboard data on selection, but not beyond. If data is smaller than selection, repeat data to fit selection.

paste_normal()[source]

Pastes clipboard data, overwriting cells if needed.

set_column_converter_for_pasting(header, converter)[source]
_converters()[source]
spinetoolbox.spine_db_editor.widgets.manage_items_dialogs.busy_effect(func)[source]

Decorator to change the mouse cursor to ‘busy’ while a function is processed.

Parameters:

func (Callable) – Decorated function.

spinetoolbox.spine_db_editor.widgets.manage_items_dialogs.preferred_row_height(widget, factor=1.5)[source]
spinetoolbox.spine_db_editor.widgets.manage_items_dialogs.DB_ITEM_SEPARATOR = ' ǀ '[source]

Display string to separate items such as entity names.

class spinetoolbox.spine_db_editor.widgets.manage_items_dialogs.DialogWithButtons(parent, db_mngr)[source]

Bases: PySide6.QtWidgets.QDialog

Parameters:
showEvent(ev)[source]
_populate_layout()[source]
connect_signals()[source]

Connect signals to slots.

class spinetoolbox.spine_db_editor.widgets.manage_items_dialogs.DialogWithTableAndButtons(parent, db_mngr)[source]

Bases: DialogWithButtons

Parameters:
_populate_layout()[source]
showEvent(ev)[source]
abstract make_table_view()[source]
resize_window_to_columns(height=None)[source]
class spinetoolbox.spine_db_editor.widgets.manage_items_dialogs.ManageItemsDialog(parent, db_mngr)[source]

Bases: DialogWithTableAndButtons

A dialog with a CopyPasteTableView and a QDialogButtonBox. Base class for all dialogs to query user’s preferences for adding/editing/managing data items.

Parameters:
make_table_view()[source]
connect_signals()[source]

Connect signals to slots.

_handle_model_data_changed(top_left, bottom_right, roles)[source]

Reimplement in subclasses to handle changes in model data.

set_model_data(index, data)[source]

Update model data.

_handle_model_reset()[source]

Resize columns and form.

class spinetoolbox.spine_db_editor.widgets.manage_items_dialogs.GetEntityClassesMixin[source]

Provides a method to retrieve entity classes for AddEntitiesDialog and AddEntityClassesDialog.

db_map_ent_cls_lookup()[source]
db_map_ent_cls_lookup_by_name()[source]
entity_class_name_list(row)[source]

Return a list of entity class names present in all databases selected for given row. Used by ManageEntityClassesDelegate.

_entity_class_name_list_from_db_maps(*db_maps)[source]
class spinetoolbox.spine_db_editor.widgets.manage_items_dialogs.GetEntitiesMixin(*args, **kwargs)[source]

Provides a method to retrieve entities for AddEntitiesDialog and EditEntitiesDialog.

property class_key[source]
property dimension_name_list[source]
property class_name[source]
db_map_ent_lookup()[source]
db_map_alt_id_lookup()[source]
alternative_name_list(row)[source]

Return a list of alternative names present in all databases selected for given row. Used by ManageEntitiesDelegate.

entity_name_list(row, column)[source]

Return a list of entity names present in all databases selected for given row. Used by ManageEntitiesDelegate.

class spinetoolbox.spine_db_editor.widgets.manage_items_dialogs.ShowIconColorEditorMixin[source]

Provides methods to show an IconColorEditor upon request.

reset_data(editor)[source]

Resets the editors selections to the default state and closes the editor

show_icon_color_editor(index)[source]
contextMenuEvent(event)[source]

Shows the context menu for the display icon.