mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:24:57 +00:00
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:
parent
e5e621a63f
commit
044be82567
3 changed files with 22 additions and 0 deletions
|
@ -162,12 +162,15 @@ void InspectorWidget::load_style_json(String specified_values_json, String compu
|
|||
{
|
||||
m_selection_specified_values_json = specified_values_json;
|
||||
m_style_table_view->set_model(Web::StylePropertiesModel::create(m_selection_specified_values_json.value().view()));
|
||||
m_style_table_view->set_searchable(true);
|
||||
|
||||
m_selection_computed_values_json = computed_values_json;
|
||||
m_computed_style_table_view->set_model(Web::StylePropertiesModel::create(m_selection_computed_values_json.value().view()));
|
||||
m_computed_style_table_view->set_searchable(true);
|
||||
|
||||
m_selection_custom_properties_json = custom_properties_json;
|
||||
m_custom_properties_table_view->set_model(Web::StylePropertiesModel::create(m_selection_custom_properties_json.value().view()));
|
||||
m_custom_properties_table_view->set_searchable(true);
|
||||
}
|
||||
|
||||
void InspectorWidget::update_node_box_model(Optional<String> node_box_sizing_json)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ public:
|
|||
virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return Column::__Count; }
|
||||
virtual String column_name(int) const override;
|
||||
virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override;
|
||||
virtual bool is_searchable() const override { return true; }
|
||||
virtual Vector<GUI::ModelIndex> matches(StringView, unsigned flags, GUI::ModelIndex const&) override;
|
||||
|
||||
private:
|
||||
explicit StylePropertiesModel(JsonObject);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue