def createEditor(self, parent, option, index): if (self._parent.isLocked()): return None if (index.internalPointer().sidsIsCGNSTree()): return None if (index.internalPointer().sidsIsLink()): return None if (index.internalPointer().sidsIsLinkChild()): return None ws = option.rect.width() hs = option.rect.height() + 4 xs = option.rect.x() ys = option.rect.y() - 2 if (not index.internalPointer().hasEditCheck() or (index.column() in [NMT.COLUMN_NAME])): self._mode = CELLTEXT editor = QLineEdit(parent) editor.transgeometry = (xs, ys, ws, hs) editor.installEventFilter(self) self.setEditorData(editor, index) return editor if index.column() in [NMT.COLUMN_VALUE]: node = self._parent.modelData(index) if node.hasValueView(): pt = node.sidsPath().split('/')[1:] lt = node.sidsTypePath() fc = self._parent._control._control.userFunctionFromPath(pt, lt) if (fc is not None): en = fc.getEnumerate(pt, lt) else: en = node.sidsValueEnum() if (en is None): self._mode = CELLTEXT editor = QLineEdit(parent) editor.transgeometry = (xs, ys, ws, hs) else: self._mode = CELLCOMBO editor = QComboBox(parent) editor.transgeometry = (xs, ys, ws, hs) editor.addItems(en) try: tix = en.index(node.sidsValue().tostring().decode('ascii')) except ValueError: editor.insertItem(0, node.sidsValue().tostring().decode('ascii')) tix = 0 editor.setCurrentIndex(tix) editor.installEventFilter(self) self.setEditorData(editor, index) return editor if (index.column() == NMT.COLUMN_SIDS): self._mode = CELLCOMBO editor = QComboBox(parent) editor.transgeometry = (xs, ys, ws, hs) tnode = self._parent.modelData(index) itemslist = tnode.sidsTypeList() editor.addItems(itemslist) try: tix = itemslist.index(tnode.sidsType()) except ValueError: editor.insertItem(0, tnode.sidsType()) tix = 0 editor.setCurrentIndex(tix) editor.installEventFilter(self) self.setEditorData(editor, index) return editor if (index.column() == NMT.COLUMN_DATATYPE): self._mode = CELLCOMBO editor = QComboBox(parent) editor.transgeometry = (xs, ys, ws, hs) editor.setProperty("Q7SIDSDataTypeComboBox", "True") itemslist = self._parent.modelData(index).sidsDataType(all=True) editor.addItems(itemslist) editor.installEventFilter(self) sizePolicy = QSizePolicy(QSizePolicy.Minimum,QSizePolicy.Minimum) editor.setSizePolicy(sizePolicy) self.setEditorData(editor, index) return editor return None
def createEditor(self, parent, option, index): tnode = self._model.nodeFromPath(self._parent._data[index.row()]) if tnode.sidsIsCGNSTree(): return None if tnode.sidsIsLink(): return None if tnode.sidsIsLinkChild(): return None ws = option.rect.width() hs = option.rect.height() + 4 xs = option.rect.x() ys = option.rect.y() - 2 if index.column() == 2: self._lastCol = COLUMN_SIDS if self._parent.cForce.checkState() != Qt.Checked: self._mode = CELLTEXT editor = QLineEdit(parent) editor.transgeometry = (xs, ys, ws, hs) else: self._mode = CELLCOMBO editor = QComboBox(parent) editor.transgeometry = (xs, ys, ws, hs) itemslist = tnode.sidsTypeList() editor.addItems(itemslist) try: tix = itemslist.index(tnode.sidsType()) except ValueError: editor.insertItem(0, tnode.sidsType()) tix = 0 editor.setCurrentIndex(tix) editor.installEventFilter(self) self.setEditorData(editor, index) return editor if index.column() == 3: self._lastCol = COLUMN_DATATYPE self._mode = CELLCOMBO editor = QComboBox(parent) editor.transgeometry = (xs, ys, ws, hs) itemslist = tnode.sidsDataType(all=True) editor.addItems(itemslist) editor.setCurrentIndex(0) editor.installEventFilter(self) self.setEditorData(editor, index) return editor if index.column() == 4: self._lastCol = COLUMN_VALUE if tnode.hasValueView(): pt = tnode.sidsPath().split('/')[1:] lt = tnode.sidsTypePath() fc = self._parent._control.userFunctionFromPath(pt, lt) if fc is not None: en = fc.getEnumerate(pt, lt) else: en = tnode.sidsValueEnum() if en is None: self._mode = CELLTEXT editor = QLineEdit(parent) editor.transgeometry = (xs, ys, ws, hs) else: self._mode = CELLCOMBO editor = QComboBox(parent) editor.transgeometry = (xs, ys, ws, hs) editor.addItems(en) try: tix = en.index( tnode.sidsValue().tostring().decode('ascii')) except ValueError: editor.insertItem( 0, tnode.sidsValue().tostring().decode('ascii')) tix = 0 editor.setCurrentIndex(tix) editor.installEventFilter(self) self.setEditorData(editor, index) return editor return None