SystemMonitor: Wrap adapters and sockets model into a SortingProxyModel

This commit is contained in:
Tibor Nagy 2020-09-22 00:21:28 +02:00 committed by Andreas Kling
parent 2c1b244889
commit e596b1da88
2 changed files with 7 additions and 2 deletions

View file

@ -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] {

View file

@ -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;
};