void KoRdfSemanticItemViewSite::setProperty(const QString &prop, const QString &v) { QString fqprop = "http://koffice.org/rdf/site#" + prop; KoDocumentRdf *rdf = d->m_semItem->documentRdf(); Soprano::Model *m = rdf->model(); Soprano::Node ls = linkingSubject(); Soprano::Node pred = Node::createResourceNode(QUrl(fqprop)); m->removeAllStatements(Statement(ls, pred, Node())); m->addStatement(ls, pred,Node::createLiteralNode(v), rdf->manifestRdfNode()); }
Soprano::Node KoRdfSemanticItemViewSite::linkingSubject() const { KoDocumentRdf *rdf = d->m_semItem->documentRdf(); Soprano::Model *m = rdf->model(); Node pred(QUrl("http://koffice.org/rdf/site/package/common#idref")); Node obj = Node::createLiteralNode(d->m_xmlid); Node context = rdf->manifestRdfNode(); // try to find it if it already exists StatementIterator it = m->listStatements(Node(), pred, obj, context); QList<Statement> allStatements = it.allElements(); foreach (Soprano::Statement s, allStatements) { return s.subject(); } Node ret = m->createBlankNode(); m->addStatement(ret, pred, obj, context); return ret; }