summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGUI/GJsonArrayModel.cpp7
-rw-r--r--Libraries/LibGUI/GJsonArrayModel.h4
2 files changed, 10 insertions, 1 deletions
diff --git a/Libraries/LibGUI/GJsonArrayModel.cpp b/Libraries/LibGUI/GJsonArrayModel.cpp
index 52f329c324..d819518f92 100644
--- a/Libraries/LibGUI/GJsonArrayModel.cpp
+++ b/Libraries/LibGUI/GJsonArrayModel.cpp
@@ -46,6 +46,13 @@ GVariant GJsonArrayModel::data(const GModelIndex& index, Role role) const
return field_spec.massage_for_sort(object);
return data(index, Role::Display);
}
+
+ if (role == GModel::Role::Custom) {
+ if (field_spec.massage_for_custom)
+ return field_spec.massage_for_custom(object);
+ return {};
+ }
+
return {};
}
diff --git a/Libraries/LibGUI/GJsonArrayModel.h b/Libraries/LibGUI/GJsonArrayModel.h
index a5e9f14ceb..25780e6e1e 100644
--- a/Libraries/LibGUI/GJsonArrayModel.h
+++ b/Libraries/LibGUI/GJsonArrayModel.h
@@ -7,11 +7,12 @@
class GJsonArrayModel final : public GModel {
public:
struct FieldSpec {
- FieldSpec(const String& a_column_name, TextAlignment a_text_alignment, Function<GVariant(const JsonObject&)>&& a_massage_for_display, Function<GVariant(const JsonObject&)>&& a_massage_for_sort = {})
+ FieldSpec(const String& a_column_name, TextAlignment a_text_alignment, Function<GVariant(const JsonObject&)>&& a_massage_for_display, Function<GVariant(const JsonObject&)>&& a_massage_for_sort = {}, Function<GVariant(const JsonObject&)>&& a_massage_for_custom = {})
: column_name(a_column_name)
, text_alignment(a_text_alignment)
, massage_for_display(move(a_massage_for_display))
, massage_for_sort(move(a_massage_for_sort))
+ , massage_for_custom(move(a_massage_for_custom))
{
}
@@ -27,6 +28,7 @@ public:
TextAlignment text_alignment;
Function<GVariant(const JsonObject&)> massage_for_display;
Function<GVariant(const JsonObject&)> massage_for_sort;
+ Function<GVariant(const JsonObject&)> massage_for_custom;
};
static NonnullRefPtr<GJsonArrayModel> create(const String& json_path, Vector<FieldSpec>&& fields)