1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 17:45:07 +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:
sin-ack 2021-05-25 14:13:19 +00:00 committed by Andreas Kling
parent 5cd2e0f3a2
commit ca2c81251a
100 changed files with 116 additions and 261 deletions

View file

@ -286,7 +286,7 @@ FileSystemModel::FileSystemModel(String root_path, Mode mode)
did_update();
};
update();
invalidate();
}
FileSystemModel::~FileSystemModel()
@ -364,7 +364,7 @@ void FileSystemModel::set_root_path(String root_path)
m_root_path = {};
else
m_root_path = LexicalPath::canonicalized_path(move(root_path));
update();
invalidate();
if (m_root->has_error()) {
if (on_directory_change_error)
@ -374,7 +374,7 @@ void FileSystemModel::set_root_path(String root_path)
}
}
void FileSystemModel::update()
void FileSystemModel::invalidate()
{
m_root = adopt_own(*new Node(*this));
@ -383,7 +383,7 @@ void FileSystemModel::update()
m_root->reify_if_needed();
did_update();
Model::invalidate();
}
int FileSystemModel::row_count(const ModelIndex& index) const
@ -665,7 +665,9 @@ void FileSystemModel::set_should_show_dotfiles(bool show)
if (m_should_show_dotfiles == show)
return;
m_should_show_dotfiles = show;
update();
// FIXME: add a way to granularly update in this case.
invalidate();
}
bool FileSystemModel::is_editable(const ModelIndex& index) const