Rename C++'s internal AbstractRepeaterView to ModelChangeListener

For consistency with the Rust model implementation.
This commit is contained in:
Simon Hausmann 2022-09-27 10:26:55 +02:00
parent 5b95466fa6
commit 56983482b9
3 changed files with 8 additions and 8 deletions

View file

@ -595,15 +595,15 @@ inline float layout_cache_access(const SharedVector<float> &cache, int offset, i
}
// models
struct AbstractRepeaterView
struct ModelChangeListener
{
virtual ~AbstractRepeaterView() = default;
virtual ~ModelChangeListener() = default;
virtual void row_added(int index, int count) = 0;
virtual void row_removed(int index, int count) = 0;
virtual void row_changed(int index) = 0;
virtual void reset() = 0;
};
using ModelPeer = std::weak_ptr<AbstractRepeaterView>;
using ModelPeer = std::weak_ptr<ModelChangeListener>;
template<typename M>
auto access_array_index(const M &model, int index)
@ -834,7 +834,7 @@ class FilterModel;
namespace private_api {
template<typename ModelData>
struct FilterModelInner : private_api::AbstractRepeaterView
struct FilterModelInner : private_api::ModelChangeListener
{
FilterModelInner(std::shared_ptr<slint::Model<ModelData>> source_model,
std::function<bool(const ModelData &)> filter_fn,
@ -989,7 +989,7 @@ class Repeater
{
private_api::Property<std::shared_ptr<Model<ModelData>>> model;
struct RepeaterInner : AbstractRepeaterView
struct RepeaterInner : ModelChangeListener
{
enum class State { Clean, Dirty };
struct ComponentWithState

View file

@ -436,13 +436,13 @@ inline Value::Value(const std::shared_ptr<slint::Model<Value>> &model)
{
using cbindgen_private::ModelAdaptorVTable;
using vtable::VRef;
struct ModelWrapper : private_api::AbstractRepeaterView
struct ModelWrapper : private_api::ModelChangeListener
{
std::shared_ptr<slint::Model<Value>> model;
cbindgen_private::ModelNotifyOpaque notify;
// This kind of mean that the rust code has ownership of "this" until the drop function is
// called
std::shared_ptr<AbstractRepeaterView> self;
std::shared_ptr<ModelChangeListener> self;
~ModelWrapper() { cbindgen_private::slint_interpreter_model_notify_destructor(&notify); }
void row_added(int index, int count) override