def __init__(self, preselected_index, message: Message, viewtype: int, parent=None): super().__init__(parent) self.ui = Ui_DialogLabels() self.ui.setupUi(self) field_types = FieldType.load_from_xml() self.model = PLabelTableModel(message, field_types) self.preselected_index = preselected_index self.ui.tblViewProtoLabels.setItemDelegateForColumn( 0, ComboBoxDelegate([ft.caption for ft in field_types], is_editable=True, return_index=False, parent=self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn( 1, SpinBoxDelegate(1, len(message), self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn( 2, SpinBoxDelegate(1, len(message), self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn( 3, ComboBoxDelegate([""] * len(constants.LABEL_COLORS), colors=constants.LABEL_COLORS, parent=self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn( 4, CheckBoxDelegate(self)) self.ui.tblViewProtoLabels.setModel(self.model) self.ui.tblViewProtoLabels.selectRow(preselected_index) self.ui.tblViewProtoLabels.setEditTriggers( QAbstractItemView.AllEditTriggers) self.ui.tblViewProtoLabels.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) self.ui.tblViewProtoLabels.resizeColumnsToContents() self.setWindowFlags(Qt.Window) self.setWindowTitle( self.tr("Edit Protocol Labels from message type %s") % message.message_type.name) self.configure_special_config_tabs() self.ui.splitter.setSizes([self.height() / 2, self.height() / 2]) self.create_connects() self.ui.cbProtoView.setCurrentIndex(viewtype) self.setAttribute(Qt.WA_DeleteOnClose) try: self.restoreGeometry( constants.SETTINGS.value("{}/geometry".format( self.__class__.__name__))) except TypeError: pass for i in range(self.model.rowCount()): self.open_editors(i)
def __init__(self, preselected_index, proto_group: ProtocolGroup, offset: int, viewtype: int, parent=None): super().__init__(parent) self.ui = Ui_DialogLabels() self.ui.setupUi(self) self.model = PLabelTableModel(proto_group, offset) self.preselected_index = preselected_index if proto_group.num_blocks > 0: maxval = numpy.max([len(block) for block in proto_group.decoded_bits_str]) else: maxval = 42000 self.ui.tblViewProtoLabels.setItemDelegateForColumn(1, SpinBoxDelegate(1, maxval, self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn(2, SpinBoxDelegate(1, maxval, self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn(3, CheckBoxDelegate(self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn(4, SpinBoxDelegate(offset+1, offset+proto_group.num_blocks, self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn(5, ComboBoxDelegate([""] * len(constants.LABEL_COLORS), True, self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn(6, CheckBoxDelegate(self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn(7, DeleteButtonDelegate(self)) self.ui.tblViewProtoLabels.setModel(self.model) self.ui.tblViewProtoLabels.selectRow(preselected_index) for i in range(self.model.row_count): self.openEditors(i) self.ui.tblViewProtoLabels.resizeColumnsToContents() self.setWindowTitle(self.tr("Edit Protocol Labels from %s") % proto_group.name) self.create_connects() self.ui.cbProtoView.setCurrentIndex(viewtype) self.setAttribute(Qt.WA_DeleteOnClose)
def __init__(self, preselected_index, message_type: MessageType, viewtype: int, max_end: int, parent=None): super().__init__(parent) self.ui = Ui_DialogLabels() self.ui.setupUi(self) field_types = FieldType.load_from_xml() self.model = PLabelTableModel(message_type, field_types) self.preselected_index = preselected_index self.ui.tblViewProtoLabels.setItemDelegateForColumn( 0, ComboBoxDelegate([ft.caption for ft in field_types], is_editable=True, return_index=False, parent=self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn( 1, SpinBoxDelegate(1, max_end, self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn( 2, SpinBoxDelegate(1, max_end, self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn( 3, ComboBoxDelegate([""] * len(constants.LABEL_COLORS), colors=constants.LABEL_COLORS, parent=self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn( 4, CheckBoxDelegate(self)) self.ui.tblViewProtoLabels.setModel(self.model) self.ui.tblViewProtoLabels.selectRow(preselected_index) self.ui.tblViewProtoLabels.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) for i in range(self.model.row_count): self.open_editors(i) self.ui.tblViewProtoLabels.resizeColumnsToContents() self.setWindowTitle( self.tr("Edit Protocol Labels from %s") % message_type.name) self.create_connects() self.ui.cbProtoView.setCurrentIndex(viewtype) self.setAttribute(Qt.WA_DeleteOnClose)