mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
4d3c5fd83e
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.
31 lines
1,012 B
C++
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 };
|
|
};
|