(self)
Merge less common categories into one with the dialog for merge
        selection.
Merge less common categories into one with the dialog for merge
        selection.
Merge less common categories into one with the dialog for merge selection .
def _merge_categories(self) -> None:
        """
        Merge less common categories into one with the dialog for merge
        selection.
        """
        view = self.values_edit
        model = view.model()  # type: QAbstractItemModel

        selected_attributes = [ind.data(SourceNameRole)
                               for ind in view.selectedIndexes()]
        dlg = GroupItemsDialog(
            self.var, self._values, selected_attributes,
            self.merge_dialog_settings.get(self.var, {}), self,
            windowTitle="Import Options",
            sizeGripEnabled=True,
        )
        dlg.setWindowModality(Qt.WindowModal)
        status = dlg.exec()
        dlg.deleteLater()
        self.merge_dialog_settings[self.var] = dlg.get_dialog_settings()

        rows = (model.index(i, 0) for i in range(model.rowCount()))

        def complete_merge(text, merge_attributes):
            # write the new text for edit role in all rows
            with disconnected(model.dataChanged, self.on_values_changed):
                for row in rows:
                    if row.data(SourceNameRole) in merge_attributes:
                        model.setData(row, text, Qt.EditRole)
            self.variable_changed.emit()

        if status == QDialog.Accepted:
            complete_merge(
                dlg.get_merged_value_name(), dlg.get_merge_attributes()
            )
def _merge_categories ( self ) -> None : view = self . values_edit model = view . model ( ) # type: QAbstractItemModel selected_attributes = [ ind . data ( SourceNameRole ) for ind in view . selectedIndexes ( ) ] dlg = GroupItemsDialog ( self . var , self . _values , selected_attributes , self . merge_dialog_settings . get ( self . var , { } ) , self , windowTitle = "Import Options" , sizeGripEnabled = True , ) dlg . setWindowModality ( Qt . WindowModal ) status = dlg . exec ( ) dlg . deleteLater ( ) self . merge_dialog_settings [ self . var ] = dlg . get_dialog_settings ( ) rows = ( model . index ( i , 0 ) for i in range ( model . rowCount ( ) ) ) def complete_merge ( text , merge_attributes ) : # write the new text for edit role in all rows with disconnected ( model . dataChanged , self . on_values_changed ) : for row in rows : if row . data ( SourceNameRole ) in merge_attributes : model . setData ( row , text , Qt . EditRole ) self . variable_changed . emit ( ) if status == QDialog . Accepted : complete_merge ( dlg . get_merged_value_name ( ) , dlg . get_merge_attributes ( ) )