spinetoolbox.spine_db_editor.mvcmodels.empty_models

Empty models for parameter definitions and values.

Module Contents

Classes

EmptyModelBase

Base class for all empty models that go in a CompoundModelBase subclass.

ParameterMixin

EntityMixin

EmptyParameterDefinitionModel

An empty parameter_definition model.

EmptyParameterValueModel

An empty parameter_value model.

EmptyEntityAlternativeModel

Makes relationships on the fly.

class spinetoolbox.spine_db_editor.mvcmodels.empty_models.EmptyModelBase(parent)[source]

Bases: spinetoolbox.mvcmodels.empty_row_model.EmptyRowModel

Base class for all empty models that go in a CompoundModelBase subclass.

Parameters

parent (CompoundModelBase) – the parent model

abstract property item_type[source]
property field_map[source]
property can_be_filtered[source]
add_items_to_db(db_map_data)[source]

Add items to db.

Parameters

db_map_data (dict) – mapping DiffDatabaseMapping instance to list of items

abstract _make_unique_id(item)[source]

Returns a unique id for the given model item (name-based). Used by handle_items_added to identify which rows have been added and thus need to be removed.

accepted_rows()[source]
db_item(_index)[source]
item_id(_row)[source]
handle_items_added(db_map_data)[source]

Runs when parameter definitions or values are added. Finds and removes model items that were successfully added to the db.

batch_set_data(indexes, data)[source]

Sets data for indexes in batch. If successful, add items to db.

_autocomplete_row(db_map, item)[source]

Fills in entity_class_name whenever other selections make it obvious.

abstract _entity_class_name_candidates(db_map, item)[source]
_make_item(row)[source]
_make_db_map_data(rows)[source]

Returns model data grouped by database map.

Parameters

rows (set) – group data from these rows

Returns

mapping DiffDatabaseMapping instance to list of items

Return type

dict

data(index, role=Qt.ItemDataRole.DisplayRole)[source]

Returns the data stored under the given role for the item referred to by the index.

Parameters
  • index (QModelIndex) – Index of item

  • role (int) – Data role

Returns

Item data for given role.

class spinetoolbox.spine_db_editor.mvcmodels.empty_models.ParameterMixin[source]
property value_field[source]
data(index, role=Qt.ItemDataRole.DisplayRole)[source]
static _entity_class_name_candidates_by_parameter(db_map, item)[source]
class spinetoolbox.spine_db_editor.mvcmodels.empty_models.EntityMixin[source]
abstract _do_add_items_to_db(db_map_items)[source]
add_items_to_db(db_map_data)[source]

Overriden to add entities on the fly first.

_make_item(row)[source]
static _entity_class_name_candidates_by_entity(db_map, item)[source]
class spinetoolbox.spine_db_editor.mvcmodels.empty_models.EmptyParameterDefinitionModel(parent)[source]

Bases: spinetoolbox.spine_db_editor.mvcmodels.single_and_empty_model_mixins.SplitValueAndTypeMixin, ParameterMixin, EmptyModelBase

An empty parameter_definition model.

Parameters

parent (CompoundModelBase) – the parent model

property item_type[source]
_make_unique_id(item)[source]

Returns a unique id for the given model item (name-based). Used by handle_items_added to identify which rows have been added and thus need to be removed.

static _check_item(item)[source]

Checks if a db item is ready to be inserted.

_entity_class_name_candidates(db_map, item)[source]
_do_add_items_to_db(db_map_items)[source]
class spinetoolbox.spine_db_editor.mvcmodels.empty_models.EmptyParameterValueModel(parent)[source]

Bases: spinetoolbox.spine_db_editor.mvcmodels.single_and_empty_model_mixins.MakeEntityOnTheFlyMixin, spinetoolbox.spine_db_editor.mvcmodels.single_and_empty_model_mixins.SplitValueAndTypeMixin, ParameterMixin, EntityMixin, EmptyModelBase

An empty parameter_value model.

Parameters

parent (CompoundModelBase) – the parent model

property item_type[source]
static _check_item(item)[source]

Checks if a db item is ready to be inserted.

_make_unique_id(item)[source]

Returns a unique id for the given model item (name-based). Used by handle_items_added to identify which rows have been added and thus need to be removed.

_do_add_items_to_db(db_map_items)[source]
_entity_class_name_candidates(db_map, item)[source]
class spinetoolbox.spine_db_editor.mvcmodels.empty_models.EmptyEntityAlternativeModel(parent)[source]

Bases: spinetoolbox.spine_db_editor.mvcmodels.single_and_empty_model_mixins.MakeEntityOnTheFlyMixin, EntityMixin, EmptyModelBase

Makes relationships on the fly.

Parameters

parent (CompoundModelBase) – the parent model

property item_type[source]
static _check_item(item)[source]

Checks if a db item is ready to be inserted.

_make_unique_id(item)[source]

Returns a unique id for the given model item (name-based). Used by handle_items_added to identify which rows have been added and thus need to be removed.

_do_add_items_to_db(db_map_items)[source]
_entity_class_name_candidates(db_map, item)[source]