1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:34:59 +00:00

Browser: Add option to filter entries in Storage Inspector

This commit is contained in:
Rafał Babiarz 2022-05-06 20:30:39 +02:00 committed by Linus Groh
parent d1e6dcfbc2
commit 6463bc7eb3
7 changed files with 87 additions and 11 deletions

View file

@ -5,6 +5,7 @@
*/
#include "CookiesModel.h"
#include <AK/FuzzyMatch.h>
namespace Browser {
@ -26,6 +27,13 @@ void CookiesModel::clear_items()
did_update(DontInvalidateIndices);
}
int CookiesModel::row_count(GUI::ModelIndex const& index) const
{
if (!index.is_valid())
return m_cookies.size();
return 0;
}
String CookiesModel::column_name(int column) const
{
switch (column) {
@ -76,4 +84,17 @@ GUI::Variant CookiesModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol
VERIFY_NOT_REACHED();
}
TriState CookiesModel::data_matches(GUI::ModelIndex const& index, GUI::Variant const& term) const
{
auto needle = term.as_string();
if (needle.is_empty())
return TriState::True;
auto const& cookie = m_cookies[index.row()];
auto haystack = String::formatted("{} {} {} {}", cookie.domain, cookie.path, cookie.name, cookie.value);
if (fuzzy_match(needle, haystack).score > 0)
return TriState::True;
return TriState::False;
}
}