1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 19:54:57 +00:00

GJsonArrayModel: Add hook to customize what comes out of GModel::Sort

Now you can provide a massage_for_sort hook in your FieldSpec.
This allows you to implement arbitrary sorting rules for the data.
This commit is contained in:
Andreas Kling 2019-08-12 11:54:18 +02:00
parent 2c7b0b8893
commit 69ec08774b
2 changed files with 9 additions and 1 deletions

View file

@ -40,6 +40,12 @@ GVariant GJsonArrayModel::data(const GModelIndex& index, Role role) const
return data.as_uint();
return object.get(json_field_name).to_string();
}
if (role == GModel::Role::Sort) {
if (field_spec.massage_for_sort)
return field_spec.massage_for_sort(object);
return data(index, Role::Display);
}
return {};
}