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:
parent
0e10a92ebc
commit
b778804d20
Notes:
sideshowbarker
2024-07-19 04:51:04 +09:00
Author: https://github.com/tomuta
Commit: b778804d20
Pull-request: https://github.com/SerenityOS/serenity/pull/2761
Reviewed-by: https://github.com/Dexesttp
13 changed files with 144 additions and 60 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue