Models¶
Mixed Qt model classes.
-
class
objettoqt.models.OQListModel(parent=None, headers=None, mime_type=None, **kwargs)¶ Mixed
QAbstractItemModeltype (for lists).Observes actions sent from an instance of
objetto.objects.ListObject.- Inherits from:
- Parameters
-
headersObjChanged¶ signal
Emitted when the headers object changes.
- Parameters
obj (objetto.objects.ListObject or None) – New headers list object (or None).
old_obj (objetto.objects.ListObject or None) – Old headers list object (or None).
phase (objetto.bases.Phase) – Phase.
-
headersActionReceived¶ signal
Emitted when an action is received from the headers object.
- Parameters
action (objetto.objects.Action) – Action.
phase (objetto.bases.Phase) – Phase.
-
OBase¶ read-only class attribute
Minimum objetto object base requirement.
-
_onHeadersObjChanged(obj, old_obj, phase)¶ virtual method
Called when the headers object changes.
This method is called before the
objettoqt.models.OQListModel.headersObjChangedsignal gets emitted.- Parameters
obj (objetto.objects.ListObject or None) – New headers list object (or None).
old_obj (objetto.objects.ListObject or None) – Old headers list object (or None).
phase (objetto.bases.Phase) – Phase.
-
_onHeadersActionReceived(action, phase)¶ virtual method
Called when an action is received from the headers object.
This method is called before the
objettoqt.models.OQListModel.headersActionReceivedsignal gets emitted.- Parameters
action (objetto.objects.Action) – Action.
phase (objetto.bases.Phase) – Phase.
-
headersObj()¶ final method
Get the headers object being observed.
- Returns
Headers object being observed.
- Return type
-
setHeadersObj(obj)¶ final method
Set the headers object to observe.
- Parameters
obj (objetto.objects.ListObject or None) – Headers object to observe (or None for default).
-
headersObjToken()¶ final method
Get the action observer token for the headers object.
- Returns
Action observer token for the headers object.
- Return type
-
headers()¶ final method
Get headers.
- Returns
Headers.
- Return type
-
setHeaders(headers=None)¶ final method
Set headers.
- Parameters
headers (collections.abc.Iterable[objettoqt.models.AbstractListModelHeader or str] or None) – Headers (or None for default).
-
index(row, column=0, parent=<PySide2.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>, *args, **kwargs)¶ Get index.
- Parameters
row (int) – Row.
column (int) – Column.
parent (QModelIndex) – Parent index.
- Returns
Index.
- Return type
-
parent(index=<PySide2.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>, *args, **kwargs)¶ Get invalid parent index (no valid parent indexes in a list model).
- Returns
Invalid parent index.
- Return type
-
headerData(column=None, orientation=PySide2.QtCore.Qt.Orientation.Horizontal, role=PySide2.QtCore.Qt.ItemDataRole.DisplayRole, *args, **kwargs)¶ Get header data.
- Parameters
orientation (Orientation) – Orientation.
role (ItemDataRole) – Role.
- Returns
Header data.
-
rowCount(parent=<PySide2.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>, *args, **kwargs)¶ Get value count (row count).
- Returns
Value count (row count).
- Return type
-
flags(index=<PySide2.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>, *args, **kwargs)¶ Get flags.
- Parameters
index (QModelIndex) – Index.
- Returns
Flags.
- Return type
-
data(index=<PySide2.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>, role=PySide2.QtCore.Qt.ItemDataRole.DisplayRole)¶ Get data.
- Parameters
index (QModelIndex) – Index.
role (ItemDataRole) – Role.
- Returns
Data.
-
mimeData(indexes)¶ Get mime data stream.
- Parameters
indexes (collections.abc.Iterable[QModelIndex]) – Indexes.
- Returns
Mime data stream.
- Return type
-
supportedDropActions()¶ Get supported drop actions.
- Returns
Supported drop actions.
- Return type
-
supportedDragActions()¶ Get supported drag actions.
- Returns
Supported drag actions.
- Return type
-
dropMimeData(data, action, row, column, parent=<PySide2.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>)¶ Handle dropped mime data stream.
- Parameters
data (QMimeData) – Mime data stream.
action (DropAction) – Drop action.
row (int) – Row.
column (int) – Column.
parent (QModelIndex) – Parent index.
- Returns
True if handled it.
- Return type
-
class
objettoqt.models.AbstractListModelHeader(**initial)¶ (abstract class)
To be used with
objettoqt.models.OQListModel. Carries information on how the value should be retrieved for a column.- Inherits from:
objetto.InteractiveData
-
flags(obj, row)¶ virtual method
Retrieve flags for an item at a specific row.
- Parameters
obj (objetto.objects.ListObject) – List object.
row (int) – Row.
- Returns
Flags.
- Return type
-
abstract
data(obj, row, role=PySide2.QtCore.Qt.ItemDataRole.DisplayRole)¶ abstract method
Retrieve data for an item at a specific row.
- Parameters
obj (objetto.objects.ListObject) – List object.
row (int) – Row.
role (ItemDataRole) – Role.
- Returns
Data.
-
class
objettoqt.models.ListModelHeader(**initial)¶ To be used with
objettoqt.models.OQListModel. Carries information on how the value should be retrieved for a column.For the
QtCore.Qt.DisplayRole, this implementation will use theobjettoqt.models.AbstractListModelHeader.titleas the attribute name that will be queried from the source object at the row.The fallback value will be returned if a title is provided and the object at the row does not have an attribute with the same name as the title.
In the case an empty title is provided (default behavior), a string representation of the object at the row will be returned.
The source object at the row can be accesed through the
QtCore.Qt.UserRole.- Inherits from:
-
flags(obj, row)¶ Retrieve flags for an item at a specific row.
- Parameters
obj (objetto.objects.ListObject) – List object.
row (int) – Row.
- Returns
Flags.
- Return type
-
data(obj, row, role=PySide2.QtCore.Qt.ItemDataRole.DisplayRole)¶ Retrieve data for an item at a specific row.
- Parameters
obj (objetto.objects.ListObject) – List object.
row (int) – Row.
role (ItemDataRole) – Role.
- Returns
Data.
- Return type