1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:47:35 +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

@ -207,9 +207,4 @@ GUI::Variant DisassemblyModel::data(const GUI::ModelIndex& index, GUI::ModelRole
return {};
}
void DisassemblyModel::update()
{
did_update();
}
}

View file

@ -47,7 +47,6 @@ public:
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; }
virtual String column_name(int) const override;
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
virtual void update() override;
virtual bool is_column_sortable(int) const override { return false; }
private:

View file

@ -67,9 +67,4 @@ GUI::Variant IndividualSampleModel::data(const GUI::ModelIndex& index, GUI::Mode
return {};
}
void IndividualSampleModel::update()
{
did_update(Model::InvalidateAllIndices);
}
}

View file

@ -32,7 +32,6 @@ public:
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
virtual String column_name(int) const override;
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
virtual void update() override;
private:
IndividualSampleModel(Profile&, size_t event_index);

View file

@ -187,7 +187,7 @@ void Profile::rebuild_tree()
sort_profile_nodes(roots);
m_roots = move(roots);
m_model->update();
m_model->invalidate();
}
Result<NonnullOwnPtr<Profile>, String> Profile::load_from_perfcore_file(const StringView& path)
@ -378,7 +378,7 @@ void Profile::set_timestamp_filter_range(u64 start, u64 end)
m_timestamp_filter_range_end = max(start, end);
rebuild_tree();
m_samples_model->update();
m_samples_model->invalidate();
}
void Profile::clear_timestamp_filter_range()
@ -387,7 +387,7 @@ void Profile::clear_timestamp_filter_range()
return;
m_has_timestamp_filter_range = false;
rebuild_tree();
m_samples_model->update();
m_samples_model->invalidate();
}
void Profile::add_process_filter(pid_t pid, EventSerialNumber start_valid, EventSerialNumber end_valid)
@ -399,8 +399,8 @@ void Profile::add_process_filter(pid_t pid, EventSerialNumber start_valid, Event
rebuild_tree();
if (m_disassembly_model)
m_disassembly_model->update();
m_samples_model->update();
m_disassembly_model->invalidate();
m_samples_model->invalidate();
}
void Profile::remove_process_filter(pid_t pid, EventSerialNumber start_valid, EventSerialNumber end_valid)
@ -414,8 +414,8 @@ void Profile::remove_process_filter(pid_t pid, EventSerialNumber start_valid, Ev
rebuild_tree();
if (m_disassembly_model)
m_disassembly_model->update();
m_samples_model->update();
m_disassembly_model->invalidate();
m_samples_model->invalidate();
}
void Profile::clear_process_filter()
@ -425,8 +425,8 @@ void Profile::clear_process_filter()
m_process_filters.clear();
rebuild_tree();
if (m_disassembly_model)
m_disassembly_model->update();
m_samples_model->update();
m_disassembly_model->invalidate();
m_samples_model->invalidate();
}
bool Profile::process_filter_contains(pid_t pid, EventSerialNumber serial)

View file

@ -135,9 +135,4 @@ GUI::Variant ProfileModel::data(const GUI::ModelIndex& index, GUI::ModelRole rol
return {};
}
void ProfileModel::update()
{
did_update(Model::InvalidateAllIndices);
}
}

View file

@ -35,7 +35,6 @@ public:
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex& parent = GUI::ModelIndex()) const override;
virtual GUI::ModelIndex parent_index(const GUI::ModelIndex&) const override;
virtual void update() override;
virtual int tree_column() const override { return Column::StackFrame; }
virtual bool is_column_sortable(int) const override { return false; }

View file

@ -94,9 +94,4 @@ GUI::Variant SamplesModel::data(const GUI::ModelIndex& index, GUI::ModelRole rol
return {};
}
void SamplesModel::update()
{
did_update(Model::InvalidateAllIndices);
}
}

View file

@ -36,7 +36,6 @@ public:
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
virtual String column_name(int) const override;
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
virtual void update() override;
virtual bool is_column_sortable(int) const override { return false; }
private: