mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:07:35 +00:00
Browser: Add option to filter entries in Storage Inspector
This commit is contained in:
parent
d1e6dcfbc2
commit
6463bc7eb3
7 changed files with 87 additions and 11 deletions
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include "LocalStorageModel.h"
|
||||
|
||||
#include <AK/FuzzyMatch.h>
|
||||
|
||||
namespace Browser {
|
||||
|
||||
void LocalStorageModel::set_items(OrderedHashMap<String, String> map)
|
||||
|
@ -26,6 +28,13 @@ void LocalStorageModel::clear_items()
|
|||
did_update(DontInvalidateIndices);
|
||||
}
|
||||
|
||||
int LocalStorageModel::row_count(GUI::ModelIndex const& index) const
|
||||
{
|
||||
if (!index.is_valid())
|
||||
return m_local_storage_entries.size();
|
||||
return 0;
|
||||
}
|
||||
|
||||
String LocalStorageModel::column_name(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
|
@ -66,4 +75,20 @@ GUI::Variant LocalStorageModel::data(GUI::ModelIndex const& index, GUI::ModelRol
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
TriState LocalStorageModel::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& keys = m_local_storage_entries.keys();
|
||||
auto const& local_storage_key = keys[index.row()];
|
||||
auto const& local_storage_value = m_local_storage_entries.get(local_storage_key).value_or({});
|
||||
|
||||
auto haystack = String::formatted("{} {}", local_storage_key, local_storage_value);
|
||||
if (fuzzy_match(needle, haystack).score > 0)
|
||||
return TriState::True;
|
||||
return TriState::False;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue