예제 #1
0
파일: typestable.py 프로젝트: KDE/ginkgo
    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
예제 #2
0
파일: typestable.py 프로젝트: KDE/ginkgo
 def setModelData(self, editor, model, index):
     
     sindex = self.table.table.model().mapToSource(index)
     cindex = editor.currentIndex()
     
     if index.column() == 0:
         newOntology = self.ontologies[cindex]
         #get first class of that ontology
         classes = datamanager.findOntologyClasses(newOntology.resourceUri())
         if classes:
             index.model().sourceModel().resources[sindex.row()] = classes[0] 
         
     elif index.column() == 1:
         index.model().sourceModel().resources[sindex.row()] = self.classes[cindex]
예제 #3
0
    def setModelData(self, editor, model, index):

        sindex = self.table.table.model().mapToSource(index)
        cindex = editor.currentIndex()

        if index.column() == 0:
            newOntology = self.ontologies[cindex]
            #get first class of that ontology
            classes = datamanager.findOntologyClasses(
                newOntology.resourceUri())
            if classes:
                index.model().sourceModel().resources[
                    sindex.row()] = classes[0]

        elif index.column() == 1:
            index.model().sourceModel().resources[
                sindex.row()] = self.classes[cindex]
예제 #4
0
    def loadOntologyClasses(self, ontologyUri):

        #type = Soprano.Vocabulary.RDFS.Resource()
        #rootClass = Nepomuk.Types.Class(rootType)
        
        #sparql = "select distinct ?subject where { graph <%s> { ?subject a rdfs:Class . } }" % ontologyUri.toString()
        classes = datamanager.findOntologyClasses(ontologyUri)
        
        rootTypeResource = Nepomuk.Resource(Soprano.Vocabulary.RDFS.Resource())
        self.rootItem = ResourceNode(rootTypeResource)
        
        #first we add all children to the root
        #then we load the children of the root children, and we remove the root children which have ancestors
        for classResource in classes:
            child = ResourceNode(classResource, self.rootItem)
            self.rootItem.addChild(child)
        
        for child in self.rootItem.children:
            classResource = child.nodeData
            self.addChildren(child, classResource)
예제 #5
0
    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