diff --git a/Userland/DevTools/Profiler/ProfileModel.cpp b/Userland/DevTools/Profiler/ProfileModel.cpp index 3a1c0626f2..abf984867f 100644 --- a/Userland/DevTools/Profiler/ProfileModel.cpp +++ b/Userland/DevTools/Profiler/ProfileModel.cpp @@ -145,4 +145,29 @@ GUI::Variant ProfileModel::data(const GUI::ModelIndex& index, GUI::ModelRole rol return {}; } +Vector ProfileModel::matches(StringView const& searching, unsigned flags, GUI::ModelIndex const& parent) +{ + RemoveReference* nodes { nullptr }; + + if (!parent.is_valid()) + nodes = &m_profile.roots(); + else + nodes = &static_cast(parent.internal_data())->children(); + + if (!nodes) + return {}; + + Vector found_indices; + for (auto it = nodes->begin(); !it.is_end(); ++it) { + GUI::ModelIndex index = this->index(it.index(), StackFrame, 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; +} + } diff --git a/Userland/DevTools/Profiler/ProfileModel.h b/Userland/DevTools/Profiler/ProfileModel.h index 46f8fc6131..53cdabbe4a 100644 --- a/Userland/DevTools/Profiler/ProfileModel.h +++ b/Userland/DevTools/Profiler/ProfileModel.h @@ -38,6 +38,8 @@ public: virtual GUI::ModelIndex parent_index(const GUI::ModelIndex&) const override; virtual int tree_column() const override { return Column::StackFrame; } virtual bool is_column_sortable(int) const override { return false; } + virtual bool is_searchable() const override { return true; } + virtual Vector matches(StringView const&, unsigned flags, GUI::ModelIndex const&) override; private: explicit ProfileModel(Profile&);