1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09: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
Notes: sideshowbarker 2024-07-19 04:51:04 +09:00
13 changed files with 144 additions and 60 deletions

View file

@ -44,6 +44,13 @@ enum class SortOrder {
Descending
};
class ModelClient {
public:
virtual ~ModelClient() { }
virtual void on_model_update(unsigned flags) = 0;
};
class Model : public RefCounted<Model> {
public:
enum UpdateFlag {
@ -95,7 +102,8 @@ public:
void register_view(Badge<AbstractView>, AbstractView&);
void unregister_view(Badge<AbstractView>, AbstractView&);
Function<void()> on_update;
void register_client(ModelClient&);
void unregister_client(ModelClient&);
protected:
Model();
@ -107,6 +115,7 @@ protected:
private:
HashTable<AbstractView*> m_views;
HashTable<ModelClient*> m_clients;
};
inline ModelIndex ModelIndex::parent() const