mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 11:54:57 +00:00
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>
This commit is contained in:
parent
5cd2e0f3a2
commit
ca2c81251a
100 changed files with 116 additions and 261 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue