spinetoolbox.mvcmodels.project_item_factory_models

Contains a class for storing Tool specifications.

authors:
  1. Savolainen (VTT)
date:

23.1.2018

Module Contents

Classes

ProjectItemFactoryModel A model for listing project items in the Item Palette view.
ProjectItemSpecFactoryModel Class to store specs that are available in a project e.g. GAMS or Julia models.
FilteredSpecFactoryModel
class spinetoolbox.mvcmodels.project_item_factory_models.ProjectItemFactoryModel[source]

Bases: PySide2.QtGui.QStandardItemModel

A model for listing project items in the Item Palette view.

add_item(self, item_type, factory)[source]

Add item to model.

Parameters:
flags(self, index)[source]
static is_index_draggable(index)[source]
get_mime_data_text(self, index)[source]
class spinetoolbox.mvcmodels.project_item_factory_models.ProjectItemSpecFactoryModel(icons)[source]

Bases: PySide2.QtCore.QAbstractListModel

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

rowCount(self, 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(self, 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(self, index)[source]

Returns enabled flags for the given index.

Parameters:index (QModelIndex) – Index of spec
insertRow(self, spec, row=None, parent=QModelIndex())[source]

Insert row (specification) into model.

Parameters:
  • spec (ProjectItemSpecification) – spec added to the model
  • row (str) – Row to insert spec to
  • parent (QModelIndex) – Parent of child (not used)
Returns:

Void

removeRow(self, 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

update_specification(self, row, spec)[source]

Updates specification.

Parameters:
Returns:

Boolean value depending on the result of the operation

undo_update_specification(self, row)[source]
specification(self, row)[source]

Returns spec specification on given row.

Parameters:row (int) – Row of spec specification
Returns:ProjectItemSpecification from specification list or None if given row is zero
specifications(self)[source]

Yields all specs.

find_specification(self, name)[source]

Returns specification with the given name.

Parameters:name (str) – Name of specification to find
specification_row(self, name)[source]

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

specification_index(self, name)[source]

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

static is_index_draggable(index)[source]
get_mime_data_text(self, index)[source]
class spinetoolbox.mvcmodels.project_item_factory_models.FilteredSpecFactoryModel(item_type)[source]

Bases: PySide2.QtCore.QSortFilterProxyModel

filterAcceptsRow(self, source_row, source_parent)[source]