Bladeren bron

LibGUI: Replace uses of JsonObject::get_deprecated()/get_ptr()

Sam Atkins 2 jaren geleden
bovenliggende
commit
2fce19a451

+ 2 - 2
Userland/Libraries/LibGUI/CommonLocationsProvider.cpp

@@ -56,8 +56,8 @@ ErrorOr<void> CommonLocationsProvider::load_from_json(StringView json_path)
         if (!entry_value.is_object())
             continue;
         auto entry = entry_value.as_object();
-        auto name = entry.get_deprecated("name"sv).to_deprecated_string();
-        auto path = entry.get_deprecated("path"sv).to_deprecated_string();
+        auto name = entry.get_deprecated_string("name"sv).value_or({});
+        auto path = entry.get_deprecated_string("path"sv).value_or({});
         TRY(s_common_locations.try_append({ name, path }));
     }
 

+ 6 - 4
Userland/Libraries/LibGUI/JsonArrayModel.cpp

@@ -119,12 +119,14 @@ Variant JsonArrayModel::data(ModelIndex const& index, ModelRole role) const
 
     if (role == ModelRole::Display) {
         auto& json_field_name = field_spec.json_field_name;
-        auto data = object.get_deprecated(json_field_name);
+        auto data = object.get(json_field_name);
         if (field_spec.massage_for_display)
             return field_spec.massage_for_display(object);
-        if (data.is_number())
-            return data;
-        return object.get_deprecated(json_field_name).to_deprecated_string();
+        if (!data.has_value())
+            return "";
+        if (data->is_number())
+            return data.value();
+        return data->to_deprecated_string();
     }
 
     if (role == ModelRole::Sort) {

+ 2 - 2
Userland/Libraries/LibGUI/UIDimensions.h

@@ -306,9 +306,9 @@ inline auto clamp<GUI::UIDimension>(GUI::UIDimension const& input, GUI::UIDimens
             if (!value.is_object())                                            \
                 return false;                                                  \
             auto result_width = GUI::UIDimension::construct_from_json_value(   \
-                value.as_object().get_deprecated("width"sv));                  \
+                value.as_object().get("width"sv).value_or({}));                \
             auto result_height = GUI::UIDimension::construct_from_json_value(  \
-                value.as_object().get_deprecated("height"sv));                 \
+                value.as_object().get("height"sv).value_or({}));               \
             if (result_width.has_value() && result_height.has_value()) {       \
                 GUI::UISize size(result_width.value(), result_height.value()); \
                 setter(size);                                                  \