def setModelData(self, editor: QWidget, model: QAbstractItemModel, index: QModelIndex): """Set the data for the item at the given index in the model to the contents of the given editor. """ if isinstance(editor, QComboBox): model.setData(index, editor.currentData()) if index.column() == 2 or index.column() == 3: row = index.row() model = index.model() # Detect parthenogenesis: same mother and father father_id = model.samples_data[row][2] # Only for not unknown parents if father_id != "0" and father_id == model.samples_data[row][3]: self.erroneous_samples.add(row) elif row in self.erroneous_samples: # Reset interface self.parthenogenesis_detected.emit("") self.erroneous_samples.remove(row) for row in self.erroneous_samples: self.parthenogenesis_detected.emit( self.tr("<b>Same father and mother for sample '{}'</b>"). format(model.samples_data[row][1])) return # Basic text not editable return super().setModelData(editor, model, index)
def setModelData(self, editor: QWidget, model: 'PropModel', index: QModelIndex) -> None: """ Returns updated data to the model :param editor: Editor that will be set for certain data structures. :type editor: QWidget :param model: The model that our delegate will render. :type model: PropModel :param index: Index of the editor. :type index: QModelIndex :return: None :rtype: NoneType """ data = index.internalPointer() if type(data) == Property: if index.column() == 1: t = data.getType() if t == str: data.setValue(editor.text()) self.propertyUpdated.emit() elif t == int: data.setValue(editor.value()) elif t == bool: data.setValue(editor.isChecked()) elif t == float: data.setValue(editor.value()) elif issubclass(t, Enum): data.setValue(editor.currentData()) else: pass