Browser: Allow jumping to stylenames by typing in the inspector

This adds the default behavior of search and highlighting of
abstractView to the inspectorWidget. Search results are based on
the titles in the first columns.
This commit is contained in:
Vrins 2022-02-17 18:20:20 +01:00 committed by Andreas Kling
commit 044be82567
Notes: sideshowbarker 2024-07-17 17:21:13 +09:00
3 changed files with 22 additions and 0 deletions

View file

@ -56,4 +56,21 @@ GUI::Variant StylePropertiesModel::data(GUI::ModelIndex const& index, GUI::Model
return {};
}
Vector<GUI::ModelIndex> StylePropertiesModel::matches(StringView searching, unsigned flags, GUI::ModelIndex const& parent)
{
if (m_values.is_empty())
return {};
Vector<GUI::ModelIndex> found_indices;
for (auto it = m_values.begin(); !it.is_end(); ++it) {
GUI::ModelIndex index = this->index(it.index(), Column::PropertyName, parent);
if (!string_matches(data(index, GUI::ModelRole::Display).as_string(), searching, flags))
continue;
found_indices.append(index);
if (flags & FirstMatchOnly)
break;
}
return found_indices;
}
}