mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 10:18:15 +09:00
LibGUI: Allow assigning a value to a specific index in JsonArrayModel
This commit is contained in:
parent
4babf6e4e1
commit
990e362a17
Notes:
sideshowbarker
2024-07-18 21:03:55 +09:00
Author: https://github.com/trflynn89
Commit: 990e362a17
Pull-request: https://github.com/SerenityOS/serenity/pull/5947
2 changed files with 20 additions and 0 deletions
|
@ -76,6 +76,25 @@ bool JsonArrayModel::add(const Vector<JsonValue>&& values)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool JsonArrayModel::set(int row, Vector<JsonValue>&& values)
|
||||||
|
{
|
||||||
|
VERIFY(values.size() == m_fields.size());
|
||||||
|
|
||||||
|
if (row >= m_array.size())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
JsonObject obj;
|
||||||
|
for (size_t i = 0; i < m_fields.size(); ++i) {
|
||||||
|
auto& field_spec = m_fields[i];
|
||||||
|
obj.set(field_spec.json_field_name, move(values.at(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_array.set(row, move(obj));
|
||||||
|
did_update();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool JsonArrayModel::remove(int row)
|
bool JsonArrayModel::remove(int row)
|
||||||
{
|
{
|
||||||
if (row >= m_array.size())
|
if (row >= m_array.size())
|
||||||
|
|
|
@ -76,6 +76,7 @@ public:
|
||||||
void set_json_path(const String& json_path);
|
void set_json_path(const String& json_path);
|
||||||
|
|
||||||
bool add(const Vector<JsonValue>&& fields);
|
bool add(const Vector<JsonValue>&& fields);
|
||||||
|
bool set(int row, Vector<JsonValue>&& fields);
|
||||||
bool remove(int row);
|
bool remove(int row);
|
||||||
bool store();
|
bool store();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue