From 2c1b244889fbe7b2d489b77636948d426a45e935 Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Tue, 22 Sep 2020 00:20:35 +0200 Subject: [PATCH] SystemMonitor: Add sorting key to the devices model --- Applications/SystemMonitor/DevicesModel.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Applications/SystemMonitor/DevicesModel.cpp b/Applications/SystemMonitor/DevicesModel.cpp index 7ab4dddca1..6957c666b8 100644 --- a/Applications/SystemMonitor/DevicesModel.cpp +++ b/Applications/SystemMonitor/DevicesModel.cpp @@ -93,6 +93,24 @@ GUI::Variant DevicesModel::data(const GUI::ModelIndex& index, GUI::ModelRole rol return {}; } + if (role == GUI::ModelRole::Sort) { + const DeviceInfo& device = m_devices[index.row()]; + switch (index.column()) { + case Column::Device: + return device.path; + case Column::Major: + return device.major; + case Column::Minor: + return device.minor; + case Column::ClassName: + return device.class_name; + case Column::Type: + return device.type; + default: + ASSERT_NOT_REACHED(); + } + } + if (role == GUI::ModelRole::Display) { const DeviceInfo& device = m_devices[index.row()]; switch (index.column()) {