diff options
author | speles <speles@mail.ua> | 2021-02-28 20:50:52 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-01 11:16:18 +0100 |
commit | aa9c5d4418d2ffbb1efba6293c9ea961a3ab0592 (patch) | |
tree | f80d969a079e524ff5d60d343df5f559b34484ea /Userland/Libraries/LibGUI | |
parent | dff31d5885cc9c6d2c9c162fef67adda00d055ff (diff) | |
download | serenity-aa9c5d4418d2ffbb1efba6293c9ea961a3ab0592.zip |
LibGUI: Add possibility to search for exact match in model
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r-- | Userland/Libraries/LibGUI/Model.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/Model.h b/Userland/Libraries/LibGUI/Model.h index 5d8c5057b0..1603d766df 100644 --- a/Userland/Libraries/LibGUI/Model.h +++ b/Userland/Libraries/LibGUI/Model.h @@ -66,6 +66,7 @@ public: FirstMatchOnly = 1 << 0, CaseInsensitive = 1 << 1, MatchAtStart = 1 << 2, + MatchFull = 1 << 3, }; virtual ~Model(); @@ -112,6 +113,8 @@ protected: static bool string_matches(const StringView& str, const StringView& needle, unsigned flags) { auto case_sensitivity = (flags & CaseInsensitive) ? CaseSensitivity::CaseInsensitive : CaseSensitivity::CaseSensitive; + if (flags & MatchFull) + return str.length() == needle.length() && str.starts_with(needle, case_sensitivity); if (flags & MatchAtStart) return str.starts_with(needle, case_sensitivity); return str.contains(needle, case_sensitivity); |