(self)
Restore the selection on the table view from saved settings.
Restore the selection on the table view from saved settings.
Restore the selection on the table view from saved settings .
def __restore_selection(self):
        """Restore the selection on the table view from saved settings."""
        selection_model = self.table_view.selectionModel()
        selection = QItemSelection()
        if self.selected_vars:
            var_indices = {var: i for i, var in enumerate(self.model.variables)}
            selected_indices = [var_indices[var] for var in self.selected_vars]
            for row in self.model.mapFromSourceRows(selected_indices):
                selection.append(QItemSelectionRange(
                    self.model.index(row, 0),
                    self.model.index(row, self.model.columnCount() - 1)
                ))
        selection_model.select(selection, QItemSelectionModel.ClearAndSelect)
def __restore_selection ( self ) : selection_model = self . table_view . selectionModel ( ) selection = QItemSelection ( ) if self . selected_vars : var_indices = { var : i for i , var in enumerate ( self . model . variables ) } selected_indices = [ var_indices [ var ] for var in self . selected_vars ] for row in self . model . mapFromSourceRows ( selected_indices ) : selection . append ( QItemSelectionRange ( self . model . index ( row , 0 ) , self . model . index ( row , self . model . columnCount ( ) - 1 ) ) ) selection_model . select ( selection , QItemSelectionModel . ClearAndSelect )