1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 17:35:08 +00:00

LibGUI: Add ModelClient abstract class and allow registering clients

This solves a problem where the SortingProxyModel doesn't
receive the on_update call because other code overwrote
the handler later on.
This commit is contained in:
Tom 2020-07-11 06:47:26 -06:00 committed by Andreas Kling
parent 0e10a92ebc
commit b778804d20
13 changed files with 144 additions and 60 deletions

View file

@ -30,7 +30,8 @@
namespace GUI {
class SortingProxyModel final : public Model {
class SortingProxyModel final : public Model
, private ModelClient {
public:
static NonnullRefPtr<SortingProxyModel> create(NonnullRefPtr<Model>&& model) { return adopt(*new SortingProxyModel(move(model))); }
virtual ~SortingProxyModel() override;
@ -55,10 +56,12 @@ public:
private:
explicit SortingProxyModel(NonnullRefPtr<Model>&&);
virtual void on_model_update(unsigned) override;
Model& target() { return *m_target; }
const Model& target() const { return *m_target; }
void resort();
void resort(unsigned flags = Model::UpdateFlag::DontInvalidateIndexes);
void set_sorting_case_sensitive(bool b) { m_sorting_case_sensitive = b; }
bool is_sorting_case_sensitive() { return m_sorting_case_sensitive; }
@ -69,6 +72,7 @@ private:
SortOrder m_sort_order { SortOrder::Ascending };
Role m_sort_role { Role::Sort };
bool m_sorting_case_sensitive { false };
bool m_sorting { false };
};
}