mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 11:45:06 +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:
parent
0e10a92ebc
commit
b778804d20
13 changed files with 144 additions and 60 deletions
|
@ -55,8 +55,9 @@ void Model::for_each_view(Function<void(AbstractView&)> callback)
|
|||
|
||||
void Model::did_update(unsigned flags)
|
||||
{
|
||||
if (on_update)
|
||||
on_update();
|
||||
for (auto* client : m_clients)
|
||||
client->on_model_update(flags);
|
||||
|
||||
for_each_view([&](auto& view) {
|
||||
view.did_update_model(flags);
|
||||
});
|
||||
|
@ -82,4 +83,14 @@ bool Model::accepts_drag(const ModelIndex&, const StringView&)
|
|||
return false;
|
||||
}
|
||||
|
||||
void Model::register_client(ModelClient& client)
|
||||
{
|
||||
m_clients.set(&client);
|
||||
}
|
||||
|
||||
void Model::unregister_client(ModelClient& client)
|
||||
{
|
||||
m_clients.remove(&client);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue