seriesmarker.gui.model.sort_filter_proxy_model module

class SortFilterProxyModel[source]

Bases: PySide.QtGui.QSortFilterProxyModel

Class to tweak the main view.

This proxy model allows the sorting of series and visual tweaks, e.g., text alignment.

Note

This class is intended to be used as a proxy between TreeSeriesModel and the series view of MainWindow.

__init__()[source]

Initializes the proxy model.

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

Relays the method call to the source model, but may alter the result.

This method hides the decoration in the tree of the main view and aligns the names of series and seasons to the left.

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

None for PySide.QtCore.Qt.DecorationRole

Returns:

PySide.QtCore.Qt.AlignLeft for Qt.TextAlignmentRole.

Returns:

The unaltered return value of the method call on the source model for other roles.

Overrides QAbstractItemModel.data()

filterAcceptsRow(source_row, source_parent)[source]

Filters rows from the source mode to hide them in the proxy’s views.

This method hides episodes in the tree of the main view.

Parameters:
  • source_row (int) – The row-index to test for acceptance.
  • source_parent (QModelIndex) – The parent of the row to test.
Returns:

True if a described row should be displayed, otherwise False.

Overrides QSortFilterProxyModel.filterAcceptsRow()

lessThan(left, right)[source]

Defines the sort order of elements, displayed in the proxy’s view.

This method sorts SeasonNode elements by their season number, instead of their Qt.DisplayRole (which would lead to the alphanumeric sort order of ‘Season 10’ < ‘Season 2’).

This method also sorts the episodes column (column 1) by the number of total watched episodes rather than the displayed string of the column (so ‘1/7’ may come before ‘1/2’ if the related series name is also the lesser one).

Series are sorted by numerical progress first, then by total number of watched episodes and finally by series name. Completed series (progress = 100.0%) are being ignored by progress sort and added at the end of the list in alphanumerical order.

Parameters:
  • left (QModelIndex) – The index of the left item to be sorted.
  • right (QModelIndex) – The index of the right item to be sorted.
Returns:

True if the value of the item referred to by the given index left is less than the value of the item referred to by the given index right , otherwise returns false.

Overrides QSortFilterProxyModel.lessThan()

node_at(index)[source]

Relays the method call to the source model.

The relay is necessary, since the method is not part of a original Qt model. Does not alter the result.

Parameters:index (QModelIndex) – The proxy index to pass onto the source method.
Returns:The return value of the method call on the source model.

Relays the method call to the source model.

The relay is necessary, since the method is not part of a original Qt model. Does not alter the result.

Parameters:index (QModelIndex) – The proxy index to pass onto the source method.
Returns:The return value of the method call on the source model.
staticMetaObject = <PySide.QtCore.QMetaObject object>