mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:17:44 +00:00
Inspector: Expand and show properties in a TreeView
This allows the inspector to show arbitrary json structures.
This commit is contained in:
parent
476ccb2206
commit
7b72001667
5 changed files with 372 additions and 23 deletions
|
@ -26,14 +26,16 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/JsonPath.h>
|
||||
#include <AK/JsonValue.h>
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
#include <LibGUI/Model.h>
|
||||
|
||||
class RemoteObject;
|
||||
|
||||
class RemoteObjectPropertyModel final : public GUI::Model {
|
||||
public:
|
||||
virtual ~RemoteObjectPropertyModel() override {}
|
||||
virtual ~RemoteObjectPropertyModel() override { }
|
||||
static NonnullRefPtr<RemoteObjectPropertyModel> create(RemoteObject& object)
|
||||
{
|
||||
return adopt(*new RemoteObjectPropertyModel(object));
|
||||
|
@ -52,14 +54,15 @@ public:
|
|||
virtual void set_data(const GUI::ModelIndex&, const GUI::Variant&) override;
|
||||
virtual void update() override;
|
||||
virtual bool is_editable(const GUI::ModelIndex& index) const override { return index.column() == Column::Value; }
|
||||
virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex& parent = GUI::ModelIndex()) const override;
|
||||
virtual GUI::ModelIndex parent_index(const GUI::ModelIndex&) const override;
|
||||
|
||||
private:
|
||||
explicit RemoteObjectPropertyModel(RemoteObject&);
|
||||
|
||||
const JsonPath* cached_path_at(int n, const Vector<JsonPathElement>& prefix) const;
|
||||
const JsonPath* find_cached_path(const Vector<JsonPathElement>& path) const;
|
||||
|
||||
RemoteObject& m_object;
|
||||
struct NameAndValue {
|
||||
JsonValue name;
|
||||
JsonValue value;
|
||||
};
|
||||
Vector<NameAndValue> m_properties;
|
||||
mutable NonnullOwnPtrVector<JsonPath> m_paths;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue