Example #1
0
    def createEditor(self, parent: QWidget, option: QStyleOptionViewItem,
                     index: QModelIndex):
        model = index.model()
        row = index.row()
        lbl = model.message_type[row]

        if lbl.value_type_index == 2:
            line_edit = ExpressionLineEdit(parent)
            line_edit.setPlaceholderText("(item1.length + 3) ^ 0x12")
            line_edit.setCompleter(
                QCompleter(self.controller.completer_model, line_edit))
            line_edit.setValidator(
                RuleExpressionValidator(self.controller.sim_expression_parser))
            line_edit.setToolTip(
                self.controller.sim_expression_parser.formula_help)
            return line_edit
        elif lbl.value_type_index == 3:
            return ExternalProgramWidget(parent)
        elif lbl.value_type_index == 4:
            random_widget = RandomValueWidget(parent)
            random_widget.spinbox_random_min.setMaximum(lbl.fuzz_maximum - 2)
            random_widget.spinbox_random_max.setMinimum(1)
            random_widget.spinbox_random_max.setMaximum(lbl.fuzz_maximum - 1)

            return random_widget
        else:
            return super().createEditor(parent, option, index)
Example #2
0
    def test_expression_line_edit(self):
        e = ExpressionLineEdit()
        e.setCompleter(QCompleter(self.form.simulator_tab_controller.completer_model, e))
        e.setValidator(RuleExpressionValidator(self.form.simulator_tab_controller.sim_expression_parser))

        self.assertEqual(e.text(), "")
        QTest.keyClick(e, Qt.Key_R, Qt.NoModifier)
        self.assertEqual(e.text(), "r")
Example #3
0
    def test_expression_line_edit(self):
        e = ExpressionLineEdit()
        e.setCompleter(QCompleter(self.form.simulator_tab_controller.completer_model, e))
        e.setValidator(RuleExpressionValidator(self.form.simulator_tab_controller.sim_expression_parser))

        self.assertEqual(e.text(), "")
        QTest.keyClick(e, Qt.Key_R, Qt.NoModifier)
        self.assertEqual(e.text(), "r")