'Return the selected rows in the view.'

def selected_rows(self, view):

    rows = view.selectionModel().selectedRows()
    model = view.model()
    if isinstance(model, QSortFilterProxyModel):
        rows = [model.mapToSource(r) for r in rows]
    return [r.row() for r in rows]
