void searchhandler::perform_search(QString searchtxt, bool exactmatch, sqlquery::en_queryType qrytyp, int selectitem, bool updSearchMemory) { if (sq->isDBOpen() == false) return; if (searchtxt.isEmpty()) return; sqlqueryresultlist sqlresultlist; QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); if (m_autocompBusy) { m_autocompBusy = false; m_autocompFutureWatcher.waitForFinished(); } sqlquery::en_queryType querytype = qrytyp; if (querytype == sqlquery::sqlresultDEFAULT) querytype = (sqlquery::en_queryType)m_comboBoxQueryType->itemData(m_comboBoxQueryType->currentIndex()).toInt(); sqlresultlist = sq->search(searchtxt.toAscii().data(), querytype, exactmatch); QApplication::restoreOverrideCursor(); if (sqlresultlist.result_type == sqlqueryresultlist::sqlresultERROR) { QMessageBox msgBox((QWidget*)mw); msgBox.setText(str2qt(sqlresultlist.sqlerrmsg)); msgBox.exec(); } else { m_pushButtonGraph->setEnabled((querytype == sqlquery::sqlresultFUNC_MACRO)|| (querytype == sqlquery::sqlresultCLASS_STRUCT)); if (m_checkBoxHeaderFilesOnly->isChecked()) { QRegExp rx1("\\.h([xp]{0,2})$", Qt::CaseInsensitive); unsigned int n = sqlresultlist.resultlist.size(); int pos; sqlqueryresultlist oldlist(sqlresultlist); sqlresultlist.resultlist.clear(); for(unsigned int i=0; i<n; i++) { pos = rx1.indexIn(str2qt(oldlist.resultlist[i].filename)); if (pos != -1) sqlresultlist.resultlist.push_back(oldlist.resultlist[i]); } } updateSearchHistory(searchtxt); if (updSearchMemory) addToSearchMemory(searchtxt); emit searchresults(sqlresultlist, selectitem); QString str; str = QString("%1").arg(sqlresultlist.resultlist.size()); str += " "; str += tr("results found"); emit updateStatus(str, 5000); } }
void searchhandler::perform_search(QString searchtxt, bool exactmatch, sqlquery::en_queryType qrytyp, QString filtertxt, int selectitem, bool updSearchMemory) { if (sq->isDBOpen() == false) return; if (searchtxt.isEmpty()) return; sqlqueryresultlist sqlresultlist; QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); if (m_autocompBusy) { m_autocompBusy = false; m_autocompFutureWatcher.waitForFinished(); } sqlquery::en_queryType querytype = qrytyp; if (querytype == sqlquery::sqlresultDEFAULT) querytype = (sqlquery::en_queryType)m_comboBoxQueryType->itemData(m_comboBoxQueryType->currentIndex()).toInt(); if ((filtertxt.isEmpty()) && (m_checkBoxFilter->isChecked())) { filtertxt = m_comboBoxFilter->lineEdit()->text().trimmed(); if (updSearchMemory) updateFilterHistory(filtertxt); } if (querytype == sqlquery::sqlresultGREP) { if (filtertxt.isEmpty()) filtertxt = "*"; sqlresultlist = sq->search(filtertxt.toAscii().data(), sqlquery::sqlresultFILEPATH, false); } else { sqlresultlist = sq->search(searchtxt.toAscii().data(), querytype, exactmatch, filtertxt.toAscii().data()); } QApplication::restoreOverrideCursor(); if (sqlresultlist.result_type == sqlqueryresultlist::sqlresultERROR) { QMessageBox msgBox((QWidget*)mw); msgBox.setText(str2qt(sqlresultlist.sqlerrmsg)); msgBox.exec(); } else { m_pushButtonGraph->setEnabled((querytype == sqlquery::sqlresultFUNC_MACRO)|| (querytype == sqlquery::sqlresultCLASS_STRUCT)); updateSearchHistory(searchtxt); if (updSearchMemory) addToSearchMemory(searchtxt, filtertxt); if (querytype == sqlquery::sqlresultGREP) { sqlresultlist = perform_grep(searchtxt, sqlresultlist, exactmatch); } emit searchresults(sqlresultlist, selectitem); QString str; str = QString("%1").arg(sqlresultlist.resultlist.size()); str += " "; str += tr("results found"); emit updateStatus(str, 5000); } }