diff --git a/src/qtgui/advsearch_w.cpp b/src/qtgui/advsearch_w.cpp index 94648251..047b5ec7 100644 --- a/src/qtgui/advsearch_w.cpp +++ b/src/qtgui/advsearch_w.cpp @@ -293,6 +293,9 @@ void AdvSearch::fillFileTypes() QStringList ql; if (m_ignByCats == false) { vector types = theconfig->getAllMimeTypes(); + rcldb->getAllDbMimeTypes(types); + sort(types.begin(), types.end()); + types.erase(unique(types.begin(), types.end()), types.end()); for (vector::iterator it = types.begin(); it != types.end(); it++) { QString qs = QString::fromUtf8(it->c_str()); diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index cf7f798d..6cf6ea85 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -1108,24 +1108,17 @@ void RclMain::showActiveTypes() return; } - // Get list of all mime types in index. For this, we use a - // wildcard field search on mtype - Rcl::TermMatchResult matches; - if (!rcldb->termMatch(Rcl::Db::ET_WILD, "", "*", matches, -1, "mtype")) { + // All mime types in index. + vector vdbtypes; + if (!rcldb->getAllDbMimeTypes(vdbtypes)) { QMessageBox::warning(0, tr("Error"), tr("Index query error"), QMessageBox::Ok, QMessageBox::NoButton); return; } - - // Build the set of mtypes, stripping the prefix set mtypesfromdb; - for (vector::const_iterator it = - matches.entries.begin(); - it != matches.entries.end(); it++) { - mtypesfromdb.insert(it->term.substr(matches.prefix.size())); - } + mtypesfromdb.insert(vdbtypes.begin(), vdbtypes.end()); // All types listed in mimeconf: vector mtypesfromconfig = theconfig->getAllMimeTypes(); diff --git a/src/qtgui/ssearch_w.cpp b/src/qtgui/ssearch_w.cpp index d828d49b..d27a6fba 100644 --- a/src/qtgui/ssearch_w.cpp +++ b/src/qtgui/ssearch_w.cpp @@ -352,16 +352,13 @@ int SSearch::partialWord(string& s) } // Create completion list for term by adding a joker at the end and calling -// rcldb->termMatch(). This does not work well if the db is not -// rcldb->stripped, the completion is casediac-sensitive in this case. -// -// What we should do instead is complete the term from the key list in -// the casediac expansion db (stripped->unstripped synonyms table), -// then expand each of the completed keys. +// rcldb->termMatch(). int SSearch::completionList(string s, QStringList& lst, int max) { if (!rcldb) return -1; + if (s.empty()) + return 0; // Query database for completions s += "*"; Rcl::TermMatchResult tmres; diff --git a/src/qtgui/uiprefs.ui b/src/qtgui/uiprefs.ui index bc2c9573..9d430f2e 100644 --- a/src/qtgui/uiprefs.ui +++ b/src/qtgui/uiprefs.ui @@ -22,7 +22,7 @@ - 3 + 1 @@ -284,6 +284,9 @@ 1 + + 9999 + 8 diff --git a/src/rcldb/rcldb.h b/src/rcldb/rcldb.h index 06e87531..7b6b5a74 100644 --- a/src/rcldb/rcldb.h +++ b/src/rcldb/rcldb.h @@ -329,6 +329,10 @@ class Db { bool dbStats(DbStats& stats); /** Return min and max years for doc mod times in db */ bool maxYearSpan(int *minyear, int *maxyear); + /** Return all mime types in index. This can be different from the + ones defined in the config because of 'file' command + usage. Inserts the types at the end of the parameter */ + bool getAllDbMimeTypes(std::vector&); /** Wildcard expansion specific to file names. Internal/sdata use only */ bool filenameWildExp(const string& exp, vector& names, int max); diff --git a/src/rcldb/rclterms.cpp b/src/rcldb/rclterms.cpp index 786858de..e1c27c51 100644 --- a/src/rcldb/rclterms.cpp +++ b/src/rcldb/rclterms.cpp @@ -59,8 +59,8 @@ bool Db::filenameWildExp(const string& fnexp, vector& names, int max) } TermMatchResult result; - if (!termMatch(ET_WILD, string(), pattern, result, max, - unsplitFilenameFieldName)) + if (!idxTermMatch(ET_WILD, string(), pattern, result, max, + unsplitFilenameFieldName)) return false; for (vector::const_iterator it = result.entries.begin(); it != result.entries.end(); it++) @@ -81,7 +81,7 @@ bool Db::maxYearSpan(int *minyear, int *maxyear) *minyear = 1000000; *maxyear = -1000000; TermMatchResult result; - if (!termMatch(ET_WILD, string(), "*", result, -1, "xapyear")) { + if (!idxTermMatch(ET_WILD, string(), "*", result, -1, "xapyear")) { LOGINFO(("Rcl::Db:maxYearSpan: termMatch failed\n")); return false; } @@ -98,6 +98,19 @@ bool Db::maxYearSpan(int *minyear, int *maxyear) return true; } +bool Db::getAllDbMimeTypes(std::vector& exp) +{ + Rcl::TermMatchResult res; + if (!idxTermMatch(Rcl::Db::ET_WILD, "", "*", res, -1, "mtype")) { + return false; + } + for (vector::const_iterator rit = res.entries.begin(); + rit != res.entries.end(); rit++) { + exp.push_back(Rcl::strip_prefix(rit->term)); + } + return true; +} + class TermMatchCmpByWcf { public: int operator()(const TermMatchEntry& l, const TermMatchEntry& r) { diff --git a/src/rcldb/searchdata.cpp b/src/rcldb/searchdata.cpp index f7e854d7..f125b1ca 100644 --- a/src/rcldb/searchdata.cpp +++ b/src/rcldb/searchdata.cpp @@ -87,7 +87,9 @@ bool SearchData::expandFileTypes(Db &db, vector& tps) } else { TermMatchResult res; string mt = stringtolower((const string&)*it); - db.termMatch(Db::ET_WILD, "", mt, res, -1, "mtype"); + // We set casesens|diacsens to get an equivalent of ixTermMatch() + db.termMatch(Db::ET_WILD|Db::ET_CASESENS|Db::ET_DIACSENS, string(), + mt, res, -1, "mtype"); if (res.entries.empty()) { exptps.push_back(it->c_str()); } else {