Example #1
0
 def setModelData(
     self,
     editor: QtWidgets.QComboBox,
     model: QtCore.QAbstractItemModel,
     index: QtCore.QModelIndex,
 ) -> None:
     model.setData(index, editor.currentText(), Qt.EditRole)
Example #2
0
 def draw_grid(self, data):
     item_model = QAbstractItemModel()
     i = 0
     for key in data:
         item_model.setData(i, {key: data[key]})
     table_view.setModel(item_model)
     table_view.show()
Example #3
0
 def setModelData(self, editor: QComboBox, model: QAbstractItemModel,
                  index: QModelIndex) -> None:
     if index.column() == 0:
         model.setData(index, editor.currentText())
     else:
         return super(ComboBoxDelegate,
                      self).setModelData(editor, model, index)
Example #4
0
    def setModelData(self, widget: QtWidgets.QWidget,
                     model: QtCore.QAbstractItemModel, index):

        if isinstance(widget, options.CustomItemWidget):
            model.setData(index, widget.data)
            return
        super().setModelData(widget, model, index)
Example #5
0
 def setModelData(self, editor: QWidget, model: QAbstractItemModel, index: QModelIndex):
     if isinstance(editor, ExternalProgramWidget):
         model.setData(index, editor.extProgramLineEdit.text(), Qt.EditRole)
     elif isinstance(editor, RandomValueWidget):
         model.setData(index, [editor.spinBoxRandomMin.value(), editor.spinBoxRandomMax.value()], Qt.EditRole)
     else:
         super().setModelData(editor, model, index)
Example #6
0
 def setModelData(self, editor: QWidget, model: QAbstractItemModel,
                  index: QModelIndex):
     # change the state of the checkbox, i.e. if the current state is
     # unchecked send the value 1 to the model.setData, otherwise send 0
     model.setData(
         index, 1 if index.data(Qt.CheckStateRole) == Qt.Unchecked else 0,
         Qt.EditRole)
Example #7
0
 def setModelData(self, editor: QWidget, model: QAbstractItemModel,
                  qindex: QModelIndex):
     if isinstance(editor, QComboBox):
         value = editor.currentData(Qt.UserRole)
         model.setData(qindex, value, Qt.EditRole)
     else:
         super().setModelData(editor, model, qindex)
Example #8
0
 def setModelData(self, editor: QWidget, model: QAbstractItemModel,
                  index: QModelIndex) -> None:
     if index.column() == 0:
         editor.interpretText()
         model.setData(index, editor.value(), Qt.EditRole)
     else:
         return super(SpinBoxDelegate,
                      self).setModelData(editor, model, index)
Example #9
0
 def setModelData(self, editor: QtWidgets.QWidget, treeview_model: QtCore.QAbstractItemModel,
                  index: QtCore.QModelIndex) -> None:
     (amount, range_amount), ok = self._editor.amount()
     if ok:
         unit_string = self._editor.unitComboBox.currentText().strip()
         treeview_model.setData(index, ((amount, range_amount), unit_string), QtCore.Qt.UserRole)
     else:
         self.illegalValue.emit(self._editor.amountLineEdit.text())
    def setModelData(self, editor: QWidget, model: QtCore.QAbstractItemModel,
                     index: QtCore.QModelIndex):
        print("setModelData works")
        if editor.text() != "":
            model.setData(index, editor.text(), Qt.EditRole)

        else:
            model.removeRows(index.row())
Example #11
0
 def setModelData(self, editor: QWidget, model: QAbstractItemModel, index: QModelIndex) -> None:
     # if index.data():
     #     model.setData(index, str(self.mTxt_address.text()))
     # print(index.data())
     if isinstance(editor, FileAddressEditor):
         model.setData(index, editor.text())
     else:
         super(addressTableDelegate, self).setModelData(editor, model, index)
Example #12
0
    def setModelData(  # pylint: disable=C0103
            self, widget: QtWidgets.QWidget, model: QtCore.QAbstractItemModel,
            index: QtCore.QModelIndex) -> None:

        if isinstance(widget, widgets.CustomItemWidget):
            model.setData(index, widget.data)
            return
        super().setModelData(widget, model, index)
Example #13
0
    def setModelData(self, widget: QtWidgets.QComboBox,
                     model: QtCore.QAbstractItemModel,
                     index: QtCore.QModelIndex):
        record: collection.PackageObject = model.data(index, role=Qt.UserRole)
        record.component_metadata[
            collection.Metadata.TITLE_PAGE] = widget.currentText()

        model.setData(index, record, role=Qt.UserRole)
    def setModelData(  # pylint: disable=C0103,R0201
            self, widget: QtWidgets.QWidget, model: QtCore.QAbstractItemModel,
            index: QtCore.QModelIndex) -> None:
        """Set model data."""
        record: collection.PackageObject = model.data(index, role=Qt.UserRole)
        record.component_metadata[
            collection.Metadata.TITLE_PAGE] = widget.currentText()

        model.setData(index, record, role=Qt.UserRole)
