def set_decoding(self, decoding: Encoding, messages=None):
        """

        :param decoding:
        :param messages: None = set for all messages
        :return:
        """
        if decoding is None:
            self.show_decoding_clicked.emit()
        else:
            if messages is None:
                messages = self.proto_analyzer.messages
                if len(messages) > 10:
                    reply = QMessageBox.question(self, "Set decoding",
                                                 "Do you want to apply the selected decoding to {} messages?".format(
                                                     len(messages)), QMessageBox.Yes | QMessageBox.No)
                    if reply != QMessageBox.Yes:
                        self.ui.cbDecoding.blockSignals(True)
                        self.ui.cbDecoding.setCurrentText("...")
                        self.ui.cbDecoding.blockSignals(False)
                        return

            self.show_all_cols()

            for msg in messages:
                msg.decoder = decoding

            self.ui.tblViewProtocol.zero_hide_offsets.clear()
            self.clear_search()

            selected = self.ui.tblViewProtocol.selectionModel().selection()

            if not selected.isEmpty() and self.isVisible() and self.proto_analyzer.num_messages > 0:
                min_row = min(rng.top() for rng in selected)
                min_row = min_row if min_row < len(self.proto_analyzer.messages) else -1
                try:
                    msg = self.proto_analyzer.messages[min_row]
                except IndexError:
                    msg = None
                self.__set_decoding_error_label(msg)
            else:
                self.__set_decoding_error_label(None)

            self.protocol_model.update()
            self.message_type_table_model.update()
            self.label_value_model.update()

            for lbl in self.proto_analyzer.protocol_labels:
                self.set_protocol_label_visibility(lbl)

            self.ui.tblViewProtocol.resize_columns()
def set_decoding ( self , decoding : Encoding , messages = None ) : if decoding is None : self . show_decoding_clicked . emit ( ) else : if messages is None : messages = self . proto_analyzer . messages if len ( messages ) > 10 : reply = QMessageBox . question ( self , "Set decoding" , "Do you want to apply the selected decoding to {} messages?" . format ( len ( messages ) ) , QMessageBox . Yes | QMessageBox . No ) if reply != QMessageBox . Yes : self . ui . cbDecoding . blockSignals ( True ) self . ui . cbDecoding . setCurrentText ( "..." ) self . ui . cbDecoding . blockSignals ( False ) return self . show_all_cols ( ) for msg in messages : msg . decoder = decoding self . ui . tblViewProtocol . zero_hide_offsets . clear ( ) self . clear_search ( ) selected = self . ui . tblViewProtocol . selectionModel ( ) . selection ( ) if not selected . isEmpty ( ) and self . isVisible ( ) and self . proto_analyzer . num_messages > 0 : min_row = min ( rng . top ( ) for rng in selected ) min_row = min_row if min_row < len ( self . proto_analyzer . messages ) else - 1 try : msg = self . proto_analyzer . messages [ min_row ] except IndexError : msg = None self . __set_decoding_error_label ( msg ) else : self . __set_decoding_error_label ( None ) self . protocol_model . update ( ) self . message_type_table_model . update ( ) self . label_value_model . update ( ) for lbl in self . proto_analyzer . protocol_labels : self . set_protocol_label_visibility ( lbl ) self . ui . tblViewProtocol . resize_columns ( )
:param decoding:
        :param messages: None = set for all messages
        :return: