(self, selection: Union[QModelIndex, QItemSelection], flags: int)
(De)Select given rows

        Args:
            selection (QModelIndex or QItemSelection):
                rows to select; indices are mapped to rows in the view
            flags (QItemSelectionModel.SelectionFlags):
                flags that tell whether to Clear, Select, Deselect or Toggle
(De)Select given rows
( De ) Select given rows
def select(self, selection: Union[QModelIndex, QItemSelection], flags: int):
        """
        (De)Select given rows

        Args:
            selection (QModelIndex or QItemSelection):
                rows to select; indices are mapped to rows in the view
            flags (QItemSelectionModel.SelectionFlags):
                flags that tell whether to Clear, Select, Deselect or Toggle
        """
        rows = set()
        if isinstance(selection, QModelIndex):
            if selection.model() is not None:
                rows = {selection.model().mapToSourceRows(selection.row())}
        else:
            indices = selection.indexes()
            if indices:
                map_to = indices[0].model().mapToSourceRows
                rows = set(map_to([index.row() for index in indices]))
        self.select_rows(rows, flags)
def select ( self , selection : Union [ QModelIndex , QItemSelection ] , flags : int ) : rows = set ( ) if isinstance ( selection , QModelIndex ) : if selection . model ( ) is not None : rows = { selection . model ( ) . mapToSourceRows ( selection . row ( ) ) } else : indices = selection . indexes ( ) if indices : map_to = indices [ 0 ] . model ( ) . mapToSourceRows rows = set ( map_to ( [ index . row ( ) for index in indices ] ) ) self . select_rows ( rows , flags )