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);
}
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);
QString sz;
if (sdata->m_minSize != (size_t)-1) {
if (sdata->m_minSize != -1) {
sz.setNum(sdata->m_minSize);
minSizeLE->setText(sz);
} else {
minSizeLE->setText("");
}
if (sdata->m_maxSize != (size_t)-1) {
if (sdata->m_maxSize != -1) {
sz.setNum(sdata->m_maxSize);
maxSizeLE->setText(sz);
} else {

View File

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

View File

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