Side filters: ensure filter value is used when set before query

This commit is contained in:
Jean-Francois Dockes 2022-05-14 21:28:53 +02:00
parent 28fa7387ec
commit 0250e64b5a

View File

@ -147,8 +147,7 @@ void RclMain::init()
setupMenus(); setupMenus();
(void)new HelpClient(this); (void)new HelpClient(this);
HelpClient::installMap((const char *)this->objectName().toUtf8(), HelpClient::installMap((const char *)this->objectName().toUtf8(), "RCL.SEARCH.GUI.SIMPLE");
"RCL.SEARCH.GUI.SIMPLE");
// Set the focus to the search terms entry: // Set the focus to the search terms entry:
sSearch->takeFocus(); sSearch->takeFocus();
@ -329,11 +328,9 @@ void RclMain::onNewShortcuts()
SETSHORTCUT(sSearch, "main:347", tr("Main Window"), tr("Clear search"), SETSHORTCUT(sSearch, "main:347", tr("Main Window"), tr("Clear search"),
"Ctrl+S", m_clearsearchsc, clearAll); "Ctrl+S", m_clearsearchsc, clearAll);
SETSHORTCUT(sSearch, "main:349", tr("Main Window"), SETSHORTCUT(sSearch, "main:349", tr("Main Window"), tr("Move keyboard focus to search entry"),
tr("Move keyboard focus to search entry"),
"Ctrl+L", m_focustosearchsc, takeFocus); "Ctrl+L", m_focustosearchsc, takeFocus);
SETSHORTCUT(sSearch, "main:352", tr("Main Window"), SETSHORTCUT(sSearch, "main:352", tr("Main Window"), tr("Move keyboard focus to search, alt."),
tr("Move keyboard focus to search, alt."),
"Ctrl+Shift+S", m_focustosearcholdsc, takeFocus); "Ctrl+Shift+S", m_focustosearcholdsc, takeFocus);
// We could set this as an action shortcut, but then, it would not // We could set this as an action shortcut, but then, it would not
// be editable // be editable
@ -346,11 +343,9 @@ void RclMain::onNewShortcuts()
delete m_focustotablesc; delete m_focustotablesc;
m_focustotablesc = new QShortcut(ks, this); m_focustotablesc = new QShortcut(ks, this);
if (displayingTable) { if (displayingTable) {
connect(m_focustotablesc, SIGNAL(activated()), connect(m_focustotablesc, SIGNAL(activated()), restable, SLOT(takeFocus()));
restable, SLOT(takeFocus()));
} else { } else {
disconnect(m_focustotablesc, SIGNAL(activated()), disconnect(m_focustotablesc, SIGNAL(activated()), restable, SLOT(takeFocus()));
restable, SLOT(takeFocus()));
} }
} }
} }
@ -403,8 +398,7 @@ void RclMain::setupMenus()
MenuBar->hide(); MenuBar->hide();
sSearch->menuPB->show(); sSearch->menuPB->show();
butmenuSC = new QShortcut(QKeySequence("Alt+m"), this); butmenuSC = new QShortcut(QKeySequence("Alt+m"), this);
connect(butmenuSC, SIGNAL(activated()), connect(butmenuSC, SIGNAL(activated()), sSearch->menuPB, SLOT(showMenu()));
sSearch->menuPB, SLOT(showMenu()));
} else { } else {
MenuBar->show(); MenuBar->show();
sSearch->menuPB->hide(); sSearch->menuPB->hide();
@ -418,8 +412,7 @@ void RclMain::enableTrayIcon(bool on)
on = on && QSystemTrayIcon::isSystemTrayAvailable(); on = on && QSystemTrayIcon::isSystemTrayAvailable();
if (on) { if (on) {
if (nullptr == m_trayicon) { if (nullptr == m_trayicon) {
m_trayicon = new RclTrayIcon(this, m_trayicon = new RclTrayIcon(this, QIcon(QString(":/images/recoll.png")));
QIcon(QString(":/images/recoll.png")));
} }
m_trayicon->show(); m_trayicon->show();
} else { } else {
@ -574,19 +567,15 @@ void RclMain::initDbOpen()
nodb = true; nodb = true;
if (maindberror) { if (maindberror) {
FirstIdxDialog fidia(this); FirstIdxDialog fidia(this);
connect(fidia.idxconfCLB, SIGNAL(clicked()), connect(fidia.idxconfCLB, SIGNAL(clicked()), this, SLOT(execIndexConfig()));
this, SLOT(execIndexConfig())); connect(fidia.idxschedCLB, SIGNAL(clicked()), this, SLOT(execIndexSched()));
connect(fidia.idxschedCLB, SIGNAL(clicked()), connect(fidia.runidxPB, SIGNAL(clicked()), this, SLOT(rebuildIndex()));
this, SLOT(execIndexSched()));
connect(fidia.runidxPB, SIGNAL(clicked()),
this, SLOT(rebuildIndex()));
fidia.exec(); fidia.exec();
// Don't open adv search or run cmd line search in this case. // Don't open adv search or run cmd line search in this case.
return; return;
} else { } else {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll", tr("Could not open external index. Db not "
tr("Could not open external index. Db not " "open. Check external indexes list."));
"open. Check external indexes list."));
} }
} }
@ -631,8 +620,7 @@ void RclMain::setStemLang(QAction *id)
lang = id->text(); lang = id->text();
} }
prefs.queryStemLang = lang; prefs.queryStemLang = lang;
LOGDEB("RclMain::setStemLang(" << id << "): lang [" << LOGDEB("RclMain::setStemLang(" << id << "): lang [" << qs2utf8s(prefs.queryStemLang) << "]\n");
qs2utf8s(prefs.queryStemLang) << "]\n");
rwSettings(true); rwSettings(true);
emit stemLangChanged(lang); emit stemLangChanged(lang);
} }
@ -667,8 +655,7 @@ void RclMain::adjustPrefsMenu()
void RclMain::showTrayMessage(const QString& text) void RclMain::showTrayMessage(const QString& text)
{ {
if (m_trayicon && prefs.trayMessages) if (m_trayicon && prefs.trayMessages)
m_trayicon->showMessage("Recoll", text, m_trayicon->showMessage("Recoll", text, QSystemTrayIcon::Information, 2000);
QSystemTrayIcon::Information, 2000);
} }
void RclMain::closeEvent(QCloseEvent *ev) void RclMain::closeEvent(QCloseEvent *ev)
@ -755,8 +742,7 @@ void RclMain::startSearch(std::shared_ptr<Rcl::SearchData> sdata, bool issimple)
if (prefs.synFileEnable && !prefs.synFile.isEmpty()) { if (prefs.synFileEnable && !prefs.synFile.isEmpty()) {
if (!rcldb->setSynGroupsFile(qs2path(prefs.synFile))) { if (!rcldb->setSynGroupsFile(qs2path(prefs.synFile))) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll", tr("Can't set synonyms file (parse error?)"));
tr("Can't set synonyms file (parse error?)"));
return; return;
} }
} else { } else {
@ -767,11 +753,9 @@ void RclMain::startSearch(std::shared_ptr<Rcl::SearchData> sdata, bool issimple)
query->setCollapseDuplicates(prefs.collapseDuplicates); query->setCollapseDuplicates(prefs.collapseDuplicates);
curPreview = 0; curPreview = 0;
DocSequenceDb *src = DocSequenceDb *src = new DocSequenceDb(rcldb, std::shared_ptr<Rcl::Query>(query),
new DocSequenceDb(rcldb, std::shared_ptr<Rcl::Query>(query), qs2utf8s(tr("Query results")), sdata);
qs2utf8s(tr("Query results")), sdata); src->setAbstractParams(prefs.queryBuildAbstract, prefs.queryReplaceAbstract);
src->setAbstractParams(prefs.queryBuildAbstract,
prefs.queryReplaceAbstract);
m_source = std::shared_ptr<DocSequence>(src); m_source = std::shared_ptr<DocSequence>(src);
// If this is a file name search sort by mtype so that directories // If this is a file name search sort by mtype so that directories
@ -782,25 +766,20 @@ void RclMain::startSearch(std::shared_ptr<Rcl::SearchData> sdata, bool issimple)
m_sortspec.desc = false; m_sortspec.desc = false;
} }
m_source->setSortSpec(m_sortspec); m_source->setSortSpec(m_sortspec);
m_source->setFiltSpec(m_filtspec); setFiltSpec();
emit docSourceChanged(m_source); emit docSourceChanged(m_source);
emit sortDataChanged(m_sortspec); emit sortDataChanged(m_sortspec);
initiateQuery();
} }
class QueryThread : public QThread { class QueryThread : public QThread {
std::shared_ptr<DocSequence> m_source; std::shared_ptr<DocSequence> m_source;
public: public:
QueryThread(std::shared_ptr<DocSequence> source) QueryThread(std::shared_ptr<DocSequence> source)
: m_source(source) : m_source(source) {}
{ ~QueryThread() {}
} virtual void run() {
~QueryThread() { } cnt = m_source->getResCnt();
virtual void run() }
{
cnt = m_source->getResCnt();
}
int cnt; int cnt;
}; };
@ -1006,9 +985,7 @@ void RclMain::saveDocToFile(Rcl::Doc doc)
string tofile = qs2path(s); string tofile = qs2path(s);
TempFile temp; // not used because tofile is set. TempFile temp; // not used because tofile is set.
if (!FileInterner::idocToFile(temp, tofile, theconfig, doc)) { if (!FileInterner::idocToFile(temp, tofile, theconfig, doc)) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll", tr("Cannot extract document or create temporary file"));
tr("Cannot extract document or create "
"temporary file"));
return; return;
} }
} }
@ -1058,8 +1035,7 @@ void RclMain::docExpand(Rcl::Doc doc)
// rcldb->expand is set to keep the original query terms instead. // rcldb->expand is set to keep the original query terms instead.
QString text;// = sSearch->queryText->currentText(); QString text;// = sSearch->queryText->currentText();
for (list<string>::iterator it = terms.begin(); it != terms.end(); it++) { for (list<string>::iterator it = terms.begin(); it != terms.end(); it++) {
text += QString::fromLatin1(" \"") + text += u8s2qs(std::string(" \"") + *it + "\"");
QString::fromUtf8((*it).c_str()) + QString::fromLatin1("\"");
} }
// We need to insert item here, its not auto-done like when the user types // We need to insert item here, its not auto-done like when the user types
// CR // CR
@ -1080,25 +1056,20 @@ void RclMain::showDocHistory()
return; return;
} }
// Construct a bogus SearchData structure // Construct a bogus SearchData structure
std::shared_ptr<Rcl::SearchData>searchdata = auto searchdata = std::make_shared<Rcl::SearchData>(Rcl::SCLT_AND, cstr_null);
std::shared_ptr<Rcl::SearchData>(new Rcl::SearchData(Rcl::SCLT_AND,
cstr_null));
searchdata->setDescription((const char *)tr("History data").toUtf8()); searchdata->setDescription((const char *)tr("History data").toUtf8());
// If you change the title, also change it in eraseDocHistory() // If you change the title, also change it in eraseDocHistory()
DocSequenceHistory *src = DocSequenceHistory *src =
new DocSequenceHistory(rcldb, g_dynconf, new DocSequenceHistory(rcldb, g_dynconf, qs2utf8s(tr("Document history")));
string(tr("Document history").toUtf8())); src->setDescription(qs2utf8s(tr("History data")));
src->setDescription((const char *)tr("History data").toUtf8()); DocSource *source = new DocSource(theconfig, std::shared_ptr<DocSequence>(src));
DocSource *source = new DocSource(theconfig,
std::shared_ptr<DocSequence>(src));
m_source = std::shared_ptr<DocSequence>(source); m_source = std::shared_ptr<DocSequence>(source);
m_source->setSortSpec(m_sortspec); m_source->setSortSpec(m_sortspec);
m_source->setFiltSpec(m_filtspec); setFiltSpec();
emit docSourceChanged(m_source); emit docSourceChanged(m_source);
emit sortDataChanged(m_sortspec); emit sortDataChanged(m_sortspec);
initiateQuery();
} }
// Erase all memory of documents viewed // Erase all memory of documents viewed
@ -1116,9 +1087,8 @@ void RclMain::eraseDocHistory()
void RclMain::eraseSearchHistory() void RclMain::eraseSearchHistory()
{ {
int rep = QMessageBox::warning( int rep = QMessageBox::warning(
0, tr("Confirm"), 0, tr("Confirm"),
tr("Erasing simple and advanced search history lists, " tr("Erasing simple and advanced search history lists, please click Ok to confirm"),
"please click Ok to confirm"),
QMessageBox::Ok, QMessageBox::Cancel, QMessageBox::NoButton); QMessageBox::Ok, QMessageBox::Cancel, QMessageBox::NoButton);
if (rep == QMessageBox::Ok) { if (rep == QMessageBox::Ok) {
prefs.ssearchHistory.clear(); prefs.ssearchHistory.clear();
@ -1188,8 +1158,7 @@ QString RclMain::getQueryDescription()
{ {
if (!m_source) if (!m_source)
return ""; return "";
return m_queryDescription.isEmpty() ? return m_queryDescription.isEmpty() ? u8s2qs(m_source->getDescription()) : m_queryDescription;
u8s2qs(m_source->getDescription()) : m_queryDescription;
} }
// Set filter, action style // Set filter, action style