def source_model(view):
 if isinstance(view.model(), QSortFilterProxyModel):
  return view.model().sourceModel()
 else:
  return view.model()

def source_model ( view ) : if isinstance ( view . model ( ) , QSortFilterProxyModel ) : return view . model ( ) . sourceModel ( ) else : return view . model ( )
return the source model for the qt item view if it uses the qsortfilterproxymodel .