void Nepomuk::DbpediaAnnotationPlugin::slotQueryFinished( Soprano::Util::AsyncResult* result ) { m_currentResult = 0; kDebug() << result->lastError(); Soprano::QueryResultIterator it = result->queryResultIterator(); while ( it.next() ) { kDebug() << it.current(); } // TODO: create annotations either as new pimo things that are related to the resource or as // being the resource (ie. an occurrence of resource().pimoThing()) emitFinished(); }
QList<CachedRowEntry> EventQuery::processQueryResults(const QString &query, const QUrl &uri) { Soprano::Model* model = Nepomuk2::ResourceManager::instance()->mainModel(); Soprano::QueryResultIterator it = model->executeQuery( query, Soprano::Query::QueryLanguageSparql ); // combine all search results again, so we get a just a single resource with a list of all authors and the list of types // instead of many resources with all types again QMap<QString, QStringList> resultList; while( it.next() ) { Soprano::BindingSet p = it.current(); // get either a new entry or what we have inserted beforehand QStringList curEntry = resultList.value( p.value("r").toString(), QStringList()); // now set / add each queried value into the StringList if (curEntry.isEmpty() ) { curEntry << p.value("star").toString() << p.value("title").toString() << p.value("date").toString() << p.value("publication").toString() << p.value("r").toString(); } else { QString star = p.value("star").toString(); if(!star.isEmpty()) curEntry[Column_StarRate] = star; QString title = p.value("title").toString(); if(!title.isEmpty()) curEntry[Column_Title] = title; QString date = p.value("date").toString(); if( !date.isEmpty() ) curEntry[Column_Date] = date; QString publication = p.value("publication").toString(); if(!publication.isEmpty() && !curEntry[Column_Publication] .contains(publication)) { //create content for the HTMLDelegate looks a lot better when several entries are being displayed curEntry[Column_Publication] = curEntry[Column_Publication].append("• "); curEntry[Column_Publication] = curEntry[Column_Publication].append(publication); curEntry[Column_Publication] = curEntry[Column_Publication].append("<br/>"); } } // and save the result back into the map if(p.value("r").isEmpty()) { Q_ASSERT(!uri.isEmpty()); resultList.insert(uri.toString(), curEntry); } else { resultList.insert(p.value("r").toString(), curEntry); } } // now create the cache entries from all returned search results QList<CachedRowEntry> newCache; QMapIterator<QString, QStringList> i(resultList); while (i.hasNext()) { i.next(); CachedRowEntry cre; cre.uri = QUrl( i.key() ); cre.displayColums = createDisplayData(i.value()); cre.decorationColums = createDecorationData(i.value()); cre.resource = Nepomuk2::Resource::fromResourceUri( cre.uri ); cre.timestamp = QDateTime::currentDateTime(); cre.resourceType = 0; //Unused newCache.append(cre); } return newCache; }