diff options
author | sin-ack <sin-ack@users.noreply.github.com> | 2021-05-25 14:13:19 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-06 19:14:31 +0200 |
commit | ca2c81251a7d036f586f3d0a32bc35e2b9f93144 (patch) | |
tree | 130d63311e74c262c5cf685418ab701d7aa27165 /Userland/Libraries/LibGUI/SortingProxyModel.cpp | |
parent | 5cd2e0f3a26fb4e548c11056e6ec962392e50f15 (diff) | |
download | serenity-ca2c81251a7d036f586f3d0a32bc35e2b9f93144.zip |
Everywhere: Replace Model::update() with Model::invalidate()
Most of the models were just calling did_update anyway, which is
pointless since it can be unified to the base Model class. Instead, code
calling update() will now call invalidate(), which functions identically
and is more obvious in what it does.
Additionally, a default implementation is provided, which removes the
need to add empty implementations of update() for each model subclass.
Co-Authored-By: Ali Mohammad Pur <ali.mpfard@gmail.com>
Diffstat (limited to 'Userland/Libraries/LibGUI/SortingProxyModel.cpp')
-rw-r--r-- | Userland/Libraries/LibGUI/SortingProxyModel.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Userland/Libraries/LibGUI/SortingProxyModel.cpp b/Userland/Libraries/LibGUI/SortingProxyModel.cpp index 7ae72e907e..fd8a4dbb51 100644 --- a/Userland/Libraries/LibGUI/SortingProxyModel.cpp +++ b/Userland/Libraries/LibGUI/SortingProxyModel.cpp @@ -14,7 +14,7 @@ SortingProxyModel::SortingProxyModel(NonnullRefPtr<Model> source) : m_source(move(source)) { m_source->register_client(*this); - invalidate(); + update_sort(); } SortingProxyModel::~SortingProxyModel() @@ -22,7 +22,13 @@ SortingProxyModel::~SortingProxyModel() m_source->unregister_client(*this); } -void SortingProxyModel::invalidate(unsigned int flags) +void SortingProxyModel::invalidate() +{ + source().invalidate(); + Model::invalidate(); +} + +void SortingProxyModel::update_sort(unsigned flags) { if (flags == UpdateFlag::DontInvalidateIndices) { sort(m_last_key_column, m_last_sort_order); @@ -40,7 +46,7 @@ void SortingProxyModel::invalidate(unsigned int flags) void SortingProxyModel::model_did_update(unsigned flags) { - invalidate(flags); + update_sort(flags); } bool SortingProxyModel::accepts_drag(const ModelIndex& proxy_index, const Vector<String>& mime_types) const @@ -110,11 +116,6 @@ Variant SortingProxyModel::data(const ModelIndex& proxy_index, ModelRole role) c return source().data(map_to_source(proxy_index), role); } -void SortingProxyModel::update() -{ - source().update(); -} - StringView SortingProxyModel::drag_data_type() const { return source().drag_data_type(); |