// run async void QueryModel::getEntries(EntryIterator const &i, std::string const &query, std::string const &attribute, bool yield) { alpinocorpus::CorpusInfo corpusInfo = alpinocorpus::predefinedCorpusOrFallback(d_corpus->type()); if (i.hasProgress()) emit queryStarted(100); else emit queryStarted(0); try { d_cancelled = false; d_entryIterator = i; std::set<std::string> seen; while (!d_cancelled && d_entryIterator.hasNext()) { alpinocorpus::Entry e = d_entryIterator.next(*d_corpus); if (yield) { // Check whether we have already processed this tree before. if (seen.find(e.name) != seen.end()) continue; seen.insert(e.name); std::vector<alpinocorpus::LexItem> sent = d_corpus->sentence(e.name, query, attribute, MISSING_ATTRIBUTE_SHORT, corpusInfo); // Find all match ids. std::set<size_t> ids; foreach (alpinocorpus::LexItem const &lexItem, sent) ids.insert(lexItem.matches.begin(), lexItem.matches.end()); foreach (size_t id, ids) { std::ostringstream oss; bool firstToken = true; foreach (alpinocorpus::LexItem const &lexItem, sent) { if (lexItem.matches.find(id) != lexItem.matches.end()) { if (firstToken) firstToken = false; else oss << " "; oss << lexItem.word; } } std::string result = oss.str(); emit queryEntryFound(QString::fromUtf8(result.c_str())); } size_t prevDepth = 0; } else emit queryEntryFound(QString::fromUtf8(e.contents.c_str())); }
void MetadataUpdater::runQuery() { m_indices.clear(); m_resultList.clear(); Nepomuk2::Query::Query myQuery; if (m_queryServiceClient) { m_queryServiceClient->close(); m_queryServiceClient->deleteLater(); } m_queryServiceClient = new Nepomuk2::Query::QueryServiceClient(this); connect(m_queryServiceClient, SIGNAL(newEntries(QList<Nepomuk2::Query::Result>)), this, SLOT(newEntries(QList<Nepomuk2::Query::Result>))); // connect(queryServiceClient, SIGNAL(entriesRemoved(QList<QUrl>)),SLOT(entriesRemoved(QList<QUrl>))); connect(m_queryServiceClient, SIGNAL(error(QString)), SLOT(error(QString))); connect(m_queryServiceClient, SIGNAL(finishedListing()), SLOT(finishedListing())); emit reset(); QMutexLocker locker(&m_termMutex); myQuery.setTerm(m_term); kDebug() << "SPARQL Query " << myQuery.toSparqlQuery(); m_queryServiceClient->query(myQuery); emit queryStarted(); }
void FilmwebProvider::query(const QStringList & tokens) { emit queryStarted(); resultsModel->clear(); QUrl queryUrl("http://www.filmweb.pl/search?q=" + tokens.join("+")); webPage->mainFrame()->load(queryUrl); timeout->start(5000); }
void LibraryWidget::connectModelSignals(QLibraryTreeWidgetItem *root, Library *p, BibGlobals::ResourceSelection resourceType) { QSortFilterProxyModel *viewModel = p->viewModel(resourceType); if(!viewModel) return; NepomukModel *nm = qobject_cast<NepomukModel *>(viewModel->sourceModel()); if(!nm) return; connect(nm, SIGNAL(queryStarted()), root, SLOT(startQueryFetch())); connect(nm, SIGNAL(queryFinished()), root, SLOT(stopQueryFetch())); connect(nm, SIGNAL(dataSizeChaged(int)), root, SLOT(updateItemCount(int))); }