diff options
Diffstat (limited to 'DevTools/HackStudio/Project.h')
-rw-r--r-- | DevTools/HackStudio/Project.h | 60 |
1 files changed, 12 insertions, 48 deletions
diff --git a/DevTools/HackStudio/Project.h b/DevTools/HackStudio/Project.h index dddb34726f..6d3453e84e 100644 --- a/DevTools/HackStudio/Project.h +++ b/DevTools/HackStudio/Project.h @@ -29,19 +29,11 @@ #include "ProjectFile.h" #include <AK/LexicalPath.h> #include <AK/Noncopyable.h> -#include <AK/NonnullRefPtrVector.h> #include <AK/OwnPtr.h> -#include <LibGUI/Icon.h> -#include <LibGUI/Model.h> +#include <LibGUI/FileSystemModel.h> namespace HackStudio { -enum class ProjectType { - Unknown, - Cpp, - JavaScript -}; - class Project { AK_MAKE_NONCOPYABLE(Project); AK_MAKE_NONMOVABLE(Project); @@ -49,52 +41,24 @@ class Project { public: ~Project(); - static OwnPtr<Project> load_from_file(const String& path); + static OwnPtr<Project> open_with_root_path(const String& root_path); - [[nodiscard]] bool add_file(const String& filename); - [[nodiscard]] bool remove_file(const String& filename); - [[nodiscard]] bool save(); + GUI::FileSystemModel& model() { return *m_model; } + const GUI::FileSystemModel& model() const { return *m_model; } + String name() const { return LexicalPath(m_root_path).basename(); } + String root_path() const { return m_root_path; } - RefPtr<ProjectFile> get_file(const String& filename); + RefPtr<ProjectFile> get_file(const String& path) const; - ProjectType type() const { return m_type; } - GUI::Model& model() { return *m_model; } - String default_file() const; - String name() const { return m_name; } - String path() const { return m_path; } - String root_directory() const { return LexicalPath(m_path).dirname(); } - - template<typename Callback> - void for_each_text_file(Callback callback) const - { - for (auto& file : m_files) { - callback(file); - } - } + void for_each_text_file(Function<void(const ProjectFile&)>) const; private: - friend class ProjectModel; - struct ProjectTreeNode; - explicit Project(const String& path, Vector<String>&& files); - - const ProjectTreeNode& root_node() const { return *m_root_node; } - void rebuild_tree(); + explicit Project(const String& root_path); - ProjectType m_type { ProjectType::Unknown }; - String m_name; - String m_path; - RefPtr<GUI::Model> m_model; - NonnullRefPtrVector<ProjectFile> m_files; - RefPtr<ProjectTreeNode> m_root_node; + RefPtr<GUI::FileSystemModel> m_model; + mutable NonnullRefPtrVector<ProjectFile> m_files; - GUI::Icon m_directory_icon; - GUI::Icon m_file_icon; - GUI::Icon m_cplusplus_icon; - GUI::Icon m_header_icon; - GUI::Icon m_project_icon; - GUI::Icon m_javascript_icon; - GUI::Icon m_hackstudio_icon; - GUI::Icon m_form_icon; + String m_root_path; }; } |