From e596b1da889ed1b90e959c8bfda630ccd07b58a3 Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Tue, 22 Sep 2020 00:21:28 +0200 Subject: SystemMonitor: Wrap adapters and sockets model into a SortingProxyModel --- Applications/SystemMonitor/NetworkStatisticsWidget.cpp | 7 +++++-- Applications/SystemMonitor/NetworkStatisticsWidget.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'Applications') diff --git a/Applications/SystemMonitor/NetworkStatisticsWidget.cpp b/Applications/SystemMonitor/NetworkStatisticsWidget.cpp index 0908239e81..74dd18aec7 100644 --- a/Applications/SystemMonitor/NetworkStatisticsWidget.cpp +++ b/Applications/SystemMonitor/NetworkStatisticsWidget.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include NetworkStatisticsWidget::NetworkStatisticsWidget() @@ -54,7 +55,8 @@ NetworkStatisticsWidget::NetworkStatisticsWidget() net_adapters_fields.empend("packets_out", "Pkt Out", Gfx::TextAlignment::CenterRight); net_adapters_fields.empend("bytes_in", "Bytes In", Gfx::TextAlignment::CenterRight); net_adapters_fields.empend("bytes_out", "Bytes Out", Gfx::TextAlignment::CenterRight); - m_adapter_table_view->set_model(GUI::JsonArrayModel::create("/proc/net/adapters", move(net_adapters_fields))); + m_adapter_model = GUI::JsonArrayModel::create("/proc/net/adapters", move(net_adapters_fields)); + m_adapter_table_view->set_model(GUI::SortingProxyModel::create(*m_adapter_model)); auto& sockets_group_box = add("Sockets"); sockets_group_box.set_layout(); @@ -76,7 +78,8 @@ NetworkStatisticsWidget::NetworkStatisticsWidget() net_tcp_fields.empend("packets_out", "Pkt Out", Gfx::TextAlignment::CenterRight); net_tcp_fields.empend("bytes_in", "Bytes In", Gfx::TextAlignment::CenterRight); net_tcp_fields.empend("bytes_out", "Bytes Out", Gfx::TextAlignment::CenterRight); - m_socket_table_view->set_model(GUI::JsonArrayModel::create("/proc/net/tcp", move(net_tcp_fields))); + m_socket_model = GUI::JsonArrayModel::create("/proc/net/tcp", move(net_tcp_fields)); + m_socket_table_view->set_model(GUI::SortingProxyModel::create(*m_socket_model)); m_update_timer = add( 1000, [this] { diff --git a/Applications/SystemMonitor/NetworkStatisticsWidget.h b/Applications/SystemMonitor/NetworkStatisticsWidget.h index 554bd255f0..d49a9641c8 100644 --- a/Applications/SystemMonitor/NetworkStatisticsWidget.h +++ b/Applications/SystemMonitor/NetworkStatisticsWidget.h @@ -40,5 +40,7 @@ private: RefPtr m_adapter_table_view; RefPtr m_socket_table_view; + RefPtr m_adapter_model; + RefPtr m_socket_model; RefPtr m_update_timer; }; -- cgit v1.2.3