Template Class MapModel#
Defined in File slint.h
public slint::Model< SourceModelData >(Template Class Model)
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_stringon each value given in the mapping lambda expression.
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 size_t row_count() const override#
The amount of row in the model.
inline virtual std::optional<MappedModelData> row_data(size_t i) const override#
Returns the data for a particular row. This function should be called with
row < row_count().
- friend struct private_api::MapModelInner< SourceModelData, MappedModelData >