GUI: Only enable the side filters in query language mode
This commit is contained in:
parent
03149a57b4
commit
77024d3f6a
@ -47,6 +47,14 @@ void RclMain::populateSideFilters(bool init)
|
||||
}
|
||||
}
|
||||
|
||||
void RclMain::enableSideFilters(bool enable)
|
||||
{
|
||||
idxTreeView->setEnabled(enable);
|
||||
dateFilterCB->setEnabled(enable);
|
||||
minDateFilterDTEDT->setEnabled(enable && dateFilterCB->isChecked());
|
||||
maxDateFilterDTEDT->setEnabled(enable && dateFilterCB->isChecked());
|
||||
}
|
||||
|
||||
void RclMain::clearDirFilter()
|
||||
{
|
||||
idxTreeView->clearSelection();
|
||||
|
||||
@ -40,6 +40,20 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayoutsidefilt">
|
||||
<item>
|
||||
<widget class="Line" name="line3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="sideFilterLBL">
|
||||
<property name="text">
|
||||
<string>Query Language Filters</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line2">
|
||||
<property name="orientation">
|
||||
|
||||
@ -177,6 +177,7 @@ void RclMain::init()
|
||||
|
||||
connect(sSearch, SIGNAL(startSearch(std::shared_ptr<Rcl::SearchData>, bool)),
|
||||
this, SLOT(startSearch(std::shared_ptr<Rcl::SearchData>, bool)));
|
||||
connect(sSearch, SIGNAL(ssearchTypeChanged(int)), this, SLOT(onSSearchTypeChanged(int)));
|
||||
connect(sSearch, SIGNAL(setDescription(QString)), this, SLOT(onSetDescription(QString)));
|
||||
connect(sSearch, SIGNAL(clearSearch()), this, SLOT(resetSearch()));
|
||||
connect(this, SIGNAL(uiPrefsChanged()), sSearch, SLOT(setPrefs()));
|
||||
@ -301,6 +302,11 @@ void RclMain::init()
|
||||
periodictimer->start(1000);
|
||||
}
|
||||
|
||||
void RclMain::onSSearchTypeChanged(int typ)
|
||||
{
|
||||
enableSideFilters(typ == SSearch::SST_LANG);
|
||||
}
|
||||
|
||||
void RclMain::zoomIn()
|
||||
{
|
||||
prefs.reslistfontsize++;
|
||||
@ -1220,7 +1226,9 @@ void RclMain::catgFilter(int id)
|
||||
void RclMain::setFiltSpec()
|
||||
{
|
||||
m_filtspec.reset();
|
||||
|
||||
if (nullptr == m_source)
|
||||
return;
|
||||
|
||||
// "Category" buttons
|
||||
if (m_catgbutvecidx != 0) {
|
||||
string catg = m_catgbutvec[m_catgbutvecidx];
|
||||
@ -1238,32 +1246,35 @@ void RclMain::setFiltSpec()
|
||||
}
|
||||
}
|
||||
|
||||
auto treedirs = idxTreeGetDirs();
|
||||
if (!treedirs.empty()) {
|
||||
bool first{true};
|
||||
const std::string prefix{"dir:"};
|
||||
std::string clause;
|
||||
for (const auto& dir : treedirs) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
clause += " OR ";
|
||||
}
|
||||
clause += prefix + makeCString(dir);
|
||||
if (dateFilterCB->isEnabled()) {
|
||||
// The CB is only disabled when we are not in query language mode
|
||||
auto treedirs = idxTreeGetDirs();
|
||||
if (!treedirs.empty()) {
|
||||
bool first{true};
|
||||
const std::string prefix{"dir:"};
|
||||
std::string clause;
|
||||
for (const auto& dir : treedirs) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
clause += " OR ";
|
||||
}
|
||||
clause += prefix + makeCString(dir);
|
||||
}
|
||||
LOGDEB0("Sidefilter dir clause: [" << clause << "]\n");
|
||||
m_filtspec.orCrit(DocSeqFiltSpec::DSFS_QLANG, clause);
|
||||
}
|
||||
|
||||
if (dateFilterCB->isChecked()) {
|
||||
QString mindate = minDateFilterDTEDT->date().toString("yyyy-MM-dd");
|
||||
QString maxdate = maxDateFilterDTEDT->date().toString("yyyy-MM-dd");
|
||||
std::string clause = std::string("date:") + qs2utf8s(mindate) + "/" + qs2utf8s(maxdate);
|
||||
LOGDEB1("RclMain::setFiltSpec: date clause " << clause << "\n");
|
||||
m_filtspec.orCrit(DocSeqFiltSpec::DSFS_QLANG, clause);
|
||||
}
|
||||
LOGDEB0("Sidefilter dir clause: [" << clause << "]\n");
|
||||
m_filtspec.orCrit(DocSeqFiltSpec::DSFS_QLANG, clause);
|
||||
}
|
||||
|
||||
if (dateFilterCB->isChecked()) {
|
||||
QString mindate = minDateFilterDTEDT->date().toString("yyyy-MM-dd");
|
||||
QString maxdate = maxDateFilterDTEDT->date().toString("yyyy-MM-dd");
|
||||
std::string clause = std::string("date:") + qs2utf8s(mindate) + "/" + qs2utf8s(maxdate);
|
||||
LOGDEB1("RclMain::setFiltSpec: date clause " << clause << "\n");
|
||||
m_filtspec.orCrit(DocSeqFiltSpec::DSFS_QLANG, clause);
|
||||
}
|
||||
if (m_source)
|
||||
m_source->setFiltSpec(m_filtspec);
|
||||
m_source->setFiltSpec(m_filtspec);
|
||||
initiateQuery();
|
||||
}
|
||||
|
||||
|
||||
@ -177,7 +177,9 @@ public slots:
|
||||
virtual void zoomIn();
|
||||
virtual void zoomOut();
|
||||
virtual void setFiltSpec();
|
||||
|
||||
virtual void onSSearchTypeChanged(int);
|
||||
virtual void enableSideFilters(bool enable);
|
||||
|
||||
private slots:
|
||||
virtual bool updateIdxStatus();
|
||||
virtual void onWebcacheDestroyed(QObject *);
|
||||
|
||||
@ -167,8 +167,7 @@ void SSearch::init()
|
||||
this, SLOT(searchTextEdited(const QString&)));
|
||||
connect(clearqPB, SIGNAL(clicked()), queryText, SLOT(clear()));
|
||||
connect(searchPB, SIGNAL(clicked()), this, SLOT(startSimpleSearch()));
|
||||
connect(searchTypCMB, SIGNAL(activated(int)), this,
|
||||
SLOT(onSearchTypeChanged(int)));
|
||||
connect(searchTypCMB, SIGNAL(activated(int)), this, SLOT(onSearchTypeChanged(int)));
|
||||
|
||||
m_completermodel = new RclCompleterModel(this);
|
||||
m_completer = new QCompleter(m_completermodel, this);
|
||||
@ -391,11 +390,9 @@ void SSearch::onSearchTypeChanged(int typ)
|
||||
|
||||
// Adjust context help
|
||||
if (typ == SST_LANG) {
|
||||
HelpClient::installMap((const char *)this->objectName().toUtf8(),
|
||||
"RCL.SEARCH.LANG");
|
||||
HelpClient::installMap((const char *)this->objectName().toUtf8(), "RCL.SEARCH.LANG");
|
||||
} else {
|
||||
HelpClient::installMap((const char *)this->objectName().toUtf8(),
|
||||
"RCL.SEARCH.GUI.SIMPLE");
|
||||
HelpClient::installMap((const char *)this->objectName().toUtf8(), "RCL.SEARCH.GUI.SIMPLE");
|
||||
}
|
||||
// Also fix tooltips
|
||||
switch (typ) {
|
||||
@ -447,6 +444,7 @@ void SSearch::onSearchTypeChanged(int typ)
|
||||
default:
|
||||
queryText->setToolTip(tr("Enter search terms here."));
|
||||
}
|
||||
emit ssearchTypeChanged(typ);
|
||||
}
|
||||
|
||||
void SSearch::startSimpleSearch()
|
||||
|
||||
@ -112,7 +112,8 @@ signals:
|
||||
void setDescription(QString);
|
||||
void clearSearch();
|
||||
void partialWord(int, const QString& text, const QString &partial);
|
||||
|
||||
void ssearchTypeChanged(int typ);
|
||||
|
||||
private:
|
||||
int getPartialWord(QString& word);
|
||||
bool startSimpleSearch(const string& q, int maxexp = -1);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user