mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +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 <LibCore/CTimer.h>
|
||||||
#include <LibGUI/GBoxLayout.h>
|
#include <LibGUI/GBoxLayout.h>
|
||||||
#include <LibGUI/GJsonArrayModel.h>
|
#include <LibGUI/GJsonArrayModel.h>
|
||||||
|
#include <LibGUI/GSortingProxyModel.h>
|
||||||
#include <LibGUI/GTableView.h>
|
#include <LibGUI/GTableView.h>
|
||||||
|
|
||||||
ProcessMemoryMapWidget::ProcessMemoryMapWidget(GWidget* parent)
|
ProcessMemoryMapWidget::ProcessMemoryMapWidget(GWidget* parent)
|
||||||
|
@ -30,7 +31,9 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget(GWidget* parent)
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
});
|
});
|
||||||
pid_vm_fields.empend("name", "Name", TextAlignment::CenterLeft);
|
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);
|
m_timer = CTimer::construct(1000, [this] { refresh(); }, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,11 +46,11 @@ void ProcessMemoryMapWidget::set_pid(pid_t pid)
|
||||||
if (m_pid == pid)
|
if (m_pid == pid)
|
||||||
return;
|
return;
|
||||||
m_pid = pid;
|
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()
|
void ProcessMemoryMapWidget::refresh()
|
||||||
{
|
{
|
||||||
if (m_pid != -1)
|
if (m_pid != -1)
|
||||||
m_table_view->model()->update();
|
m_json_model->update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <LibGUI/GWidget.h>
|
#include <LibGUI/GWidget.h>
|
||||||
|
|
||||||
class CTimer;
|
class CTimer;
|
||||||
|
class GJsonArrayModel;
|
||||||
class GTableView;
|
class GTableView;
|
||||||
|
|
||||||
class ProcessMemoryMapWidget final : public GWidget {
|
class ProcessMemoryMapWidget final : public GWidget {
|
||||||
|
@ -16,6 +17,7 @@ public:
|
||||||
private:
|
private:
|
||||||
explicit ProcessMemoryMapWidget(GWidget* parent);
|
explicit ProcessMemoryMapWidget(GWidget* parent);
|
||||||
RefPtr<GTableView> m_table_view;
|
RefPtr<GTableView> m_table_view;
|
||||||
|
RefPtr<GJsonArrayModel> m_json_model;
|
||||||
pid_t m_pid { -1 };
|
pid_t m_pid { -1 };
|
||||||
RefPtr<CTimer> m_timer;
|
RefPtr<CTimer> m_timer;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue