mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 10:44:57 +00:00
SystemMonitor: Enable sorting by column in the process memory map view
This commit is contained in:
parent
7970b594d5
commit
b9f58a0e2e
2 changed files with 8 additions and 3 deletions
|
@ -2,6 +2,7 @@
|
|||
#include <LibCore/CTimer.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GJsonArrayModel.h>
|
||||
#include <LibGUI/GSortingProxyModel.h>
|
||||
#include <LibGUI/GTableView.h>
|
||||
|
||||
ProcessMemoryMapWidget::ProcessMemoryMapWidget(GWidget* parent)
|
||||
|
@ -30,7 +31,9 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget(GWidget* parent)
|
|||
return builder.to_string();
|
||||
});
|
||||
pid_vm_fields.empend("name", "Name", TextAlignment::CenterLeft);
|
||||
m_table_view->set_model(GJsonArrayModel::create({}, move(pid_vm_fields)));
|
||||
m_json_model = GJsonArrayModel::create({}, move(pid_vm_fields));
|
||||
m_table_view->set_model(GSortingProxyModel::create(*m_json_model));
|
||||
m_table_view->model()->set_key_column_and_sort_order(0, GSortOrder::Ascending);
|
||||
m_timer = CTimer::construct(1000, [this] { refresh(); }, this);
|
||||
}
|
||||
|
||||
|
@ -43,11 +46,11 @@ void ProcessMemoryMapWidget::set_pid(pid_t pid)
|
|||
if (m_pid == pid)
|
||||
return;
|
||||
m_pid = pid;
|
||||
static_cast<GJsonArrayModel*>(m_table_view->model())->set_json_path(String::format("/proc/%d/vm", pid));
|
||||
m_json_model->set_json_path(String::format("/proc/%d/vm", pid));
|
||||
}
|
||||
|
||||
void ProcessMemoryMapWidget::refresh()
|
||||
{
|
||||
if (m_pid != -1)
|
||||
m_table_view->model()->update();
|
||||
m_json_model->update();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue