def createEditor(self, parent, option, index): if index.column() == 0: combobox = QComboBox(parent) combobox.setEditable(False) for ontology in self.ontologies: abbrev = unicode(ontology.property(Soprano.Vocabulary.NAO.hasDefaultNamespaceAbbreviation()).toString()) if len(abbrev) == 0: abbrev = ontology.resourceUri().toString() combobox.addItem(abbrev, QVariant(str(ontology.resourceUri().toString()))) return combobox elif index.column() == 1: #edition of a property value #identify the range of the property sindex = self.table.table.model().mapToSource(index) currentType = index.model().sourceModel().resourceAt(sindex.row()) currentOntology = datamanager.ontologyForUri(currentType.resourceUri()) self.classes = datamanager.findOntologyClasses(currentOntology.resourceUri()) combobox = QComboBox(parent) combobox.setEditable(False) for clazz in self.classes: combobox.addItem(clazz.genericLabel(), QVariant(unicode(clazz.resourceUri().toString()))) return combobox else: return None
def setEditorData(self, editor, index): sindex = self.table.table.model().mapToSource(index) currentType = index.model().sourceModel().resourceAt(sindex.row()) currentOntology = datamanager.ontologyForUri(currentType.resourceUri()) if index.column() == 0: i = 0 for ontology in self.ontologies: if currentOntology.resourceUri() == ontology.resourceUri(): editor.setCurrentIndex(i) break i = i + 1 elif index.column() == 1: i = 0 for clazz in self.classes: if currentType.resourceUri() == clazz.resourceUri(): editor.setCurrentIndex(i) break i = i + 1
def createEditor(self, parent, option, index): if index.column() == 0: combobox = QComboBox(parent) combobox.setEditable(False) for ontology in self.ontologies: abbrev = unicode( ontology.property( Soprano.Vocabulary.NAO.hasDefaultNamespaceAbbreviation( )).toString()) if len(abbrev) == 0: abbrev = ontology.resourceUri().toString() combobox.addItem( abbrev, QVariant(str(ontology.resourceUri().toString()))) return combobox elif index.column() == 1: #edition of a property value #identify the range of the property sindex = self.table.table.model().mapToSource(index) currentType = index.model().sourceModel().resourceAt(sindex.row()) currentOntology = datamanager.ontologyForUri( currentType.resourceUri()) self.classes = datamanager.findOntologyClasses( currentOntology.resourceUri()) combobox = QComboBox(parent) combobox.setEditable(False) for clazz in self.classes: combobox.addItem( clazz.genericLabel(), QVariant(unicode(clazz.resourceUri().toString()))) return combobox else: return None