Bladeren bron

SystemMonitor: Add sorting key to the devices model

Tibor Nagy 4 jaren geleden
bovenliggende
commit
2c1b244889
1 gewijzigde bestanden met toevoegingen van 18 en 0 verwijderingen
  1. 18 0
      Applications/SystemMonitor/DevicesModel.cpp

+ 18 - 0
Applications/SystemMonitor/DevicesModel.cpp

@@ -93,6 +93,24 @@ GUI::Variant DevicesModel::data(const GUI::ModelIndex& index, GUI::ModelRole rol
         return {};
         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) {
     if (role == GUI::ModelRole::Display) {
         const DeviceInfo& device = m_devices[index.row()];
         const DeviceInfo& device = m_devices[index.row()];
         switch (index.column()) {
         switch (index.column()) {