diff options
author | supermerill <merill@free.fr> | 2022-07-19 17:10:55 +0300 |
---|---|---|
committer | supermerill <merill@free.fr> | 2022-07-19 17:17:12 +0300 |
commit | 4cec66ec5363e81a47fcd43690b53f50b96f99a8 (patch) | |
tree | 06a514e0476f49047eb110ba9dd776d2a151aa7e | |
parent | df9d385036e27c2bc73793f17212426c63a459ec (diff) |
Search now compare all lowercase.
-rw-r--r-- | src/slic3r/GUI/Search.cpp | 19 | ||||
-rw-r--r-- | src/slic3r/GUI/Search.hpp | 2 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index 69cf519ee..36dfe82c2 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -112,7 +112,8 @@ static Option create_option(const std::string& opt_key, Preset::Type type, const (label + suffix).ToStdWstring(), (local_label + suffix_local).ToStdWstring(), gc.group.ToStdWstring(), _(gc.group).ToStdWstring(), category.ToStdWstring(), GUI::Tab::translate_category(category, type).ToStdWstring() , - wxString(opt.tooltip).ToStdWstring(), (_(opt.tooltip)).ToStdWstring() }; + wxString(opt.tooltip).ToStdWstring(), (_(opt.tooltip)).ToStdWstring(), + boost::algorithm::to_lower_copy(wxString(opt.tooltip).ToStdWstring()), boost::algorithm::to_lower_copy((_(opt.tooltip)).ToStdWstring()) }; return Option{}; } @@ -385,26 +386,29 @@ bool OptionsSearcher::search(const std::string& search, bool force/* = false*/) std::wstring wsearch = boost::nowide::widen(search); boost::trim_left(wsearch); + boost::algorithm::to_lower(wsearch); std::wstring label = get_label(opt, false); std::wstring label_english = get_label_english(opt, false); + std::wstring label_lowercase = boost::algorithm::to_lower_copy(label); + std::wstring label_english_lowercase = boost::algorithm::to_lower_copy(label_english); int score = std::numeric_limits<int>::min(); int score2; matches.clear(); //search for label if(view_params.exact) - strong_match(wsearch, label, score, matches); + strong_match(wsearch, label_lowercase, score, matches); else - fuzzy_match(wsearch, label, score, matches); + fuzzy_match(wsearch, label_lowercase, score, matches); //search in english label - if (view_params.english && (view_params.exact ? strong_match(wsearch, label_english, score2, matches2) : fuzzy_match(wsearch, label_english, score2, matches2)) && score2 > score) { + if (view_params.english && (view_params.exact ? strong_match(wsearch, label_english_lowercase, score2, matches2) : fuzzy_match(wsearch, label_english_lowercase, score2, matches2)) && score2 > score) { label = std::move(label_english); matches = std::move(matches2); score = score2; } - //search in opt_key + //search in opt_key (key is always lowercase) if ((view_params.exact ? strong_match(wsearch, opt.key, score2, matches2) : fuzzy_match(wsearch, opt.key, score2, matches2)) && (view_params.exact || score2 > score)) { for (fts::pos_type& pos : matches2) pos += label.size() + 1; @@ -417,9 +421,10 @@ bool OptionsSearcher::search(const std::string& search, bool force/* = false*/) size_t find_in_tooltip = std::wstring::npos; if (score <= 90) { //strong_match(wsearch, opt.tooltip_local, score2, matches2); //Too slow - find_in_tooltip = opt.tooltip_local.find(wsearch); + std::wstring tooltip_lowercase = opt.tooltip_local; + find_in_tooltip = opt.tooltip_local_lowercase.find(wsearch); if (find_in_tooltip == std::wstring::npos && view_params.english) { - find_in_tooltip = opt.tooltip.find(wsearch); + find_in_tooltip = opt.tooltip_lowercase.find(wsearch); } } if (score > 90/*std::numeric_limits<int>::min()*/ || find_in_tooltip != std::wstring::npos) { diff --git a/src/slic3r/GUI/Search.hpp b/src/slic3r/GUI/Search.hpp index b502b6e12..1575449ad 100644 --- a/src/slic3r/GUI/Search.hpp +++ b/src/slic3r/GUI/Search.hpp @@ -65,6 +65,8 @@ struct Option { std::wstring category_local; std::wstring tooltip; std::wstring tooltip_local; + std::wstring tooltip_lowercase; + std::wstring tooltip_local_lowercase; std::string opt_key() const; }; |