Template Class MapModel
Defined in File slint.h
Inheritance Relationships
Base Type
public slint::Model< SourceModelData >
(Template Class Model)
Class Documentation
-
template<typename SourceModelData, typename MappedModelData = SourceModelData>
class MapModel : public slint::Model<SourceModelData> The MapModel acts as an adapter model for a given source model by applying a mapping function. The mapping function is called for each row on the source model and allows transforming the values on the fly. The MapModel has two template parameters: The SourceModelData specifies the data type of the underlying source model, and the MappedModelData the data type of this MapModel. This permits not only changing the values of the underlying source model, but also changing the data type itself. For example a MapModel can be used to adapt a model that provides numbers to be a model that exposes all numbers converted to strings, by calling
std::to_string
on each value given in the mapping lambda expression.Public Functions
Constructs a new MapModel that provides an altered view on the source_model by applying map_fn on the data in each row.
-
inline virtual int row_count() const override
The amount of row in the model.
-
inline virtual std::optional<MappedModelData> row_data(int i) const override
Returns the data for a particular row. This function should be called with
row < row_count()
.
-
inline std::shared_ptr<Model<SourceModelData>> source_model() const
Returns the source model of this filter model.
Friends
- friend struct private_api::MapModelInner< SourceModelData, MappedModelData >