def source_indexes(indexes, view):
 model = view.model()
 if isinstance(model, QSortFilterProxyModel):
  return list(map(model.mapToSource, indexes))
 else:
  return indexes

def source_indexes ( indexes , view ) : model = view . model ( ) if isinstance ( model , QSortFilterProxyModel ) : return list ( map ( model . mapToSource , indexes ) ) else : return indexes
map model indexes through a views qsortfilterproxymodel .