aboutsummaryrefslogtreecommitdiff
path: root/core/src/Model/Project.cpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2021-06-11 22:19:23 -0700
committerrtk0c <[email protected]>2021-06-11 22:19:23 -0700
commitbdee9dd0c92865e0cec2f4bbf170959df282a930 (patch)
treeaf9d40cb4378ee2166574faed9cc16e283110f31 /core/src/Model/Project.cpp
parent8f7daa9bd100345d7e23639604c9a3a50ce6448b (diff)
More UI polishing and fix asset saving/reloading
Diffstat (limited to 'core/src/Model/Project.cpp')
-rw-r--r--core/src/Model/Project.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/core/src/Model/Project.cpp b/core/src/Model/Project.cpp
index 9f41d3a..523ee9b 100644
--- a/core/src/Model/Project.cpp
+++ b/core/src/Model/Project.cpp
@@ -14,7 +14,7 @@
namespace fs = std::filesystem;
template <class T>
-void ReadItemList(ItemList<T>& list, const fs::path& filePath)
+static void ReadItemList(ItemList<T>& list, const fs::path& filePath)
{
std::ifstream ifs(filePath);
if (ifs) {
@@ -25,9 +25,19 @@ void ReadItemList(ItemList<T>& list, const fs::path& filePath)
}
}
+static void CreateProjectSubfolders(const Project& project)
+{
+ fs::create_directory(project.GetDatabasesDirectory());
+ fs::create_directory(project.GetItemsDirectory());
+ fs::create_directory(project.GetWorkflowsDirectory());
+ fs::create_directory(project.GetTemplatesDirectory());
+}
+
Project::Project(fs::path rootPath)
: mRootPath{ std::move(rootPath) }
, mRootPathString{ mRootPath.string() }
+ , Workflows(*this)
+ , Templates(*this)
, Database(*this)
{
// TODO better diagnostic
@@ -58,18 +68,26 @@ Project::Project(fs::path rootPath)
}
}
+ CreateProjectSubfolders(*this);
+
auto itemsDir = mRootPath / "items";
ReadItemList(Products, itemsDir / "products.json");
ReadItemList(Factories, itemsDir / "factories.json");
ReadItemList(Customers, itemsDir / "customers.json");
+
+ Workflows.Reload();
+ Templates.Reload();
}
Project::Project(fs::path rootPath, std::string name)
: mRootPath{ std::move(rootPath) }
, mRootPathString{ mRootPath.string() }
, mName{ std::move(name) }
+ , Workflows(*this)
+ , Templates(*this)
, Database(*this)
{
+ CreateProjectSubfolders(*this);
}
const fs::path& Project::GetPath() const
@@ -143,9 +161,7 @@ void Project::WriteToDisk()
std::ofstream ofs(mRootPath / "cplt_project.json");
ofs << this->Serialize();
- auto itemsDir = mRootPath / "items";
- fs::create_directories(itemsDir);
-
+ auto itemsDir = GetItemsDirectory();
WriteItemList(Products, itemsDir / "products.json");
WriteItemList(Factories, itemsDir / "factories.json");
WriteItemList(Customers, itemsDir / "customers.json");