mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 07:07:23 +00:00
LibGUI: JsonArrayModel update without invalidating indices
Add function to update a JsonArrayModel without invalidating it. Now, for example in the SystemMonitor in the Network tab, a selected line will not be deselected whenever the data is updated.
This commit is contained in:
committed by
Andreas Kling
parent
fd24782d85
commit
b6c3fad078
@@ -28,6 +28,24 @@ void JsonArrayModel::invalidate()
|
||||
did_update();
|
||||
}
|
||||
|
||||
void JsonArrayModel::update()
|
||||
{
|
||||
auto file = Core::File::construct(m_json_path);
|
||||
if (!file->open(Core::OpenMode::ReadOnly)) {
|
||||
dbgln("Unable to open {}", file->filename());
|
||||
m_array.clear();
|
||||
did_update();
|
||||
return;
|
||||
}
|
||||
|
||||
auto json = JsonValue::from_string(file->read_all()).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
VERIFY(json.is_array());
|
||||
m_array = json.as_array();
|
||||
|
||||
did_update(GUI::Model::UpdateFlag::DontInvalidateIndices);
|
||||
}
|
||||
|
||||
bool JsonArrayModel::store()
|
||||
{
|
||||
auto file = Core::File::construct(m_json_path);
|
||||
|
||||
Reference in New Issue
Block a user