mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:08:10 +00:00
LibGUI: Reverse FilteringProxyModel update propagation flow
FilteringProxyModel is a narrowing projection of its parent model with a filter applied. That means that updates of FilteringProxyModel should not propagate to its parent model, but the opposite - updates happening in the parent model should "trickle down" and trigger an update of the filtering model.
This commit is contained in:
parent
781bc67a96
commit
2189cc6bf1
2 changed files with 10 additions and 3 deletions
|
@ -46,7 +46,6 @@ Variant FilteringProxyModel::data(ModelIndex const& index, ModelRole role) const
|
|||
|
||||
void FilteringProxyModel::invalidate()
|
||||
{
|
||||
m_model.invalidate();
|
||||
filter();
|
||||
did_update();
|
||||
}
|
||||
|
|
|
@ -14,14 +14,18 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
class FilteringProxyModel final : public Model {
|
||||
class FilteringProxyModel final : public Model
|
||||
, public ModelClient {
|
||||
public:
|
||||
static NonnullRefPtr<FilteringProxyModel> construct(Model& model)
|
||||
{
|
||||
return adopt_ref(*new FilteringProxyModel(model));
|
||||
}
|
||||
|
||||
virtual ~FilteringProxyModel() override {};
|
||||
virtual ~FilteringProxyModel() override
|
||||
{
|
||||
m_model.unregister_client(*this);
|
||||
};
|
||||
|
||||
virtual int row_count(ModelIndex const& = ModelIndex()) const override;
|
||||
virtual int column_count(ModelIndex const& = ModelIndex()) const override;
|
||||
|
@ -35,11 +39,15 @@ public:
|
|||
|
||||
ModelIndex map(ModelIndex const&) const;
|
||||
|
||||
protected:
|
||||
virtual void model_did_update([[maybe_unused]] unsigned flags) override { invalidate(); }
|
||||
|
||||
private:
|
||||
void filter();
|
||||
explicit FilteringProxyModel(Model& model)
|
||||
: m_model(model)
|
||||
{
|
||||
m_model.register_client(*this);
|
||||
}
|
||||
|
||||
Model& m_model;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue