serenity/LibGUI/GFileSystemModel.h
Andreas Kling 4d3c5fd83e LibGUI: Start working on a GFileSystemModel and hook that up in FileManager.
This is a read-only model for the tree view, at least initially. We'll see
where we take it from there once it's more polished.
2019-03-29 17:03:30 +01:00

31 lines
1,012 B
C++

#pragma once
#include <LibGUI/GModel.h>
class GFileSystemModel : public GModel {
friend class Node;
public:
static Retained<GFileSystemModel> create(const String& root_path = "/")
{
return adopt(*new GFileSystemModel(root_path));
}
virtual ~GFileSystemModel() override;
String root_path() const { return m_root_path; }
virtual int row_count(const GModelIndex& = GModelIndex()) const override;
virtual int column_count(const GModelIndex& = GModelIndex()) const override;
virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
virtual void update() override;
virtual GModelIndex parent_index(const GModelIndex&) const override;
virtual GModelIndex index(int row, int column = 0, const GModelIndex& = GModelIndex()) const override;
virtual void activate(const GModelIndex&) override;
private:
explicit GFileSystemModel(const String& root_path);
String m_root_path;
struct Node;
Node* m_root { nullptr };
};