mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +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
|
@ -26,7 +26,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/HashTable.h>
|
||||
#include <AK/TemporaryChange.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGUI/ModelIndex.h>
|
||||
|
||||
|
@ -91,9 +93,25 @@ public:
|
|||
|
||||
void remove_matching(Function<bool(const ModelIndex&)>);
|
||||
|
||||
template<typename Function>
|
||||
void change_from_model(Badge<SortingProxyModel>, Function f)
|
||||
{
|
||||
{
|
||||
TemporaryChange change(m_disable_notify, true);
|
||||
m_notify_pending = false;
|
||||
f(*this);
|
||||
}
|
||||
if (m_notify_pending)
|
||||
notify_selection_changed();
|
||||
}
|
||||
|
||||
private:
|
||||
void notify_selection_changed();
|
||||
|
||||
AbstractView& m_view;
|
||||
HashTable<ModelIndex> m_indexes;
|
||||
bool m_disable_notify { false };
|
||||
bool m_notify_pending { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue