Loading saved simple searches: only reset the ext indexes set when prefs dialog is opened, not after 1st search

This commit is contained in:
Jean-Francois Dockes 2020-05-19 19:20:38 +02:00
parent 1865f1ff63
commit 90fd4865eb
2 changed files with 113 additions and 113 deletions

View File

@ -111,8 +111,6 @@ bool maybeOpenDb(string &reason, bool force, bool *maindberror)
if (!edbs->empty()) { if (!edbs->empty()) {
rcldb->setExtraQueryDbs(*edbs); rcldb->setExtraQueryDbs(*edbs);
} }
prefs.useTmpActiveExtraDbs = false;
prefs.tmpActiveExtraDbs.clear();
Rcl::Db::OpenError error; Rcl::Db::OpenError error;
if (!rcldb->isopen() && !rcldb->open(Rcl::Db::DbRO, &error)) { if (!rcldb->isopen() && !rcldb->open(Rcl::Db::DbRO, &error)) {

View File

@ -46,38 +46,38 @@ static const QKeySequence closeKeySeq("Ctrl+w");
void RclMain::showAdvSearchDialog() void RclMain::showAdvSearchDialog()
{ {
if (asearchform == 0) { if (asearchform == 0) {
asearchform = new AdvSearch(0); asearchform = new AdvSearch(0);
if (asearchform == 0) { if (asearchform == 0) {
return; return;
} }
connect(new QShortcut(quitKeySeq, asearchform), SIGNAL (activated()), connect(new QShortcut(quitKeySeq, asearchform), SIGNAL (activated()),
this, SLOT (fileExit())); this, SLOT (fileExit()));
connect(asearchform, connect(asearchform,
SIGNAL(startSearch(std::shared_ptr<Rcl::SearchData>, bool)), SIGNAL(startSearch(std::shared_ptr<Rcl::SearchData>, bool)),
this, SLOT(startSearch(std::shared_ptr<Rcl::SearchData>, bool))); this, SLOT(startSearch(std::shared_ptr<Rcl::SearchData>, bool)));
connect(asearchform, SIGNAL(setDescription(QString)), connect(asearchform, SIGNAL(setDescription(QString)),
this, SLOT(onSetDescription(QString))); this, SLOT(onSetDescription(QString)));
asearchform->show(); asearchform->show();
} else { } else {
// Close and reopen, in hope that makes us visible... // Close and reopen, in hope that makes us visible...
asearchform->close(); asearchform->close();
asearchform->show(); asearchform->show();
} }
} }
void RclMain::showSpellDialog() void RclMain::showSpellDialog()
{ {
if (spellform == 0) { if (spellform == 0) {
spellform = new SpellW(0); spellform = new SpellW(0);
connect(new QShortcut(quitKeySeq, spellform), SIGNAL (activated()), connect(new QShortcut(quitKeySeq, spellform), SIGNAL (activated()),
this, SLOT (fileExit())); this, SLOT (fileExit()));
connect(spellform, SIGNAL(wordSelect(QString)), connect(spellform, SIGNAL(wordSelect(QString)),
sSearch, SLOT(addTerm(QString))); sSearch, SLOT(addTerm(QString)));
spellform->show(); spellform->show();
} else { } else {
// Close and reopen, in hope that makes us visible... // Close and reopen, in hope that makes us visible...
spellform->close(); spellform->close();
spellform->show(); spellform->show();
} }
} }
@ -111,10 +111,10 @@ void RclMain::showWebcacheDialog()
} }
if (webcache == 0) { if (webcache == 0) {
webcache = new WebcacheEdit(this); webcache = new WebcacheEdit(this);
webcache->setAttribute(Qt::WA_DeleteOnClose); webcache->setAttribute(Qt::WA_DeleteOnClose);
connect(new QShortcut(quitKeySeq, webcache), SIGNAL (activated()), connect(new QShortcut(quitKeySeq, webcache), SIGNAL (activated()),
this, SLOT (fileExit())); this, SLOT (fileExit()));
connect(webcache, SIGNAL(destroyed(QObject*)), connect(webcache, SIGNAL(destroyed(QObject*)),
this, SLOT(onWebcacheDestroyed(QObject*)) ); this, SLOT(onWebcacheDestroyed(QObject*)) );
webcache->show(); webcache->show();
@ -140,7 +140,7 @@ void RclMain::showFragButs()
deleteZ(fragbuts); deleteZ(fragbuts);
} }
if (fragbuts == 0) { if (fragbuts == 0) {
fragbuts = new FragButs(0); fragbuts = new FragButs(0);
if (fragbuts->ok()) { if (fragbuts->ok()) {
fragbuts->show(); fragbuts->show();
connect(fragbuts, SIGNAL(fragmentsChanged()), connect(fragbuts, SIGNAL(fragmentsChanged()),
@ -149,8 +149,8 @@ void RclMain::showFragButs()
deleteZ(fragbuts); deleteZ(fragbuts);
} }
} else { } else {
// Close and reopen, in hope that makes us visible... // Close and reopen, in hope that makes us visible...
fragbuts->close(); fragbuts->close();
fragbuts->show(); fragbuts->show();
} }
} }
@ -158,12 +158,12 @@ void RclMain::showFragButs()
void RclMain::showSpecIdx() void RclMain::showSpecIdx()
{ {
if (specidx == 0) { if (specidx == 0) {
specidx = new SpecIdxW(0); specidx = new SpecIdxW(0);
connect(specidx, SIGNAL(accepted()), this, SLOT(specialIndex())); connect(specidx, SIGNAL(accepted()), this, SLOT(specialIndex()));
specidx->show(); specidx->show();
} else { } else {
// Close and reopen, in hope that makes us visible... // Close and reopen, in hope that makes us visible...
specidx->close(); specidx->close();
specidx->show(); specidx->show();
} }
} }
@ -182,11 +182,11 @@ void RclMain::showIndexConfig(bool modal)
bool created{false}; bool created{false};
if (indexConfig == 0) { if (indexConfig == 0) {
created = true; created = true;
indexConfig = new ConfIndexW(0, theconfig); indexConfig = new ConfIndexW(0, theconfig);
} }
indexConfig->showPrefs(modal); indexConfig->showPrefs(modal);
if (created) { if (created) {
connect(new QShortcut(quitKeySeq, indexConfig->getDialog()), connect(new QShortcut(quitKeySeq, indexConfig->getDialog()),
SIGNAL (activated()), this, SLOT (fileExit())); SIGNAL (activated()), this, SLOT (fileExit()));
} }
} }
@ -203,9 +203,9 @@ void RclMain::showIndexSched(bool modal)
{ {
LOGDEB("showIndexSched()\n" ); LOGDEB("showIndexSched()\n" );
if (indexSched == 0) { if (indexSched == 0) {
indexSched = new IdxSchedW(this); indexSched = new IdxSchedW(this);
connect(new QShortcut(quitKeySeq, indexSched), SIGNAL (activated()), connect(new QShortcut(quitKeySeq, indexSched), SIGNAL (activated()),
this, SLOT (fileExit())); this, SLOT (fileExit()));
#ifdef _WIN32 #ifdef _WIN32
indexSched->cronCLB->setText(tr("Batch scheduling")); indexSched->cronCLB->setText(tr("Batch scheduling"));
indexSched->cronCLB->setDescription( indexSched->cronCLB->setDescription(
@ -214,29 +214,29 @@ void RclMain::showIndexSched(bool modal)
indexSched->mainExplainLBL->hide(); indexSched->mainExplainLBL->hide();
indexSched->rtidxCLB->hide(); indexSched->rtidxCLB->hide();
#endif #endif
connect(indexSched->cronCLB, SIGNAL(clicked()), connect(indexSched->cronCLB, SIGNAL(clicked()),
this, SLOT(execCronTool())); this, SLOT(execCronTool()));
if (theconfig && theconfig->isDefaultConfig()) { if (theconfig && theconfig->isDefaultConfig()) {
#ifdef RCL_MONITOR #ifdef RCL_MONITOR
connect(indexSched->rtidxCLB, SIGNAL(clicked()), connect(indexSched->rtidxCLB, SIGNAL(clicked()),
this, SLOT(execRTITool())); this, SLOT(execRTITool()));
#else #else
indexSched->rtidxCLB->setEnabled(false); indexSched->rtidxCLB->setEnabled(false);
indexSched->rtidxCLB->setToolTip(tr("Disabled because the real time indexer was not compiled in.")); indexSched->rtidxCLB->setToolTip(tr("Disabled because the real time indexer was not compiled in."));
#endif #endif
} else { } else {
indexSched->rtidxCLB->setEnabled(false); indexSched->rtidxCLB->setEnabled(false);
indexSched->rtidxCLB->setToolTip(tr("This configuration tool only works for the main index.")); indexSched->rtidxCLB->setToolTip(tr("This configuration tool only works for the main index."));
} }
} else { } else {
// Close and reopen, in hope that makes us visible... // Close and reopen, in hope that makes us visible...
indexSched->close(); indexSched->close();
} }
if (modal) { if (modal) {
indexSched->exec(); indexSched->exec();
indexSched->setModal(false); indexSched->setModal(false);
} else { } else {
indexSched->show(); indexSched->show();
} }
} }
@ -254,21 +254,21 @@ void RclMain::showCronTool(bool modal)
LOGDEB("showCronTool()\n" ); LOGDEB("showCronTool()\n" );
if (cronTool == 0) { if (cronTool == 0) {
#ifdef _WIN32 #ifdef _WIN32
cronTool = new WinSchedToolW(0); cronTool = new WinSchedToolW(0);
#else #else
cronTool = new CronToolW(0); cronTool = new CronToolW(0);
#endif #endif
connect(new QShortcut(quitKeySeq, cronTool), SIGNAL (activated()), connect(new QShortcut(quitKeySeq, cronTool), SIGNAL (activated()),
this, SLOT (fileExit())); this, SLOT (fileExit()));
} else { } else {
// Close and reopen, in hope that makes us visible... // Close and reopen, in hope that makes us visible...
cronTool->close(); cronTool->close();
} }
if (modal) { if (modal) {
cronTool->exec(); cronTool->exec();
cronTool->setModal(false); cronTool->setModal(false);
} else { } else {
cronTool->show(); cronTool->show();
} }
} }
@ -285,18 +285,18 @@ void RclMain::showRTITool(bool modal)
#ifndef _WIN32 #ifndef _WIN32
LOGDEB("showRTITool()\n" ); LOGDEB("showRTITool()\n" );
if (rtiTool == 0) { if (rtiTool == 0) {
rtiTool = new RTIToolW(0); rtiTool = new RTIToolW(0);
connect(new QShortcut(quitKeySeq, rtiTool), SIGNAL (activated()), connect(new QShortcut(quitKeySeq, rtiTool), SIGNAL (activated()),
this, SLOT (fileExit())); this, SLOT (fileExit()));
} else { } else {
// Close and reopen, in hope that makes us visible... // Close and reopen, in hope that makes us visible...
rtiTool->close(); rtiTool->close();
} }
if (modal) { if (modal) {
rtiTool->exec(); rtiTool->exec();
rtiTool->setModal(false); rtiTool->setModal(false);
} else { } else {
rtiTool->show(); rtiTool->show();
} }
#else #else
PRETEND_USE(modal); PRETEND_USE(modal);
@ -305,16 +305,18 @@ void RclMain::showRTITool(bool modal)
void RclMain::showUIPrefs() void RclMain::showUIPrefs()
{ {
prefs.useTmpActiveExtraDbs = false;
prefs.tmpActiveExtraDbs.clear();
if (uiprefs == 0) { if (uiprefs == 0) {
uiprefs = new UIPrefsDialog(this); uiprefs = new UIPrefsDialog(this);
connect(new QShortcut(quitKeySeq, uiprefs), SIGNAL (activated()), connect(new QShortcut(quitKeySeq, uiprefs), SIGNAL (activated()),
this, SLOT (fileExit())); this, SLOT (fileExit()));
connect(uiprefs, SIGNAL(uiprefsDone()), this, SLOT(setUIPrefs())); connect(uiprefs, SIGNAL(uiprefsDone()), this, SLOT(setUIPrefs()));
connect(this, SIGNAL(stemLangChanged(const QString&)), connect(this, SIGNAL(stemLangChanged(const QString&)),
uiprefs, SLOT(setStemLang(const QString&))); uiprefs, SLOT(setStemLang(const QString&)));
} else { } else {
// Close and reopen, in hope that makes us visible... // Close and reopen, in hope that makes us visible...
uiprefs->close(); uiprefs->close();
rwSettings(false); rwSettings(false);
uiprefs->setFromPrefs(); uiprefs->setFromPrefs();
} }
@ -331,7 +333,7 @@ void RclMain::showAboutDialog()
{ {
string vstring = Rcl::version_string() + string vstring = Rcl::version_string() +
string("<br><a href='http://www.recoll.org'>www.recoll.org</a>") + string("<br><a href='http://www.recoll.org'>www.recoll.org</a>") +
string("<br><a href='http://www.xapian.org'>www.xapian.org</a>"); string("<br><a href='http://www.xapian.org'>www.xapian.org</a>");
QMessageBox::information(this, tr("About Recoll"), vstring.c_str()); QMessageBox::information(this, tr("About Recoll"), vstring.c_str());
} }
@ -339,20 +341,20 @@ void RclMain::showMissingHelpers()
{ {
string miss; string miss;
if (!theconfig->getMissingHelperDesc(miss)) { if (!theconfig->getMissingHelperDesc(miss)) {
QMessageBox::information( QMessageBox::information(
this, "", tr("No information: initial indexing not yet performed.")); this, "", tr("No information: initial indexing not yet performed."));
return; return;
} }
QString msg = QString::fromUtf8("<p>") + QString msg = QString::fromUtf8("<p>") +
tr("External applications/commands needed for your file types " tr("External applications/commands needed for your file types "
"and not found, as stored by the last indexing pass in "); "and not found, as stored by the last indexing pass in ");
msg += "<i>"; msg += "<i>";
msg += path2qs(theconfig->getConfDir()); msg += path2qs(theconfig->getConfDir());
msg += "/missing</i>:<pre>\n"; msg += "/missing</i>:<pre>\n";
if (!miss.empty()) { if (!miss.empty()) {
msg += QString::fromUtf8(miss.c_str()); msg += QString::fromUtf8(miss.c_str());
} else { } else {
msg += tr("No helpers found missing"); msg += tr("No helpers found missing");
} }
msg += "</pre>"; msg += "</pre>";
QMessageBox::information(this, tr("Missing helper programs"), msg); QMessageBox::information(this, tr("Missing helper programs"), msg);
@ -363,21 +365,21 @@ void RclMain::showActiveTypes()
string reason; string reason;
bool maindberror; bool maindberror;
if (!maybeOpenDb(reason, true, &maindberror)) { if (!maybeOpenDb(reason, true, &maindberror)) {
QMessageBox::warning(0, tr("Error"), QMessageBox::warning(0, tr("Error"),
u8s2qs(reason), u8s2qs(reason),
QMessageBox::Ok, QMessageBox::Ok,
QMessageBox::NoButton); QMessageBox::NoButton);
return; return;
} }
// All mime types in index. // All mime types in index.
vector<string> vdbtypes; vector<string> vdbtypes;
if (!rcldb->getAllDbMimeTypes(vdbtypes)) { if (!rcldb->getAllDbMimeTypes(vdbtypes)) {
QMessageBox::warning(0, tr("Error"), QMessageBox::warning(0, tr("Error"),
tr("Index query error"), tr("Index query error"),
QMessageBox::Ok, QMessageBox::Ok,
QMessageBox::NoButton); QMessageBox::NoButton);
return; return;
} }
set<string> mtypesfromdb; set<string> mtypesfromdb;
mtypesfromdb.insert(vdbtypes.begin(), vdbtypes.end()); mtypesfromdb.insert(vdbtypes.begin(), vdbtypes.end());
@ -389,27 +391,27 @@ void RclMain::showActiveTypes()
// config can be indexed by name, not by content) // config can be indexed by name, not by content)
set<string> mtypesfromdbconf; set<string> mtypesfromdbconf;
for (vector<string>::const_iterator it = mtypesfromconfig.begin(); for (vector<string>::const_iterator it = mtypesfromconfig.begin();
it != mtypesfromconfig.end(); it++) { it != mtypesfromconfig.end(); it++) {
if (mtypesfromdb.find(*it) != mtypesfromdb.end()) if (mtypesfromdb.find(*it) != mtypesfromdb.end())
mtypesfromdbconf.insert(*it); mtypesfromdbconf.insert(*it);
} }
// Substract the types for missing helpers (the docs are indexed // Substract the types for missing helpers (the docs are indexed
// by name only): // by name only):
string miss; string miss;
if (theconfig->getMissingHelperDesc(miss) && !miss.empty()) { if (theconfig->getMissingHelperDesc(miss) && !miss.empty()) {
FIMissingStore st(miss); FIMissingStore st(miss);
map<string, set<string> >::const_iterator it; map<string, set<string> >::const_iterator it;
for (it = st.m_typesForMissing.begin(); for (it = st.m_typesForMissing.begin();
it != st.m_typesForMissing.end(); it++) { it != st.m_typesForMissing.end(); it++) {
set<string>::const_iterator it1; set<string>::const_iterator it1;
for (it1 = it->second.begin(); for (it1 = it->second.begin();
it1 != it->second.end(); it1++) { it1 != it->second.end(); it1++) {
set<string>::iterator it2 = mtypesfromdbconf.find(*it1); set<string>::iterator it2 = mtypesfromdbconf.find(*it1);
if (it2 != mtypesfromdbconf.end()) if (it2 != mtypesfromdbconf.end())
mtypesfromdbconf.erase(it2); mtypesfromdbconf.erase(it2);
} }
} }
} }
ListDialog dialog; ListDialog dialog;
dialog.setWindowTitle(tr("Indexed MIME Types")); dialog.setWindowTitle(tr("Indexed MIME Types"));
@ -424,7 +426,7 @@ void RclMain::showActiveTypes()
dialog.horizontalLayout->addWidget(editor); dialog.horizontalLayout->addWidget(editor);
if (mtypesfromdbconf.empty()) { if (mtypesfromdbconf.empty()) {
editor->append(tr("Types list empty: maybe wait for indexing to " editor->append(tr("Types list empty: maybe wait for indexing to "
"progress?")); "progress?"));
} else { } else {
for (set<string>::const_iterator it = mtypesfromdbconf.begin(); for (set<string>::const_iterator it = mtypesfromdbconf.begin();
@ -443,7 +445,7 @@ void RclMain::newDupsW(const Rcl::Doc, const vector<Rcl::Doc> dups)
dialog.setWindowTitle(tr("Duplicate documents")); dialog.setWindowTitle(tr("Duplicate documents"));
dialog.groupBox->setTitle(tr("These Urls ( | ipath) share the same" dialog.groupBox->setTitle(tr("These Urls ( | ipath) share the same"
" content:")); " content:"));
// We replace the list with an editor so that the user can copy/paste // We replace the list with an editor so that the user can copy/paste
delete dialog.listWidget; delete dialog.listWidget;
QTextEdit *editor = new QTextEdit(dialog.groupBox); QTextEdit *editor = new QTextEdit(dialog.groupBox);
@ -451,11 +453,11 @@ void RclMain::newDupsW(const Rcl::Doc, const vector<Rcl::Doc> dups)
dialog.horizontalLayout->addWidget(editor); dialog.horizontalLayout->addWidget(editor);
for (vector<Rcl::Doc>::const_iterator it = dups.begin(); for (vector<Rcl::Doc>::const_iterator it = dups.begin();
it != dups.end(); it++) { it != dups.end(); it++) {
if (it->ipath.empty()) if (it->ipath.empty())
editor->append(path2qs(it->url)); editor->append(path2qs(it->url));
else else
editor->append(path2qs(it->url) + " | " + u8s2qs(it->ipath)); editor->append(path2qs(it->url) + " | " + u8s2qs(it->ipath));
} }
editor->moveCursor(QTextCursor::Start); editor->moveCursor(QTextCursor::Start);
editor->ensureCursorVisible(); editor->ensureCursorVisible();