void searchhandler::OpenDB_indexChanged(const int& idx) { if (idx < 0) return; sqlquery::en_filereadstatus sqstatus; if (m_autocompBusy) { m_autocompBusy = false; m_autocompFutureWatcher.waitForFinished(); } sq->close_dbfile(); QFileInfo dbfile(m_comboBoxDB->itemText(idx)); sqstatus = sq->open_dbfile(qt2str(m_comboBoxDB->itemText(idx))); if (sqstatus != sqlquery::sqlfileOK) { QMessageBox msgBox((QWidget*)mw); msgBox.setText(sqlerrormsg(sqstatus)); msgBox.exec(); m_comboBoxDB->removeItem(idx); } else { QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); m_comboBoxSearch->clear(); m_comboBoxSearch->lineEdit()->clear(); m_searchMemoryList.clear(); m_iter = m_searchMemoryList.begin(); m_pushButtonSearchPrev->setEnabled(false); m_pushButtonSearchNext->setEnabled(false); emit sendDBtimestamp(dbfile.lastModified()); emit DBreset(); QApplication::restoreOverrideCursor(); } }
tVecStr qt2strLst(const QStringList& inpLst) { tVecStr res; int n = inpLst.size(); res.reserve(n); for(int i=0; i < n; i++) { res.push_back(qt2str(inpLst[i])); } return res; }
sqlqueryresultlist searchhandler::doGrep(const QString &fp) { sqlqueryresultlist reslist; sqlqueryresult res; QString str, fp2; tStr fpstr, fn; int pos, linenumber=0; char numtext[10]; QRegExp rx1(*m_grepRegExp); reslist.result_type = sqlqueryresultlist::sqlresultFILE_LINE; fp2 = fp; fp2.replace(QString("$HOME"), QDir::homePath()); #ifdef _WIN32 fp2.replace("/", "\\"); #endif fpstr = qt2str(fp2); fn = extract_filename(fpstr.c_str()); QFile file(fp2); QTextStream in(&file); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { return reslist; } while (!in.atEnd()) { linenumber++; str = in.readLine(); pos = rx1.indexIn(str); if (pos != -1) { res.filepath = fpstr; res.filename = fn; sprintf(numtext, "%d", linenumber); res.linenum = numtext; res.linetext = qt2str(str.trimmed().left(80)); reslist.resultlist.push_back(res); } } return reslist; }