1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

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.
This commit is contained in:
Andreas Kling 2020-08-16 10:44:10 +02:00
parent 370624bc37
commit e1ed71ef9e
15 changed files with 85 additions and 55 deletions

View file

@ -87,6 +87,7 @@ public:
virtual bool accepts_drag(const ModelIndex&, const StringView& data_type);
virtual bool is_column_sortable([[maybe_unused]] int column_index) const { return true; }
virtual void sort([[maybe_unused]] int column, SortOrder) { }
bool is_valid(const ModelIndex& index) const
{
@ -94,10 +95,6 @@ public:
return index.row() >= 0 && index.row() < row_count(parent_index) && index.column() >= 0 && index.column() < column_count(parent_index);
}
virtual int key_column() const { return -1; }
virtual SortOrder sort_order() const { return SortOrder::None; }
virtual void set_key_column_and_sort_order(int, SortOrder) { }
virtual StringView drag_data_type() const { return {}; }
void register_view(Badge<AbstractView>, AbstractView&);