(self)
Remove the current selected category.

        If the item is an existing category present in the source variable it
        is marked as removed in the view. But if it was added in the set
        transformation it is removed entirely from the model and view.
Remove the current selected category.
Remove the current selected category .
def _remove_category(self):
        """
        Remove the current selected category.

        If the item is an existing category present in the source variable it
        is marked as removed in the view. But if it was added in the set
        transformation it is removed entirely from the model and view.
        """
        view = self.values_edit
        rows = view.selectionModel().selectedRows(0)
        if not rows:
            return  # pragma: no cover
        for index in rows:
            model = index.model()
            state = index.data(EditStateRole)
            pos = index.data(SourcePosRole)
            if pos is not None and pos >= 0:
                # existing level -> only mark/toggle its dropped state,
                model.setData(
                    index,
                    ItemEditState.Dropped if state != ItemEditState.Dropped
                    else ItemEditState.NoState,
                    EditStateRole)
            elif state == ItemEditState.Added:
                # new level -> remove it
                model.removeRow(index.row())
            else:
                assert False, "invalid state '{}' for {}" \
                    .format(state, index.row())
def _remove_category ( self ) : view = self . values_edit rows = view . selectionModel ( ) . selectedRows ( 0 ) if not rows : return # pragma: no cover for index in rows : model = index . model ( ) state = index . data ( EditStateRole ) pos = index . data ( SourcePosRole ) if pos is not None and pos >= 0 : # existing level -> only mark/toggle its dropped state, model . setData ( index , ItemEditState . Dropped if state != ItemEditState . Dropped else ItemEditState . NoState , EditStateRole ) elif state == ItemEditState . Added : # new level -> remove it model . removeRow ( index . row ( ) ) else : assert False , "invalid state '{}' for {}" . format ( state , index . row ( ) )