(self)
Custom behaviour for switching between steps. It is required since
        sometimes user will select different types of attributes at the same
        time. In this case we step between unchecked, partially checked and
        checked or just between unchecked and checked - depending on situation
Custom behaviour for switching between steps. It is required since
        sometimes user will select different types of attributes at the same
        time. In this case we step between unchecked, partially checked and
        checked or just between unchecked and checked - depending on situation
Custom behaviour for switching between steps . It is required since sometimes user will select different types of attributes at the same time . In this case we step between unchecked partially checked and checked or just between unchecked and checked - depending on situation
def nextCheckState(self) -> None:
        """
        Custom behaviour for switching between steps. It is required since
        sometimes user will select different types of attributes at the same
        time. In this case we step between unchecked, partially checked and
        checked or just between unchecked and checked - depending on situation
        """
        if self.checkState() == Qt.Checked:
            # if checked always uncheck
            self.setCheckState(Qt.Unchecked)
        else:
            agg = self.text()
            selected_attrs = self.parent.get_selected_attributes()
            types = set(type(attr) for attr in selected_attrs)
            can_be_applied_all = types <= AGGREGATIONS[agg].types

            # true if aggregation applied to all attributes that can be
            # aggregated with selected aggregation
            applied_all = all(
                type(attr) not in AGGREGATIONS[agg].types
                or agg in self.parent.aggregations[attr]
                for attr in selected_attrs
            )
            if self.checkState() == Qt.PartiallyChecked:
                # if partially check: 1) check if agg can be applied to all
                # 2) else uncheck if agg already applied to all
                # 3) else leve partially checked to apply to all that can be aggregated
                if can_be_applied_all:
                    self.setCheckState(Qt.Checked)
                elif applied_all:
                    self.setCheckState(Qt.Unchecked)
                else:
                    self.setCheckState(Qt.PartiallyChecked)
                    # since checkbox state stay same signal is not emitted
                    # automatically but we need a callback call so we emit it
                    self.stateChanged.emit(Qt.PartiallyChecked)
            else:  # self.checkState() == Qt.Unchecked
                # if unchecked: check if all can be checked else partially check
                self.setCheckState(
                    Qt.Checked if can_be_applied_all else Qt.PartiallyChecked
                )
def nextCheckState ( self ) -> None : if self . checkState ( ) == Qt . Checked : # if checked always uncheck self . setCheckState ( Qt . Unchecked ) else : agg = self . text ( ) selected_attrs = self . parent . get_selected_attributes ( ) types = set ( type ( attr ) for attr in selected_attrs ) can_be_applied_all = types <= AGGREGATIONS [ agg ] . types # true if aggregation applied to all attributes that can be # aggregated with selected aggregation applied_all = all ( type ( attr ) not in AGGREGATIONS [ agg ] . types or agg in self . parent . aggregations [ attr ] for attr in selected_attrs ) if self . checkState ( ) == Qt . PartiallyChecked : # if partially check: 1) check if agg can be applied to all # 2) else uncheck if agg already applied to all # 3) else leve partially checked to apply to all that can be aggregated if can_be_applied_all : self . setCheckState ( Qt . Checked ) elif applied_all : self . setCheckState ( Qt . Unchecked ) else : self . setCheckState ( Qt . PartiallyChecked ) # since checkbox state stay same signal is not emitted # automatically but we need a callback call so we emit it self . stateChanged . emit ( Qt . PartiallyChecked ) else : # self.checkState() == Qt.Unchecked # if unchecked: check if all can be checked else partially check self . setCheckState ( Qt . Checked if can_be_applied_all else Qt . PartiallyChecked )