From 3bd61429188bd1ee59233f2e3c51415b2b1e4172 Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Tue, 22 Sep 2020 00:40:57 +0200 Subject: SystemMonitor: Wrap file descriptor and unveiled paths model into a SortingProxyModel --- Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp | 6 ++++-- Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h | 1 + Applications/SystemMonitor/ProcessUnveiledPathsWidget.cpp | 7 +++++-- Applications/SystemMonitor/ProcessUnveiledPathsWidget.h | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp b/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp index 9e8505f5dc..da3868dda2 100644 --- a/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp +++ b/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp @@ -27,6 +27,7 @@ #include "ProcessFileDescriptorMapWidget.h" #include #include +#include #include ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget() @@ -56,7 +57,8 @@ ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget() return object.get("can_write").to_bool() ? "Yes" : "No"; }); - m_table_view->set_model(GUI::JsonArrayModel::create({}, move(pid_fds_fields))); + m_model = GUI::JsonArrayModel::create({}, move(pid_fds_fields)); + m_table_view->set_model(GUI::SortingProxyModel::create(*m_model)); } ProcessFileDescriptorMapWidget::~ProcessFileDescriptorMapWidget() @@ -68,5 +70,5 @@ void ProcessFileDescriptorMapWidget::set_pid(pid_t pid) if (m_pid == pid) return; m_pid = pid; - static_cast(m_table_view->model())->set_json_path(String::format("/proc/%d/fds", m_pid)); + m_model->set_json_path(String::format("/proc/%d/fds", m_pid)); } diff --git a/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h b/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h index a03bf7d1cf..97e68b6bd1 100644 --- a/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h +++ b/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h @@ -39,5 +39,6 @@ private: ProcessFileDescriptorMapWidget(); RefPtr m_table_view; + RefPtr m_model; pid_t m_pid { -1 }; }; diff --git a/Applications/SystemMonitor/ProcessUnveiledPathsWidget.cpp b/Applications/SystemMonitor/ProcessUnveiledPathsWidget.cpp index 4121057fef..98fd77e72d 100644 --- a/Applications/SystemMonitor/ProcessUnveiledPathsWidget.cpp +++ b/Applications/SystemMonitor/ProcessUnveiledPathsWidget.cpp @@ -27,6 +27,7 @@ #include "ProcessUnveiledPathsWidget.h" #include #include +#include #include ProcessUnveiledPathsWidget::ProcessUnveiledPathsWidget() @@ -38,7 +39,9 @@ ProcessUnveiledPathsWidget::ProcessUnveiledPathsWidget() Vector pid_unveil_fields; pid_unveil_fields.empend("path", "Path", Gfx::TextAlignment::CenterLeft); pid_unveil_fields.empend("permissions", "Permissions", Gfx::TextAlignment::CenterLeft); - m_table_view->set_model(GUI::JsonArrayModel::create({}, move(pid_unveil_fields))); + + m_model = GUI::JsonArrayModel::create({}, move(pid_unveil_fields)); + m_table_view->set_model(GUI::SortingProxyModel::create(*m_model)); } ProcessUnveiledPathsWidget::~ProcessUnveiledPathsWidget() @@ -50,5 +53,5 @@ void ProcessUnveiledPathsWidget::set_pid(pid_t pid) if (m_pid == pid) return; m_pid = pid; - static_cast(m_table_view->model())->set_json_path(String::format("/proc/%d/unveil", m_pid)); + m_model->set_json_path(String::format("/proc/%d/unveil", m_pid)); } diff --git a/Applications/SystemMonitor/ProcessUnveiledPathsWidget.h b/Applications/SystemMonitor/ProcessUnveiledPathsWidget.h index 99eb84055a..d930c90bf7 100644 --- a/Applications/SystemMonitor/ProcessUnveiledPathsWidget.h +++ b/Applications/SystemMonitor/ProcessUnveiledPathsWidget.h @@ -39,5 +39,6 @@ private: ProcessUnveiledPathsWidget(); RefPtr m_table_view; + RefPtr m_model; pid_t m_pid { -1 }; }; -- cgit v1.2.3