diff options
Diffstat (limited to 'Applications/SystemMonitor')
-rw-r--r-- | Applications/SystemMonitor/ProcessMemoryMapWidget.cpp | 9 | ||||
-rw-r--r-- | Applications/SystemMonitor/ProcessMemoryMapWidget.h | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp b/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp index 8b592a5999..8b28c21c0b 100644 --- a/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp +++ b/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp @@ -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(); } diff --git a/Applications/SystemMonitor/ProcessMemoryMapWidget.h b/Applications/SystemMonitor/ProcessMemoryMapWidget.h index 8d4081635b..aebf7f15af 100644 --- a/Applications/SystemMonitor/ProcessMemoryMapWidget.h +++ b/Applications/SystemMonitor/ProcessMemoryMapWidget.h @@ -3,6 +3,7 @@ #include <LibGUI/GWidget.h> class CTimer; +class GJsonArrayModel; class GTableView; class ProcessMemoryMapWidget final : public GWidget { @@ -16,6 +17,7 @@ public: private: explicit ProcessMemoryMapWidget(GWidget* parent); RefPtr<GTableView> m_table_view; + RefPtr<GJsonArrayModel> m_json_model; pid_t m_pid { -1 }; RefPtr<CTimer> m_timer; }; |