seriesmarker.gui.model.search.search_model module

class SearchModel(parent=None)[source]

Bases: PySide.QtCore.QAbstractTableModel

This model is used to display search results in a SearchDialog.

__init__(parent=None)[source]

Initializes the model.

Parameters:parent (PySide.QtCore.QObject) – The parent of the model.
add_node(node)[source]

Appends a node to the end of the model.

Parameters:node (SearchNode) – The node to add to the model.
clear()[source]

Removes all nodes from the model.

columnCount(parent=<PySide.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0) ) >)[source]

Describes the number of columns the model is using.

Parameters:parent (QModelIndex) – The parent to return the number of columns for.
Returns:The number of columns.

Overrides QAbstractItemModel.columnCount()

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

Returns the data under the given role from the model at a given index.

Parameters:
  • index (QModelIndex) – The position of the model to get data from.
  • role (int) – Determines the kind of data to get from the model.
Returns:

The series name, at the given index, for PySide.QtCore.Qt.DisplayRole.

Returns:

The pytvdbapi.api.Show, hold by the node at the given index, for PySide.QtCore.Qt.UserRole.

Returns:

The decoration() of the node, at the given index, for PySide.QtCore.Qt.DecorationRole.

Returns:

The desired column dimension, at the given index, for PySide.QtCore.Qt.SizeHintRole.

Overrides QAbstractItemModel.data()

node_at(index)[source]

Returns the node at the given index of the model.

Parameters:index (QModelIndex) – The index to get the associated node from.

Todo

The banner_loader may cause an access to an invalid index if another search with less results was initiated before all banner were loaded. Prevent the beginning of a new search before the last has been finished, or clear the banner_loader at clearing this model. Afterwards remove the warning log. Also remove the None check at setData of this model then.

Returns:The TreeNode if a node is associated with the given index, otherwise None.
removeRows(position, rows, parent=<PySide.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0) ) >)[source]

Removes a number of nodes from a given parent, beginning at a given position.

Parameters:
  • position (int) – The index to start removing nodes from.
  • rows (int) – The number of nodes to remove from the parent.
  • parent (QModelIndex) – The parent to remove the nodes from.
Returns:

True if the nodes were successfully removed, otherwise False.

Overrides QAbstractItemModel.removeRows()

rowCount(parent=<PySide.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0) ) >)[source]

Returns the number of rows (nodes), currently added to the model.

Parameters:parent (QModelIndex) – The parent to return the number of rows for.
Returns:The number of SearchNode added to the model.

Overrides QAbstractItemModel.rowCount()

setData(index, value, role=PySide.QtCore.Qt.ItemDataRole.DecorationRole)[source]

Sets the given value of the given role at the given index.

This method is also whenever a banner was loaded to set the node’s decoration to a PySide.QtGui.Pixmap and refresh the views afterwards.

Parameters:
  • index (QModelIndex) – The position to set the value at.
  • value (PySide.QtGui.Pixmap) – Value to be set at given index.
  • role (int) – Determines the kind of data to set for the item.
Returns:

True if successful, otherwise False.

Overrides QAbstractItemModel.setData()

staticMetaObject = <PySide.QtCore.QMetaObject object>