mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-17 02:43:04 +00:00
parent
bdae506fd6
commit
bf3c47f1fa
1 changed files with 22 additions and 0 deletions
|
|
@ -511,6 +511,14 @@ struct MapModelInner : private_api::ModelChangeListener
|
||||||
/// example a MapModel can be used to adapt a model that provides numbers to be a model
|
/// 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
|
/// that exposes all numbers converted to strings, by calling `std::to_string` on each
|
||||||
/// value given in the mapping lambda expression.
|
/// value given in the mapping lambda expression.
|
||||||
|
///
|
||||||
|
/// \code
|
||||||
|
/// auto source_model = std::make_shared<slint::VectorModel<Person>>(...);
|
||||||
|
/// auto mapped_model = std::make_shared<slint::MapModel<Person, SharedString>>(
|
||||||
|
/// source_model, [](const Person &person) {
|
||||||
|
// return fmt::format("{} {}", person.first, person.last);
|
||||||
|
// });
|
||||||
|
/// \endcode
|
||||||
template<typename SourceModelData, typename MappedModelData = SourceModelData>
|
template<typename SourceModelData, typename MappedModelData = SourceModelData>
|
||||||
class MapModel : public Model<MappedModelData>
|
class MapModel : public Model<MappedModelData>
|
||||||
{
|
{
|
||||||
|
|
@ -686,6 +694,14 @@ struct SortModelInner : private_api::ModelChangeListener
|
||||||
/// The SortModel acts as an adapter model for a given source model by sorting all rows
|
/// 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
|
/// with by order provided by the given sorting function. The sorting function is called for
|
||||||
/// pairs of elements of the source model.
|
/// pairs of elements of the source model.
|
||||||
|
///
|
||||||
|
/// \code
|
||||||
|
/// auto source_model = std::make_shared<slint::VectorModel<SharedString>>(
|
||||||
|
// std::vector<SharedString> { "lorem", "ipsum", "dolor" });
|
||||||
|
/// auto sorted_model = std::make_shared<slint::SortModel<SharedString>>(
|
||||||
|
/// source_model, [](auto lhs, auto rhs) { return lhs < rhs; }));
|
||||||
|
/// \endcode
|
||||||
|
|
||||||
template<typename ModelData>
|
template<typename ModelData>
|
||||||
class SortModel : public Model<ModelData>
|
class SortModel : public Model<ModelData>
|
||||||
{
|
{
|
||||||
|
|
@ -776,6 +792,12 @@ struct ReverseModelInner : private_api::ModelChangeListener
|
||||||
/// The ReverseModel acts as an adapter model for a given source model by reserving all rows.
|
/// The ReverseModel acts as an adapter model for a given source model by reserving all rows.
|
||||||
/// This means that the first row in the source model is the last row of this model, the second
|
/// This means that the first row in the source model is the last row of this model, the second
|
||||||
/// row is the second last, and so on.
|
/// row is the second last, and so on.
|
||||||
|
///
|
||||||
|
/// \code
|
||||||
|
/// auto source_model = std::make_shared<slint::VectorModel<int>>(
|
||||||
|
// std::vector<int> { 1, 2, 3, 4, 5 });
|
||||||
|
/// auto reversed_model = std::make_shared<slint::ReverseModel<int>>(source_model);
|
||||||
|
/// \endcode
|
||||||
template<typename ModelData>
|
template<typename ModelData>
|
||||||
class ReverseModel : public Model<ModelData>
|
class ReverseModel : public Model<ModelData>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue