/** Starts the search with the set modules and the set search text. */ void CSearchDialog::startSearch() { QString originalSearchText(m_searchOptionsArea->searchText()); QString searchText(""); // first check the search string for errors { QString TestString(originalSearchText); QRegExp ReservedWords("heading:|footnote:|morph:|strong:"); if (TestString.replace(ReservedWords, "").simplified().isEmpty()) { return; } } searchText = prepareSearchText(originalSearchText); // Insert search text into history list of combobox m_searchOptionsArea->addToHistory(originalSearchText); // check that we have the indices we need for searching if (!m_searcher.modulesHaveIndices( modules() ) ) { int result = util::showQuestion(this, tr("Missing indices"), tr("One or more works need indexing before they can be searched.\n" "This could take a long time. Proceed with indexing?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); // In SuSE 10.0 the result is the logical or of the button type, just like it is // inputed into the QMessageBox. if ( (result == (QMessageBox::Yes | QMessageBox::Default)) || (result == QMessageBox::Yes) || (result == QMessageBox::Default) ) { CModuleIndexDialog* dlg = CModuleIndexDialog::getInstance(); dlg->indexUnindexedModules( modules() ); } else { return; } } if (m_searchOptionsArea->hasSearchScope()) { m_searcher.setSearchScope( m_searchOptionsArea->searchScope() ); } else { m_searcher.resetSearchScope(); } m_searcher.setModules( modules() ); m_searcher.setSearchedText(searchText); //Just to be sure that it can't be clicked again, if the search happens to be a bit slow. m_searchOptionsArea->searchButton()->setEnabled(false); m_searchOptionsArea->m_searchTextCombo->setEnabled(false); m_searcher.startSearch(); m_searchOptionsArea->searchButton()->setEnabled(true); m_searchOptionsArea->m_searchTextCombo->setEnabled(true); m_searchOptionsArea->m_searchTextCombo->setFocus(); }
bool BtSearchInterface::performSearch() { setupSearchType(); QString searchText = prepareSearchText(m_searchText); // Check that we have the indices we need for searching QStringList moduleList = m_moduleList.split(", "); CSMI modules = CSwordBackend::instance()->getConstPointerList(moduleList); // Set the search options: CSwordModuleSearch searcher; searcher.setSearchedText(searchText); searcher.setModules(modules); searcher.resetSearchScope(); searcher.startSearch(); m_results = searcher.results(); setupModuleModel(m_results); const CSwordModuleInfo* module = getModuleFromResults(m_results,0); setupReferenceModel(module, m_results.value(module)); return true; }