insarviz.view.schema.Schema module

class insarviz.view.schema.Schema.Schema[source]

Bases: object

Abtract class for schemas.

When creating an item model for Qt (to show in QAbstractItemViews), you need to provide a way to represent an underlying data structure as a QAbstractItemModel.

A schema is a sort of translation layer between a Python structure (a list, a class, or a plain data type) and a QAbstractItemModel. It describes the shape of the structure in a way that Qt can navigate.

Qt’s tree model is rather simple, albeit a bit cumbersome for complex structures : every level of a tree is a node that can provide some data (through the ‘data’ function), and may contain sub-nodes. A QModelIndex is a sort of pointer into such a tree. From a given QModelIndex, Qt should be able to access its data, parent, and children, which allows it access to the whole structure.

A schema, at its core, simply takes values of some type, and for each value creates a ‘Node’ object that provides all the above information for that value.

class Node(item_model: QAbstractItemModel, schema: Parent)[source]

Bases: QObject, Generic

The base Schema.Node class.

This class provides all the default behaviour of an empty QAbstractItemModel tree, as needed by the SchemaItemModel and SchemaItemDelegate classes.

TODO_DOC

beginInsertRows
beginRemoveRows
beginReplaceRows
cached_child(row, column)[source]
property cached_children
can_mime_import_child(__mimeData__, __action__, __row__, __column__, /, **kwargs) bool[source]

Check whether the data can be inserted as a child of this node

can_mime_import_self(mimeData: QMimeData, __action__: DropAction, **kwargs) bool[source]

Check whether the data is in a suitable format for importing into this node

child(row: int, column: int) Node[source]
columnCount() int[source]
context_menu(parent_widget) QMenu | None[source]
createEditor(__parent__: QWidget, /) QWidget | None[source]
create_child_node(__row__: int, __column__: int, /) Node[source]
data(__role__: ItemDataRole, /)[source]
dataChanged
destroyEditor() bool[source]
editor() QWidget | None[source]
endInsertRows
endRemoveRows
endReplaceRows
flags()[source]
item_model() QAbstractItemModel[source]
mime_export() QMimeData | None[source]

Produce a QMimeData containing a serialized representation of the model, or None if the model can’t be dragged

mime_import_child(__mimeData__, __action__, __row__, __column__, /, **kwargs) bool[source]

Insert the given data as a child of this node. Return True if the import succeeded

mime_import_self(mimeData: QMimeData, __action__: DropAction, **kwargs) bool[source]

Import the given data into the model. Return True if the import succeeded

model: Model
paint(__painter__: QPainter, __option__: QStyleOption, /) bool[source]
parent_index()[source]
removeRows(__row__: int, __count__: int, /) bool[source]
requestModelChange
rowCount() int[source]
self_index()[source]
setData(__value__: Any, __role__: ItemDataRole, /) bool[source]
setEditorData(__editor__: QWidget, /) bool[source]
setModelData(__editor__: QWidget, /) bool[source]
set_model(model: Any)[source]

Change the underlying model for this node.

May be reimplemented by subclasses, depending on whether the node needs to be connected/disconnected to signals from the model.

Usually, when resetting the model, you’d first disconnect from the previous model, then call super().set_model(model), and finally connect to the new model.

staticMetaObject = PySide6.QtCore.QMetaObject("Node" inherits "QObject": Methods:   #4 type=Signal, signature=requestModelChange(PyObject), parameters=PyObject   #5 type=Signal, signature=dataChanged(QVariantList), parameters=QVariantList   #6 type=Signal, signature=beginRemoveRows(int,int), parameters=int, int   #7 type=Signal, signature=endRemoveRows(int,int), parameters=int, int   #8 type=Signal, signature=beginInsertRows(int,int), parameters=int, int   #9 type=Signal, signature=endInsertRows(int,int), parameters=int, int   #10 type=Signal, signature=beginReplaceRows(int,int), parameters=int, int   #11 type=Signal, signature=endReplaceRows(int,int), parameters=int, int   #12 type=Slot, signature=_on_data_changed(QVariantList), parameters=QVariantList   #13 type=Slot, signature=_on_begin_remove_rows(int,int), parameters=int, int   #14 type=Slot, signature=_on_end_remove_rows(int,int), parameters=int, int   #15 type=Slot, signature=_on_begin_insert_rows(int,int), parameters=int, int   #16 type=Slot, signature=_on_end_insert_rows(int,int), parameters=int, int )
can_mime_from_model(__model__: Any, /) bool[source]
can_model_from_mime(__mimeData__: QMimeData, /, **kwargs) bool[source]
make_node(item_model: QAbstractItemModel, __model__: Any, /) Node[source]
mime_from_model(__model__: Any, /) QMimeData | None[source]
model_from_mime(__mimeData__: QMimeData, /, **kwargs) Any | None[source]
supported_mime_types() set[str][source]