void Dialog::search(const QString queryString) { m_query = queryString; m_queryClient->close(); m_fileQueryClient->close(); m_lineEdit->setText(queryString); m_resultsView->clear(); // searches emailAddress //QString name = "Marco Martin"; kDebug() << queryString; //bool found = false; QUrl graphUri = QUrl(); Nepomuk::Query::Query query; //Nepomuk::Query::OrTerm orTerm; //Nepomuk::Query::ResourceTypeTerm personTypeTerm(Vocabulary::NCO::PersonContact()); //orTerm.addSubTerm(personTypeTerm); /* Nepomuk::Query::AndTerm andTerm; Nepomuk::Query::ResourceTypeTerm personTypeTerm( Vocabulary::NCO::PersonContact() ); andTerm.addSubTerm( personTypeTerm ); const Nepomuk::Query::ComparisonTerm addrTerm( Vocabulary::NCO::emailAddress(), Nepomuk::Query::LiteralTerm( queryString ), Nepomuk::Query::ComparisonTerm::Contains ); const Nepomuk::Query::ComparisonTerm mailTerm( Vocabulary::NCO::hasEmailAddress(), addrTerm ); andTerm.addSubTerm( mailTerm ); */ kDebug() << "tagsearch?" << queryString << queryString.startsWith("hastag:", Qt::CaseInsensitive); Nepomuk::Query::FileQuery fileQuery; if (queryString.startsWith("hastag:", Qt::CaseInsensitive)) { QString tagName = queryString; tagName.remove("hastag:", Qt::CaseSensitive); kDebug() << "Searching tag" << tagName; //Nepomuk::Tag myTag = Nepomuk::Tag(tagName); QList<Nepomuk::Tag> allTags = Nepomuk::Tag::allTags(); if (!allTags.count()) { return; } foreach (const Nepomuk::Tag &t, allTags) { if (QString::compare(tagName, t.genericLabel(), Qt::CaseInsensitive) == 0) { // term matching the tag kDebug() << "Found tag:" << t.genericLabel() << t.uri(); Nepomuk::Query::ResourceTerm tagTerm( t ); // term matching tagged resource Nepomuk::Query::ComparisonTerm term( Soprano::Vocabulary::NAO::hasTag(), tagTerm, Nepomuk::Query::ComparisonTerm::Equal ); fileQuery.setTerm(term); query.setTerm(term); continue; } } } else {
void moviemanager::fetchAllMovieList(KListWidget* mainMovieList) { qDebug() << "fetch All Movie List"; Nepomuk::Query::Term term = Nepomuk::Query::ResourceTypeTerm( Nepomuk::Vocabulary::NFO::Video()); Nepomuk::Query::Query currentQuery; currentQuery.setTerm(term); QList<Nepomuk::Query::Result> results = Nepomuk::Query::QueryServiceClient::syncQuery( currentQuery ); Q_FOREACH( const Nepomuk::Query::Result& result,results) { //An if condition should be added here... //If the synopsis propoery is not set, then create a qdownloader object //and send the data to fetch from imdb //and then let that function add the movie to the list if(result.resource().property(Nepomuk::Vocabulary::NFO::fileName()).toString().contains(".avi") == true) //allowing only .avi files { qDebug() << "yes, .avi file!"; if(result.resource().property(Nepomuk::Vocabulary::NMM::synopsis()).toString().contains("tt") == true) //checking for synopsis { //only .avi and //data already present, so adding to the list qDebug() << "yes, contains synopsis"; //very rarely if title does not exists if(result.resource().property(Nepomuk::Vocabulary::NIE::title()).toString().isEmpty() == true) { //Title does not exists qDebug() << "title does not exist, so showing file names"; mainMovieList->addItem(new QListWidgetItem(result.resource().property(Nepomuk::Vocabulary::NFO::fileName()).toString().remove(".avi"))); } else { //Title exists, so displaying the title qDebug() << "Title exists, showing title of the movie: " << result.resource().property(Nepomuk::Vocabulary::NIE::title()).toString(); mainMovieList->addItem(new QListWidgetItem(result.resource().property(Nepomuk::Vocabulary::NIE::title()).toString())); } } else { //.avi but no data and tt synopsis qDebug() << "synopsis: " << result.resource().property(Nepomuk::Vocabulary::NMM::synopsis()).toString(); //no data, so data needs to be fetched //item will be added to the list later IMDB* imdbFetcher = new IMDB(result.resource(), mainMovieList); imdbFetcher->getData(); } } } }