SystemMonitor: Wrap file descriptor and unveiled paths model into a SortingProxyModel

This commit is contained in:
Tibor Nagy 2020-09-22 00:40:57 +02:00 committed by Andreas Kling
parent f910cdcdb7
commit 3bd6142918
Notes: sideshowbarker 2024-07-19 02:16:49 +09:00
4 changed files with 11 additions and 4 deletions

View file

@ -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));
}

View file

@ -39,5 +39,6 @@ private:
ProcessFileDescriptorMapWidget();
RefPtr<GUI::TableView> m_table_view;
RefPtr<GUI::JsonArrayModel> m_model;
pid_t m_pid { -1 };
};

View file

@ -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));
}

View file

@ -39,5 +39,6 @@ private:
ProcessUnveiledPathsWidget();
RefPtr<GUI::TableView> m_table_view;
RefPtr<GUI::JsonArrayModel> m_model;
pid_t m_pid { -1 };
};