mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:38:10 +00:00
LibGUI: Allow assigning a value to a specific index in JsonArrayModel
This commit is contained in:
parent
4babf6e4e1
commit
990e362a17
2 changed files with 20 additions and 0 deletions
|
@ -76,6 +76,25 @@ bool JsonArrayModel::add(const Vector<JsonValue>&& values)
|
|||
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)
|
||||
{
|
||||
if (row >= m_array.size())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue