Added fts_fuzzy_match.h borrowed from https://github.com/forrestthewoods/lib_fts

Search impoved using lib_fts
Function for filtering by score is prepared.
This commit is contained in:
YuSanka 2020-03-25 10:24:43 +01:00
parent ebfaf7abb0
commit 1010fff8af
4 changed files with 283 additions and 26 deletions

View file

@ -29,19 +29,36 @@ public:
bool operator<(const Option& other) const { return other.label > this->label; }
bool operator>(const Option& other) const { return other.label < this->label; }
std::string opt_key;
wxString label;
std::string opt_key;
wxString category;
Preset::Type type {Preset::TYPE_INVALID};
// wxString grope;
bool containes(const wxString& search) const;
bool is_matched_option(const wxString &search, int &outScore);
};
std::vector<Option> options {};
std::set<Option> options {};
struct Filter {
wxString label;
int outScore {0};
};
std::vector<Filter> filters {};
void clear() { options. clear(); }
void clear_options() { options.clear(); }
void clear_filters() { filters.clear(); }
void append_options(DynamicPrintConfig* config, Preset::Type type, ConfigOptionMode mode);
void apply_filters(const wxString& search);
void sort_options() {
std::sort(options.begin(), options.end(), [](const Option& o1, const Option& o2) {
return o1.label < o2.label; });
}
void sort_filters() {
std::sort(filters.begin(), filters.end(), [](const Filter& f1, const Filter& f2) {
return f1.outScore > f2.outScore; });
};
};
class SearchComboBox : public wxBitmapComboBox