diff options
author | Tibor Nagy <xnagytibor@gmail.com> | 2020-09-22 00:21:28 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-09-22 19:05:50 +0200 |
commit | e596b1da889ed1b90e959c8bfda630ccd07b58a3 (patch) | |
tree | b1c13fbd395c80fa4622859258cdd3bff589a247 | |
parent | 2c1b244889fbe7b2d489b77636948d426a45e935 (diff) | |
download | serenity-e596b1da889ed1b90e959c8bfda630ccd07b58a3.zip |
SystemMonitor: Wrap adapters and sockets model into a SortingProxyModel
-rw-r--r-- | Applications/SystemMonitor/NetworkStatisticsWidget.cpp | 7 | ||||
-rw-r--r-- | Applications/SystemMonitor/NetworkStatisticsWidget.h | 2 |
2 files changed, 7 insertions, 2 deletions
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 <LibGUI/BoxLayout.h> #include <LibGUI/GroupBox.h> #include <LibGUI/JsonArrayModel.h> +#include <LibGUI/SortingProxyModel.h> #include <LibGUI/TableView.h> 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<GUI::GroupBox>("Sockets"); sockets_group_box.set_layout<GUI::VerticalBoxLayout>(); @@ -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<Core::Timer>( 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<GUI::TableView> m_adapter_table_view; RefPtr<GUI::TableView> m_socket_table_view; + RefPtr<GUI::JsonArrayModel> m_adapter_model; + RefPtr<GUI::JsonArrayModel> m_socket_model; RefPtr<Core::Timer> m_update_timer; }; |