From e1ed71ef9e50909f29dc4aa984e8544c7f7077c4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 16 Aug 2020 10:44:10 +0200 Subject: LibGUI: Make model sorting imperative and move order to AbstractView Instead of SortingProxyModel having a column+order, we move that state to AbstractView. When you click on a column header, the view tells the model to resort the relevant column with the new order. This is implemented in SortingProxyModel by simply walking all the reified source/proxy mappings and resorting their row indexes. --- Applications/FileManager/DirectoryView.cpp | 2 +- Applications/SystemMonitor/ProcessMemoryMapWidget.cpp | 2 +- Applications/SystemMonitor/main.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Applications') diff --git a/Applications/FileManager/DirectoryView.cpp b/Applications/FileManager/DirectoryView.cpp index a9350f6001..d9b0ff07a3 100644 --- a/Applications/FileManager/DirectoryView.cpp +++ b/Applications/FileManager/DirectoryView.cpp @@ -127,7 +127,7 @@ DirectoryView::DirectoryView() m_table_view = add(); m_table_view->set_model(m_sorting_model); - m_table_view->model()->set_key_column_and_sort_order(GUI::FileSystemModel::Column::Name, GUI::SortOrder::Ascending); + m_table_view->set_key_column_and_sort_order(GUI::FileSystemModel::Column::Name, GUI::SortOrder::Ascending); m_icon_view->set_model_column(GUI::FileSystemModel::Column::Name); m_columns_view->set_model_column(GUI::FileSystemModel::Column::Name); diff --git a/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp b/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp index 37043909ec..d0412954a5 100644 --- a/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp +++ b/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp @@ -120,7 +120,7 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget() m_table_view->set_cell_painting_delegate(7, make()); - m_table_view->model()->set_key_column_and_sort_order(0, GUI::SortOrder::Ascending); + m_table_view->set_key_column_and_sort_order(0, GUI::SortOrder::Ascending); m_timer = add(1000, [this] { refresh(); }); } diff --git a/Applications/SystemMonitor/main.cpp b/Applications/SystemMonitor/main.cpp index 916daf7c72..9f35c8f835 100644 --- a/Applications/SystemMonitor/main.cpp +++ b/Applications/SystemMonitor/main.cpp @@ -179,7 +179,7 @@ int main(int argc, char** argv) auto& process_table_view = process_table_container.add(); process_table_view.set_headers_visible(true); process_table_view.set_model(GUI::SortingProxyModel::create(ProcessModel::create())); - process_table_view.model()->set_key_column_and_sort_order(ProcessModel::Column::CPU, GUI::SortOrder::Descending); + process_table_view.set_key_column_and_sort_order(ProcessModel::Column::CPU, GUI::SortOrder::Descending); process_table_view.model()->update(); auto& refresh_timer = window->add( -- cgit v1.2.3