Example #15
0
 def setModelData(self, editor: QWidget, model: QAbstractItemModel,
                  index: QModelIndex) -> None:
     if isinstance(editor, FileAddressEditor):
         model.setData(index, editor.text())
     elif isinstance(editor, QComboBox):
         model.setData(index, editor.currentText())
         # print(editor.currentText())
     else:
         super(xyfieldDelegate, self).setModelData(editor, model, index)
 def setModelData(self, wrapper: QWidget, model: QtCore.QAbstractItemModel,
                  index: QtCore.QModelIndex) -> None:
     editor: AbstractDialogFormDelegate.Editor = wrapper.editor
     for i in range(editor.form.rowCount()):
         item: QLayoutItem = editor.form.itemAt(i, QFormLayout.FieldRole)
         if not item:
             continue
         spinbox = item.widget()
         label: QLabel = editor.form.labelForField(spinbox)
         label.setWordWrap(True)
         model.setData(index, (label.text(), spinbox.value()), Qt.EditRole)
Example #17
0
 def setModelData(
         self,
         editor: QtWidgets.QWidget,
         model: QtCore.QAbstractItemModel,
         index: QtCore.QModelIndex
 ) -> None:
     assert isinstance(model, ObjectListModel)
     col_spec = self.__columns[index.column()]
     obj = model.object(index.row())
     value = col_spec.editorValue(obj, editor)
     model.setData(index, value)
Example #18
0
 def setModelData(self, editor: QWidget, model: QAbstractItemModel,
                  index: QModelIndex):
     """
     Sets data from editor back to model.
     :param editor: Editor.
     :param model: Model.
     :param index: Model's index.
     """
     value = editor.value()
     model.setData(index, value)
     Tools.write_verbose_class_method_name(
         self, ItemDelegateSpinBoxEdit.setModelData, "value", str(value))
Example #19
0
 def setModelData(self, editor: QWidget, model: QAbstractItemModel,
                  index: QModelIndex):
     if isinstance(editor, ExternalProgramWidget):
         model.setData(index, editor.line_edit_external_program.text(),
                       Qt.EditRole)
     elif isinstance(editor, RandomValueWidget):
         model.setData(index, [
             editor.spinbox_random_min.value(),
             editor.spinbox_random_max.value()
         ], Qt.EditRole)
     else:
         super().setModelData(editor, model, index)
Example #20
0
 def setModelData(self, editor: QWidget, model: QAbstractItemModel,
                  index: QModelIndex):
     """
     Sets data from editor back to model.
     :param editor: Editor.
     :param model: Model.
     :param index: Model's index.
     """
     date = editor.date().toString(Resources.FORMAT_DATE_STORE)
     model.setData(index, date)
     Tools.write_verbose_class_method_name(
         self, ItemDelegateDateEdit.setModelData, "date", str(date))
Example #21
0
 def setModelData(
     self, editor: QWidget, model: QAbstractItemModel, index: QModelIndex
 ) -> None:
     """
     The user wants the opposite state
     """
     model.setData(
         index,
         Qt.Unchecked
         if (index.data(Qt.CheckStateRole)) == Qt.Checked
         else Qt.Checked,
         Qt.CheckStateRole,
     )
Example #22
0
    def setModelData(self, editor: QtWidgets.QComboBox,
                     model: QtCore.QAbstractItemModel,
                     index: QtCore.QModelIndex):
        """Update the model from the editor.

        :param editor: the editor widget
        :type editor: QtWidgets.QComboBox
        :param model: the model
        :type model: SequenceModel
        :param index: the model index
        :type index: QtCore.QModelIndex
        """
        model.setData(index, editor.currentText(), QtCore.Qt.EditRole)
Example #23
0
def add_row(model: QAbstractItemModel, param: tuple):
    """
    @param: model
    @param: param - tuple(row, model data, user data)
    """
    row_num = param[0]
    row = param[1]
    user_data = param[2]
    model.insertRow(row_num)
    if user_data:
        model.setData(model.index(row_num, 0), user_data, Qt.UserRole)

    for k, item in enumerate(row):
        model.setData(model.index(row_num, k), item if item else "")
Example #24
0
 def setModelData(
     self,
     editor: QSpinBox,
     model: QAbstractItemModel,
     idx: QModelIndex,
 ):
     editor.interpretText()
     currentValue = idx.model().data(idx, Qt.EditRole)
     newValue = editor.value() - 1
     if newValue == currentValue:
         return
     if newValue > currentValue:
         newValue = newValue + 1
     model.setData(idx, newValue, Qt.EditRole)
 def setModelData(self, editor: QWidget, model: QAbstractItemModel,
                  model_index: QModelIndex):
     column = model_index.column()
     if column == NAME_COL:  # Part Name
         text_QString = editor.text()
         model.setData(model_index, text_QString, Qt.EditRole)
     # elif column == VISIBLE_COL: # Visibility
     #     value = editor.isChecked()
     #     model.setData(model_index, value, Qt.EditRole)
     elif column == COLOR_COL:  # Color
         color = editor.currentColor()
         model.setData(model_index, color.name(), Qt.EditRole)
     else:
         QStyledItemDelegate.setModelData(self, editor, model, model_index)
Example #26
0
 def setModelData(self, editor: QWidget,
                         model: QAbstractItemModel,
                         model_index: QModelIndex):
     column = model_index.column()
     if column == NAME_COL:  # Part Name
         text_QString = editor.text()
         model.setData(model_index, text_QString, Qt.EditRole)
     # elif column == VISIBLE_COL: # Visibility
     #     value = editor.isChecked()
     #     model.setData(model_index, value, Qt.EditRole)
     elif column == COLOR_COL:  # Color
         color = editor.currentColor()
         model.setData(model_index, color.name(), Qt.EditRole)
     else:
         QStyledItemDelegate.setModelData(self, editor, model, model_index)
Example #27
0
    def setModelData(self, editor: QWidget, model: QAbstractItemModel,
                     index: QModelIndex):
        """Invoked ad the end of the editing session; data transferred from the editor to the model"""
        register = self._get_register_from_index(index)

        if isinstance(editor, QComboBox):
            assert self._can_use_bool_switch(register)
            # >>> int('1')
            # 1
            # >>> bool(int(False))
            # False
            # >>> bool('False')
            # True
            # Wait what?!
            value = bool(editor.currentIndex())
            _logger.info("Value %r has been interpreted as %r",
                         editor.currentText(), value)
        elif isinstance(editor, (QDoubleSpinBox, QSpinBox)):
            assert self._can_use_spinbox(register)
            editor.interpretText()  # Beware!!1
            value = editor.value()
        elif isinstance(editor, QPlainTextEdit):
            assert not self._can_use_spinbox(register)
            text = editor.toPlainText()
            try:
                value = parse_value(text, register.type_id)
            except Exception as ex:
                _logger.warning("The following value could not be parsed: %r",
                                text,
                                exc_info=True)
                show_error(
                    "Invalid value",
                    "Could not parse the entered value",
                    repr(ex),
                    editor.window(),
                )
                value = None
        else:
            raise TypeError(f"Unexpected editor: {editor}")

        # We're not going to touch the device here; instead, we're going to delegate that back to the Model instance.
        if value is not None:
            model.setData(index, value, Qt.EditRole)
    def setModelData(self, editor: QWidget, model: QAbstractItemModel, proxy_index: QModelIndex):

        src_index = self._proxy.mapToSource(proxy_index)
        tree_item = src_index.internalPointer()
        feature = tree_item.own_data[0]
        interface_type = feature.node.principal_interface_type

        if interface_type == EInterfaceType.intfIInteger:
            data = editor.value()
            model.setData(proxy_index, data)
        elif interface_type == EInterfaceType.intfIBoolean:
            data = editor.currentText()
            model.setData(proxy_index, data)
        elif interface_type == EInterfaceType.intfIEnumeration:
            data = editor.currentText()
            model.setData(proxy_index, data)
        elif interface_type == EInterfaceType.intfIString:
            data = editor.text()
            model.setData(proxy_index, data)
        elif interface_type == EInterfaceType.intfIFloat:
            data = editor.text()
            model.setData(proxy_index, data)
Example #29
0
 def setModelData(self, editor: QtWidgets.QWidget,
                  model: QtCore.QAbstractItemModel,
                  index: QtCore.QModelIndex) -> NoReturn:
     data = self.editor_factory().get_data(editor)
     model.setData(index, data)
Example #30
0
 def setModelData(self, editor: QWidget, model: QAbstractItemModel, index: QModelIndex):
     model.setData(index, editor.currentText(), Qt.EditRole)
Example #31
0
 def setModelData(self, editor: QComboBox, item_model: QAbstractItemModel,
                  model_index: QModelIndex):
     item_model.setData(model_index, editor.currentText())
Example #32
0
 def setModelData(self, editor: QCheckBox, model: QAbstractItemModel, index: QModelIndex):
     model.setData(index, editor.isChecked(), Qt.EditRole)