summaryrefslogtreecommitdiff
path: root/Userland/Applications/SystemMonitor/ProcessModel.cpp
diff options
context:
space:
mode:
authorDawid Wolosowicz <d@1823.pl>2021-09-03 21:30:45 +0200
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-09-08 15:48:02 +0430
commit000c74e6a8171e7d477b9226a1e3e5da2fd8a1c5 (patch)
tree1c18f08349ba68ee73d05c5ab0364299e47d62e5 /Userland/Applications/SystemMonitor/ProcessModel.cpp
parent52ed43d139379abed525783bd116b44f8c1edd66 (diff)
downloadserenity-000c74e6a8171e7d477b9226a1e3e5da2fd8a1c5.zip
SystemMonitor: Make the process list searchable
Diffstat (limited to 'Userland/Applications/SystemMonitor/ProcessModel.cpp')
-rw-r--r--Userland/Applications/SystemMonitor/ProcessModel.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/Userland/Applications/SystemMonitor/ProcessModel.cpp b/Userland/Applications/SystemMonitor/ProcessModel.cpp
index b421e94c02..cdefa57338 100644
--- a/Userland/Applications/SystemMonitor/ProcessModel.cpp
+++ b/Userland/Applications/SystemMonitor/ProcessModel.cpp
@@ -313,6 +313,24 @@ GUI::Variant ProcessModel::data(const GUI::ModelIndex& index, GUI::ModelRole rol
return {};
}
+Vector<GUI::ModelIndex, 1> ProcessModel::matches(const StringView& searching, unsigned flags, const GUI::ModelIndex&)
+{
+ Vector<GUI::ModelIndex, 1> found_indices;
+
+ for (auto& thread : m_threads) {
+ if (string_matches(thread.value->current_state.name, searching, flags)) {
+ auto maybe_tid_index = m_tids.find_first_index(thread.key);
+ if (!maybe_tid_index.has_value())
+ continue;
+ found_indices.append(create_index(maybe_tid_index.value(), Column::Name));
+ if (flags & FirstMatchOnly)
+ break;
+ }
+ }
+
+ return found_indices;
+}
+
void ProcessModel::update()
{
auto previous_tid_count = m_tids.size();