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); } }
sqlqueryresultlist searchhandler::perform_grep(QString searchtxt, sqlqueryresultlist searchlist, bool exactmatch) { QVector<QString> strvec; sqlqueryresultlist resultlist; QFutureWatcher<sqlqueryresultlist> futureWatcher; QProgressDialog dialog; unsigned int n = searchlist.resultlist.size(); if (n == 0) return resultlist; strvec.resize(n); for (unsigned int i=0; i < n; i++) { strvec.replace(i, str2qt(searchlist.resultlist[i].filepath)); } dialog.setAutoReset(false); dialog.setLabelText(QString("Grep ").append(QString(tr("in progress"))).append(QString(" ..."))); dialog.setCancelButtonText(tr("Cancel")); QObject::connect(&futureWatcher, SIGNAL(finished()), &dialog, SLOT(reset())); QObject::connect(&dialog, SIGNAL(canceled()), &futureWatcher, SLOT(cancel())); QObject::connect(&futureWatcher, SIGNAL(progressRangeChanged(int,int)), &dialog, SLOT(setRange(int,int))); QObject::connect(&futureWatcher, SIGNAL(progressValueChanged(int)), &dialog, SLOT(setValue(int))); m_grepExactMatch = exactmatch; (*m_grepRegExp) = QRegExp(searchtxt.toAscii().data(), Qt::CaseInsensitive); m_grepRegExp->setPatternSyntax(QRegExp::RegExp2); futureWatcher.setFuture(QtConcurrent::mappedReduced(strvec, doGrep, collateGrep, QtConcurrent::SequentialReduce)); dialog.exec(); futureWatcher.waitForFinished(); if (futureWatcher.isCanceled() == false) resultlist = futureWatcher.result(); return resultlist; }
QStringList strLst2qt(const tVecStr& inpLst) { QStringList res; unsigned int n = inpLst.size(); for(unsigned int i=0; i < n; i++) { res << str2qt(inpLst[i]); } return res; }
void fileviewer::recvFuncList(sqlqueryresultlist* reslist) { m_listWidgetFunc->clear(); if ((m_fileDataList.isEmpty())||(m_iter == m_fileDataList.end())) return; m_funclist = *reslist; filedata fd(str2qt(m_funclist.resultlist[0].filename), "1", -99); if (m_iter->compareFileNameOnly(fd) == false) { if (m_iter->fileid < 0) {emit requestFuncList_filename(m_iter->filename);} else {emit requestFuncList_fileid(m_iter->fileid);} return; } if (m_comboBoxFuncListSort->currentIndex() == 0) {m_funclist.sort_by_linenum();} else {m_funclist.sort_by_name();} for (int i=0; i < m_funclist.resultlist.size(); i++) { m_listWidgetFunc->addItem(new QListWidgetItem( str2qt(m_funclist.resultlist[i].symname), 0, atoi(m_funclist.resultlist[i].linenum.c_str()))); } }
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); } }