diff options
author | Tibor Nagy <xnagytibor@gmail.com> | 2020-09-22 00:40:57 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-09-22 19:05:50 +0200 |
commit | 3bd61429188bd1ee59233f2e3c51415b2b1e4172 (patch) | |
tree | 8b16c56a3f2925d927742612605a9f1953cb0338 | |
parent | f910cdcdb7cf7a197d9fa9521d72a9c28dfd7add (diff) | |
download | serenity-3bd61429188bd1ee59233f2e3c51415b2b1e4172.zip |
SystemMonitor: Wrap file descriptor and unveiled paths model into a SortingProxyModel
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 <LibGUI/BoxLayout.h> #include <LibGUI/JsonArrayModel.h> +#include <LibGUI/SortingProxyModel.h> #include <LibGUI/TableView.h> 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<GUI::JsonArrayModel*>(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<GUI::TableView> m_table_view; + RefPtr<GUI::JsonArrayModel> 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 <LibGUI/BoxLayout.h> #include <LibGUI/JsonArrayModel.h> +#include <LibGUI/SortingProxyModel.h> #include <LibGUI/TableView.h> ProcessUnveiledPathsWidget::ProcessUnveiledPathsWidget() @@ -38,7 +39,9 @@ ProcessUnveiledPathsWidget::ProcessUnveiledPathsWidget() Vector<GUI::JsonArrayModel::FieldSpec> 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<GUI::JsonArrayModel*>(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<GUI::TableView> m_table_view; + RefPtr<GUI::JsonArrayModel> m_model; pid_t m_pid { -1 }; }; |