spinetoolbox.mvcmodels.project_item_specification_models

Contains a class for storing Tool specifications.

Module Contents

Classes

ProjectItemSpecificationModel

Class to store specs that are available in a project e.g. GAMS or Julia models.

FilteredSpecificationModel

class spinetoolbox.mvcmodels.project_item_specification_models.ProjectItemSpecificationModel(icons)[source]

Bases: PySide6.QtCore.QAbstractListModel

Class to store specs that are available in a project e.g. GAMS or Julia models.

specification_replaced[source]
add_specification(name)[source]

Adds a specification to the model.

Parameters

name (str) – specification’s name

remove_specification(name)[source]

Removes a specification from the model

Parameters

name (str) – specification’s name

replace_specification(old_name, new_name)[source]

Replaces a specification.

Parameters
  • old_name (str) – previous name

  • new_name (str) – new name

connect_to_project(project)[source]

Connects the model to a project.

Parameters

project (SpineToolboxProject) – project to connect to

clear()[source]
rowCount(parent=None)[source]

Returns the number of specs in the model.

Parameters

parent (QModelIndex) – Not used (because this is a list)

Returns

Number of rows (available specs) in the model

data(index, role=None)[source]

Must be reimplemented when subclassing.

Parameters
  • index (QModelIndex) – Requested index

  • role (int) – Data role

Returns

Data according to requested role

flags(index)[source]

Returns enabled flags for the given index.

Parameters

index (QModelIndex) – Index of spec

insertRow(spec_name, row=None, parent=QModelIndex())[source]

Insert row (specification) into model.

Parameters
  • spec_name (str) – name of spec added to the model

  • row (int, optional) – Row to insert spec to

  • parent (QModelIndex) – Parent of child (not used)

Returns

Void

removeRow(row, parent=QModelIndex())[source]

Remove row (spec) from model.

Parameters
  • row (int) – Row to remove the spec from

  • parent (QModelIndex) – Parent of spec on row (not used)

Returns

Boolean variable

specification(row)[source]

Returns spec on given row.

Parameters

row (int) – Row of spec specification

Returns

ProjectItemSpecification from specification list or None if given row is zero

specification_row(name)[source]

Returns the row on which the given specification is located or -1 if it is not found.

specification_index(name)[source]

Returns the QModelIndex on which a specification with the given name is located or invalid index if it is not found.

class spinetoolbox.mvcmodels.project_item_specification_models.FilteredSpecificationModel(item_type)[source]

Bases: PySide6.QtCore.QSortFilterProxyModel

filterAcceptsRow(source_row, source_parent)[source]
get_mime_data_text(index)[source]
specifications()[source]

Yields all specs.

specification(row)[source]