2019-10-21 19:46:55 +03:00
|
|
|
#pragma once
|
|
|
|
|
2019-10-23 21:54:41 +03:00
|
|
|
#include "TextDocument.h"
|
2019-10-21 19:46:55 +03:00
|
|
|
#include <AK/Noncopyable.h>
|
2019-10-23 21:54:41 +03:00
|
|
|
#include <AK/NonnullRefPtrVector.h>
|
2019-10-21 19:46:55 +03:00
|
|
|
#include <AK/OwnPtr.h>
|
|
|
|
#include <LibGUI/GModel.h>
|
|
|
|
|
|
|
|
class Project {
|
|
|
|
AK_MAKE_NONCOPYABLE(Project)
|
|
|
|
AK_MAKE_NONMOVABLE(Project)
|
|
|
|
public:
|
|
|
|
static OwnPtr<Project> load_from_file(const String& path);
|
|
|
|
|
2019-10-26 22:27:57 +03:00
|
|
|
[[nodiscard]] bool add_file(const String& filename);
|
|
|
|
|
2019-10-27 21:39:15 +03:00
|
|
|
TextDocument* get_file(const String& filename);
|
|
|
|
|
2019-10-21 19:46:55 +03:00
|
|
|
GModel& model() { return *m_model; }
|
|
|
|
|
2019-10-23 21:54:41 +03:00
|
|
|
template<typename Callback>
|
|
|
|
void for_each_text_file(Callback callback) const
|
|
|
|
{
|
|
|
|
for (auto& file : m_files) {
|
|
|
|
callback(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-26 22:27:57 +03:00
|
|
|
|
2019-10-21 19:46:55 +03:00
|
|
|
private:
|
|
|
|
friend class ProjectModel;
|
2019-10-26 22:27:57 +03:00
|
|
|
explicit Project(const String& path, Vector<String>&& files);
|
2019-10-21 19:46:55 +03:00
|
|
|
|
2019-10-26 22:27:57 +03:00
|
|
|
String m_path;
|
2019-10-21 19:46:55 +03:00
|
|
|
RefPtr<GModel> m_model;
|
2019-10-23 21:54:41 +03:00
|
|
|
NonnullRefPtrVector<TextDocument> m_files;
|
2019-10-21 19:46:55 +03:00
|
|
|
};
|