void ResourceBrowser::slotRecommendedResources() { Nepomuk::Resource resource = m_resourceViewModel->resourceForIndex(m_resourceView->selectionModel()->currentIndex() ); QList<Nepomuk::Resource> recommendations; if(!(resource.label().isEmpty() && resource.genericLabel().isEmpty())) { if (!resource.topics().empty()) { recommendations = topicResourceSearch(resource); qDebug()<<recommendations; } qDebug()<<"length :"<<recommendations.length(); if (recommendations.length() < 10 && !resource.label().isEmpty()) { qDebug()<<"less than 10"; recommendations.append(contentResourceSearch(resource.label())); qDebug()<<recommendations; } if (recommendations.length() < 10 && !resource.genericLabel().isEmpty()) { qDebug()<<"less than 10"; recommendations.append(contentResourceSearch(resource.genericLabel())); qDebug()<<recommendations; } m_recommendationViewModel->setResources(recommendations); } else qDebug()<<"label empty"; }
void Nepomuk::QueryClientWrapper::slotNewEntries(const QList<Nepomuk::Query::Result>& results) { QList<Plasma::QueryMatch> matches; foreach(const Query::Result& result, results) { Plasma::QueryMatch match(m_runner); match.setType(Plasma::QueryMatch::PossibleMatch); match.setRelevance(normalizeScore(result.score())); Nepomuk::Resource res = result.resource(); QString type; QString iconName; KMimeType::Ptr mimetype; if (res.hasProperty(Nepomuk::Vocabulary::NIE::mimeType())) { mimetype = KMimeType::mimeType(res.property(Nepomuk::Vocabulary::NIE::mimeType()).toString()); } if (!mimetype && res.isFile() && res.toFile().url().isLocalFile()) { const KUrl url(res.toFile().url()); mimetype = KMimeType::findByUrl(url); } if (mimetype) { type = mimetype->comment(); iconName = mimetype->iconName(); } if (type.isEmpty() ) { type = Nepomuk::Types::Class(res.resourceType()).label(); iconName = res.genericIcon(); } match.setText(res.genericLabel()); match.setSubtext(type); match.setIcon(KIcon(iconName.isEmpty() ? QString::fromLatin1("nepomuk") : iconName)); match.setData(qVariantFromValue(res)); match.setId(KUrl(res.resourceUri()).url()); matches << match; }