1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 18:05:07 +00:00

LibGUI: Don't require passing model to FileSystemModel::Node APIs

The Node API was obnoxiously requiring you to pass the model into it
all the time, simply because nodes could not find their way back to
the containing model. This patch adds a back-reference to the model
and simplifies the API.
This commit is contained in:
Andreas Kling 2020-08-17 22:02:21 +02:00
parent 38d8426f32
commit f0349323c4
5 changed files with 47 additions and 40 deletions

View file

@ -87,11 +87,18 @@ public:
int error() const { return m_error; }
const char* error_string() const { return strerror(m_error); }
String full_path(const FileSystemModel&) const;
String full_path() const;
private:
friend class FileSystemModel;
explicit Node(FileSystemModel& model)
: m_model(model)
{
}
FileSystemModel& m_model;
Node* parent { nullptr };
NonnullOwnPtrVector<Node> children;
bool has_traversed { false };
@ -103,9 +110,9 @@ public:
int m_error { 0 };
ModelIndex index(const FileSystemModel&, int column) const;
void traverse_if_needed(const FileSystemModel&);
void reify_if_needed(const FileSystemModel&);
ModelIndex index(int column) const;
void traverse_if_needed();
void reify_if_needed();
bool fetch_data(const String& full_path, bool is_root);
};