forked from mia/Aegisub
Remove the use of wxRegex for case-insensitive filtering
This commit is contained in:
parent
17170fc5fe
commit
4e7d6df6b2
2 changed files with 9 additions and 17 deletions
|
@ -142,7 +142,6 @@
|
||||||
#include <wx/radiobut.h>
|
#include <wx/radiobut.h>
|
||||||
#include <wx/rawbmp.h>
|
#include <wx/rawbmp.h>
|
||||||
#include <wx/recguard.h>
|
#include <wx/recguard.h>
|
||||||
#include <wx/regex.h>
|
|
||||||
#include <wx/sashwin.h>
|
#include <wx/sashwin.h>
|
||||||
#include <wx/scrolbar.h>
|
#include <wx/scrolbar.h>
|
||||||
#include <wx/settings.h>
|
#include <wx/settings.h>
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
|
|
||||||
#include <wx/dataview.h>
|
#include <wx/dataview.h>
|
||||||
#include <wx/regex.h>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
@ -75,8 +74,8 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsVisible(wxRegEx const& filter) const {
|
bool IsVisible(wxString const& filter) const {
|
||||||
return filter.Matches(cmd_name) || filter.Matches(cmd_str);
|
return cmd_name.Lower().Contains(filter) || cmd_str.Contains(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Apply(Hotkey::HotkeyMap *hk_map) {
|
void Apply(Hotkey::HotkeyMap *hk_map) {
|
||||||
|
@ -166,7 +165,7 @@ public:
|
||||||
combo.Apply(hk_map);
|
combo.Apply(hk_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetFilter(wxRegEx const& new_filter) {
|
void SetFilter(wxString const& new_filter) {
|
||||||
std::set<HotkeyModelCombo*> old_visible;
|
std::set<HotkeyModelCombo*> old_visible;
|
||||||
for (auto item : visible_items)
|
for (auto item : visible_items)
|
||||||
old_visible.insert(static_cast<HotkeyModelCombo*>(item.GetID()));
|
old_visible.insert(static_cast<HotkeyModelCombo*>(item.GetID()));
|
||||||
|
@ -235,19 +234,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void Apply(Hotkey::HotkeyMap *hk_map) {
|
void Apply(Hotkey::HotkeyMap *hk_map) {
|
||||||
for_each(categories.begin(), categories.end(),
|
for (auto& category : categories)
|
||||||
bind(&HotkeyModelCategory::Apply, std::placeholders::_1, hk_map));
|
category.Apply(hk_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetFilter(wxString filter) {
|
void SetFilter(wxString const& filter) {
|
||||||
// Escape any regular-expression special characters
|
for (auto& category : categories)
|
||||||
static wxRegEx escape_meta("[-[\\]{}()*+?.,\\\\^$|#]", wxRE_ADVANCED);
|
category.SetFilter(filter);
|
||||||
escape_meta.Replace(&filter, "\\\\&");
|
|
||||||
|
|
||||||
// Using wxRegEx for case-insensitive contains
|
|
||||||
wxRegEx re(filter, wxRE_ADVANCED | wxRE_ICASE | wxRE_NOSUB);
|
|
||||||
for_each(categories.begin(), categories.end(),
|
|
||||||
bind(&HotkeyModelCategory::SetFilter, std::placeholders::_1, std::ref(re)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataViewItem GetParent() const { return wxDataViewItem(0); }
|
wxDataViewItem GetParent() const { return wxDataViewItem(0); }
|
||||||
|
@ -338,5 +331,5 @@ void HotkeyDataViewModel::Apply() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HotkeyDataViewModel::SetFilter(wxString const& filter) {
|
void HotkeyDataViewModel::SetFilter(wxString const& filter) {
|
||||||
root->SetFilter(filter);
|
root->SetFilter(filter.Lower());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue