void AudioStreamListEngine::run() { QThread::setTerminationEnabled(true); m_stop = false; if (m_updateSourceInfo || m_removeSourceInfo) { NepomukListEngine::run(); return; } //Create media list based on engine argument and filter QList<MediaItem> mediaList; MediaVocabulary mediaVocabulary = MediaVocabulary(); QString engineArg = m_mediaListProperties.engineArg(); QString engineFilter = m_mediaListProperties.engineFilter(); if (m_nepomukInited) { if (engineArg.isEmpty()) { MediaQuery query; QStringList bindings; bindings.append(mediaVocabulary.mediaResourceBinding()); bindings.append(mediaVocabulary.mediaResourceUrlBinding()); bindings.append(mediaVocabulary.titleBinding()); bindings.append(mediaVocabulary.ratingBinding()); bindings.append(mediaVocabulary.descriptionBinding()); bindings.append(mediaVocabulary.artworkBinding()); //bindings.append(mediaVocabulary.genreBinding()); query.select(bindings, MediaQuery::Distinct); query.startWhere(); query.addCondition(mediaVocabulary.hasTypeAudioStream(MediaQuery::Required)); query.addCondition(mediaVocabulary.hasTitle(MediaQuery::Required)); query.addCondition(mediaVocabulary.hasRating(MediaQuery::Optional)); query.addCondition(mediaVocabulary.hasDescription(MediaQuery::Optional)); query.addCondition(mediaVocabulary.hasArtwork(MediaQuery::Optional)); query.endWhere(); QStringList orderByBindings; orderByBindings.append(mediaVocabulary.titleBinding()); query.orderBy(orderByBindings); Soprano::QueryResultIterator it = query.executeSelect(m_mainModel); //Build media list from results while( it.next() ) { if (m_stop) { return; } MediaItem mediaItem = Utilities::mediaItemFromIterator(it, QString("Audio Stream"), m_mediaListProperties.lri); if (!mediaItem.url.startsWith(QLatin1String("nepomuk:/"))) { mediaList.append(mediaItem); } } m_mediaListProperties.summary = i18np("1 stream", "%1 streams", mediaList.count()); MediaItem mediaItem; mediaItem.type = "Audio"; mediaItem.url.clear(); mediaItem.title = i18n("New Audio Stream"); mediaItem.subTitle = i18n("Edit info to create new audio stream"); mediaItem.artwork = KIcon("text-html"); mediaItem.fields["title"] = i18n("Untitled"); mediaItem.fields["audioType"] = "Audio Stream"; mediaItem.fields["isTemplate"] = true; mediaList.append(mediaItem); m_mediaListProperties.type = QString("Sources"); } else if (engineArg.toLower() == "search") { MediaQuery query; QStringList bindings; bindings.append(mediaVocabulary.mediaResourceBinding()); bindings.append(mediaVocabulary.mediaResourceUrlBinding()); bindings.append(mediaVocabulary.titleBinding()); bindings.append(mediaVocabulary.ratingBinding()); bindings.append(mediaVocabulary.descriptionBinding()); bindings.append(mediaVocabulary.artworkBinding()); //bindings.append(mediaVocabulary.genreBinding()); query.select(bindings, MediaQuery::Distinct); query.startWhere(); query.addCondition(mediaVocabulary.hasTypeAudioStream(MediaQuery::Required)); query.addCondition(mediaVocabulary.hasTitle(MediaQuery::Required)); query.addCondition(mediaVocabulary.hasRating(MediaQuery::Optional)); query.addCondition(mediaVocabulary.hasDescription(MediaQuery::Optional)); query.addCondition(mediaVocabulary.hasArtwork(MediaQuery::Optional)); query.startFilter(); query.addFilterConstraint(mediaVocabulary.titleBinding(), engineFilter, MediaQuery::Contains); query.addFilterOr(); query.addFilterConstraint(mediaVocabulary.descriptionBinding(), engineFilter, MediaQuery::Contains); query.endFilter(); query.endWhere(); QStringList orderByBindings; orderByBindings.append(mediaVocabulary.titleBinding()); query.orderBy(orderByBindings); Soprano::QueryResultIterator it = query.executeSelect(m_mainModel); //Build media list from results while( it.next() ) { MediaItem mediaItem = Utilities::mediaItemFromIterator(it, QString("Audio Stream"), m_mediaListProperties.lri); if (!mediaItem.url.startsWith(QLatin1String("nepomuk:/"))) { mediaList.append(mediaItem); } } m_mediaListProperties.summary = i18np("1 stream", "%1 streams", mediaList.count()); m_mediaListProperties.type = QString("Sources"); } } emit results(m_requestSignature, mediaList, m_mediaListProperties, true, m_subRequestSignature); m_requestSignature.clear(); m_subRequestSignature.clear(); }