2018-08-06 18:37:16 +00:00
|
|
|
#include "projectmanager.h"
|
2018-08-07 14:51:29 +00:00
|
|
|
#include <storage/appdatastorage.h>
|
2018-08-06 18:37:16 +00:00
|
|
|
|
|
|
|
namespace Ember
|
|
|
|
{
|
|
|
|
|
|
|
|
ProjectManager::ProjectManager()
|
2018-08-07 14:51:29 +00:00
|
|
|
: m_currentProject(nullptr),
|
|
|
|
m_recentProjects(),
|
|
|
|
m_recentProjectsLoaded(false)
|
2018-08-06 18:37:16 +00:00
|
|
|
{
|
2018-08-07 14:51:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const ProjectManager::RecentProjectMap &ProjectManager::recentProjects()
|
|
|
|
{
|
|
|
|
if (!m_recentProjectsLoaded)
|
|
|
|
{
|
|
|
|
std::vector<RecentProject> projects;
|
|
|
|
AppDataStorage::readRecentProjects(projects);
|
|
|
|
|
|
|
|
for (RecentProject& project : projects)
|
|
|
|
m_recentProjects.emplace(project.path, project);
|
|
|
|
|
|
|
|
m_recentProjectsLoaded = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_recentProjects;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectManager::pinRecentProject(boost::filesystem::path path, bool pinned)
|
|
|
|
{
|
|
|
|
auto it = m_recentProjects.find(path);
|
|
|
|
if (it != m_recentProjects.end())
|
|
|
|
{
|
|
|
|
if (it->second.pinned != pinned)
|
|
|
|
{
|
|
|
|
it->second.pinned = pinned;
|
|
|
|
saveRecentProjects();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectManager::deleteRecentProject(boost::filesystem::path path)
|
|
|
|
{
|
|
|
|
auto it = m_recentProjects.find(path);
|
|
|
|
if (it != m_recentProjects.end())
|
|
|
|
{
|
|
|
|
m_recentProjects.erase(it);
|
|
|
|
saveRecentProjects();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectManager::saveRecentProjects()
|
|
|
|
{
|
|
|
|
std::vector<RecentProject> projects;
|
|
|
|
for (auto pair : m_recentProjects)
|
|
|
|
projects.push_back(pair.second);
|
2018-08-06 18:37:16 +00:00
|
|
|
|
2018-08-07 14:51:29 +00:00
|
|
|
AppDataStorage::storeRecentProjects(projects);
|
2018-08-06 18:37:16 +00:00
|
|
|
}
|
|
|
|
|
2018-08-07 14:51:29 +00:00
|
|
|
|
2018-08-06 18:37:16 +00:00
|
|
|
}
|