mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 14:42:44 +00:00 
			
		
		
		
	Profiler: Use SortingProxyModel::set_sort_role()
Use the new API to avoid duplicating code in the RunningProcessesModel.
This commit is contained in:
		
							parent
							
								
									b85a57ead7
								
							
						
					
					
						commit
						14edd67bcc
					
				
					 2 changed files with 4 additions and 17 deletions
				
			
		|  | @ -52,8 +52,10 @@ void ProcessChooser::build() | ||||||
|     widget.set_fill_with_background_color(true); |     widget.set_fill_with_background_color(true); | ||||||
|     widget.set_layout<GUI::VerticalBoxLayout>(); |     widget.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     auto& table_view = widget.add<GUI::TableView>(); |     auto& table_view = widget.add<GUI::TableView>(); | ||||||
|     table_view.set_model(GUI::SortingProxyModel::create(Profiler::RunningProcessesModel::create())); |     auto sorting_model = GUI::SortingProxyModel::create(Profiler::RunningProcessesModel::create()); | ||||||
|     table_view.model()->set_key_column_and_sort_order(Profiler::RunningProcessesModel::Column::PID, GUI::SortOrder::Descending); |     sorting_model->set_sort_role(GUI::Model::Role::Display); | ||||||
|  |     sorting_model->set_key_column_and_sort_order(Profiler::RunningProcessesModel::Column::PID, GUI::SortOrder::Descending); | ||||||
|  |     table_view.set_model(sorting_model); | ||||||
|     auto& button_container = widget.add<GUI::Widget>(); |     auto& button_container = widget.add<GUI::Widget>(); | ||||||
|     button_container.set_preferred_size(0, 30); |     button_container.set_preferred_size(0, 30); | ||||||
|     button_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     button_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); | ||||||
|  |  | ||||||
|  | @ -115,21 +115,6 @@ GUI::Variant RunningProcessesModel::data(const GUI::ModelIndex& index, Role role | ||||||
|         } |         } | ||||||
|         ASSERT_NOT_REACHED(); |         ASSERT_NOT_REACHED(); | ||||||
|     } |     } | ||||||
| 
 |  | ||||||
|     if (role == Role::Sort) { |  | ||||||
|         switch (index.column()) { |  | ||||||
|         case Column::Icon: |  | ||||||
|             return {}; |  | ||||||
|         case Column::PID: |  | ||||||
|             return process.pid; |  | ||||||
|         case Column::UID: |  | ||||||
|             return process.uid; |  | ||||||
|         case Column::Name: |  | ||||||
|             return process.name; |  | ||||||
|         } |  | ||||||
|         ASSERT_NOT_REACHED(); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     return {}; |     return {}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling