Template Class SortModel

Inheritance Relationships

Base Type

Class Documentation

template<typename ModelData>
class SortModel : public slint::Model<ModelData>

The SortModel acts as an adapter model for a given source model by sorting all rows with by order provided by the given sorting function. The sorting function is called for pairs of elements of the source model.

Public Functions

inline SortModel(std::shared_ptr<Model<ModelData>> source_model, std::function<bool(const ModelData&, const ModelData&)> comp)

Constructs a new SortModel that provides a sorted view on the source_model by applying the order given by the specified comp.

inline virtual int row_count() const override

The amount of row in the model.

inline virtual std::optional<ModelData> row_data(int i) const override

Returns the data for a particular row. This function should be called with row < row_count().

inline virtual void set_row_data(int i, const ModelData &value) override

Sets the data for a particular row.

This function should only be called with row < row_count().

If the model cannot support data changes, then it is ok to do nothing. The default implementation will print a warning to stderr.

If the model can update the data, it should also call row_changed

inline void reset()

Re-applies the model’s sort function on each row of the source model. Use this if state external to the sort function has changed.

inline int unsorted_row(int sorted_row_index) const

Given the sorted_row_index, this function returns the corresponding row index in the source model.

inline std::shared_ptr<Model<ModelData>> source_model() const

Returns the source model of this filter model.

Friends

friend struct private_api::SortModelInner< ModelData >