Fix issues consequent to type change for searchdata m_minsize and m_maxsize members

This commit is contained in:
Jean-Francois Dockes 2020-04-21 13:45:00 +01:00
parent 9670bb8ecf
commit 8a29522ef8
4 changed files with 21 additions and 38 deletions

View File

@ -552,16 +552,16 @@ void AdvSearch::fromSearch(std::shared_ptr<SearchData> sdata)
maxDateDTE->setDate(date); maxDateDTE->setDate(date);
} }
if (sdata->m_maxSize != (size_t)-1 || sdata->m_minSize != (size_t)-1) { if (sdata->m_maxSize != -1 || sdata->m_minSize != -1) {
filterSizesCB->setChecked(1); filterSizesCB->setChecked(1);
QString sz; QString sz;
if (sdata->m_minSize != (size_t)-1) { if (sdata->m_minSize != -1) {
sz.setNum(sdata->m_minSize); sz.setNum(sdata->m_minSize);
minSizeLE->setText(sz); minSizeLE->setText(sz);
} else { } else {
minSizeLE->setText(""); minSizeLE->setText("");
} }
if (sdata->m_maxSize != (size_t)-1) { if (sdata->m_maxSize != -1) {
sz.setNum(sdata->m_maxSize); sz.setNum(sdata->m_maxSize);
maxSizeLE->setText(sz); maxSizeLE->setText(sz);
} else { } else {

View File

@ -53,19 +53,6 @@ namespace Rcl {
typedef vector<SearchDataClause *>::iterator qlist_it_t; typedef vector<SearchDataClause *>::iterator qlist_it_t;
typedef vector<SearchDataClause *>::const_iterator qlist_cit_t; typedef vector<SearchDataClause *>::const_iterator qlist_cit_t;
void SearchData::commoninit()
{
m_haveDates = false;
m_maxSize = size_t(-1);
m_minSize = size_t(-1);
m_haveWildCards = false;
m_autodiacsens = false;
m_autocasesens = true;
m_maxexp = 10000;
m_maxcl = 100000;
m_softmaxexpand = -1;
}
SearchData::~SearchData() SearchData::~SearchData()
{ {
LOGDEB0("SearchData::~SearchData\n" ); LOGDEB0("SearchData::~SearchData\n" );
@ -215,8 +202,8 @@ void SearchData::simplify()
if (!clsubp->getSub()->m_filetypes.empty() || if (!clsubp->getSub()->m_filetypes.empty() ||
!clsubp->getSub()->m_nfiletypes.empty() || !clsubp->getSub()->m_nfiletypes.empty() ||
clsubp->getSub()->m_haveDates || clsubp->getSub()->m_haveDates ||
clsubp->getSub()->m_maxSize != size_t(-1) || clsubp->getSub()->m_maxSize != -1 ||
clsubp->getSub()->m_minSize != size_t(-1) || clsubp->getSub()->m_minSize != -1 ||
clsubp->getSub()->m_haveWildCards) { clsubp->getSub()->m_haveWildCards) {
if (!clsubp->getSub()->m_query.empty()) if (!clsubp->getSub()->m_query.empty())
continue; continue;
@ -229,9 +216,9 @@ void SearchData::simplify()
if (clsubp->getSub()->m_haveDates && !m_haveDates) { if (clsubp->getSub()->m_haveDates && !m_haveDates) {
m_dates = clsubp->getSub()->m_dates; m_dates = clsubp->getSub()->m_dates;
} }
if (m_maxSize == size_t(-1)) if (m_maxSize == -1)
m_maxSize = clsubp->getSub()->m_maxSize; m_maxSize = clsubp->getSub()->m_maxSize;
if (m_minSize == size_t(-1)) if (m_minSize == -1)
m_minSize = clsubp->getSub()->m_minSize; m_minSize = clsubp->getSub()->m_minSize;
m_haveWildCards = m_haveWildCards || m_haveWildCards = m_haveWildCards ||
clsubp->getSub()->m_haveWildCards; clsubp->getSub()->m_haveWildCards;
@ -305,8 +292,8 @@ void SearchData::dump(ostream& o) const
o << dumptabs << o << dumptabs <<
"SearchData: " << tpToString(m_tp) << " qs " << int(m_query.size()) << "SearchData: " << tpToString(m_tp) << " qs " << int(m_query.size()) <<
" ft " << m_filetypes.size() << " nft " << m_nfiletypes.size() << " ft " << m_filetypes.size() << " nft " << m_nfiletypes.size() <<
" hd " << m_haveDates << " maxs " << int(m_maxSize) << " mins " << " hd " << m_haveDates << " maxs " << m_maxSize << " mins " <<
int(m_minSize) << " wc " << m_haveWildCards << "\n"; m_minSize << " wc " << m_haveWildCards << "\n";
for (std::vector<SearchDataClause*>::const_iterator it = for (std::vector<SearchDataClause*>::const_iterator it =
m_query.begin(); it != m_query.end(); it++) { m_query.begin(); it != m_query.end(); it++) {
o << dumptabs; o << dumptabs;

View File

@ -81,11 +81,9 @@ public:
: m_tp(tp), m_stemlang(stemlang) { : m_tp(tp), m_stemlang(stemlang) {
if (m_tp != SCLT_OR && m_tp != SCLT_AND) if (m_tp != SCLT_OR && m_tp != SCLT_AND)
m_tp = SCLT_OR; m_tp = SCLT_OR;
commoninit();
} }
SearchData() SearchData()
: m_tp(SCLT_AND) { : m_tp(SCLT_AND) {
commoninit();
} }
~SearchData(); ~SearchData();
@ -177,33 +175,33 @@ private:
// Special stuff produced by input which looks like a clause but means // Special stuff produced by input which looks like a clause but means
// something else (date and size specs) // something else (date and size specs)
bool m_haveDates; bool m_haveDates{false};
DateInterval m_dates; // Restrict to date interval DateInterval m_dates; // Restrict to date interval
int64_t m_maxSize; int64_t m_maxSize{-1};
int64_t m_minSize; int64_t m_minSize{-1};
// Printable expanded version of the complete query, retrieved/set // Printable expanded version of the complete query, retrieved/set
// from rcldb after the Xapian::setQuery() call // from rcldb after the Xapian::setQuery() call
std::string m_description; std::string m_description;
// Error diag // Error diag
std::string m_reason; std::string m_reason;
bool m_haveWildCards; bool m_haveWildCards{false};
std::string m_stemlang; std::string m_stemlang;
// Parameters set at the start of ToNativeQuery because they need // Parameters set at the start of ToNativeQuery because they need
// an rclconfig. Actually this does not make sense and it would be // an rclconfig. Actually this does not make sense and it would be
// simpler to just pass an rclconfig to the constructor; // simpler to just pass an rclconfig to the constructor;
bool m_autodiacsens; bool m_autodiacsens{false};
bool m_autocasesens; bool m_autocasesens{true};
int m_maxexp; int m_maxexp{10000};
int m_maxcl; int m_maxcl{100000};
// Parameters which are not part of the main query data but may influence // Parameters which are not part of the main query data but may influence
// translation in special cases. // translation in special cases.
// Maximum TermMatch (e.g. wildcard) expansion. This is normally set // Maximum TermMatch (e.g. wildcard) expansion. This is normally set
// from the configuration with a high default, but may be set to a lower // from the configuration with a high default, but may be set to a lower
// value during "find-as-you-type" operations from the GUI // value during "find-as-you-type" operations from the GUI
int m_softmaxexpand; int m_softmaxexpand{-1};
// Collapse bogus subqueries generated by the query parser, mostly // Collapse bogus subqueries generated by the query parser, mostly
// so that we can check if this is an autophrase candidate (else // so that we can check if this is an autophrase candidate (else
@ -214,8 +212,6 @@ private:
bool clausesToQuery(Rcl::Db &db, SClType tp, bool clausesToQuery(Rcl::Db &db, SClType tp,
std::vector<SearchDataClause*>& query, std::vector<SearchDataClause*>& query,
string& reason, void *d); string& reason, void *d);
void commoninit();
/* Copyconst and assignment private and forbidden */ /* Copyconst and assignment private and forbidden */
SearchData(const SearchData &) {} SearchData(const SearchData &) {}
SearchData& operator=(const SearchData&) {return *this;}; SearchData& operator=(const SearchData&) {return *this;};

View File

@ -139,10 +139,10 @@ string SearchData::asXML()
} }
} }
if (m_minSize != size_t(-1)) { if (m_minSize != -1) {
os << "<MIS>" << m_minSize << "</MIS>" << endl; os << "<MIS>" << m_minSize << "</MIS>" << endl;
} }
if (m_maxSize != size_t(-1)) { if (m_maxSize != -1) {
os << "<MAS>" << m_maxSize << "</MAS>" << endl; os << "<MAS>" << m_maxSize << "</MAS>" << endl;
} }