logic: make python environment path configurable in project settings

This commit is contained in:
mlangkabel
2019-04-08 13:09:52 +02:00
parent 045a3a4e50
commit f7d3275e89
8 changed files with 126 additions and 12 deletions
@@ -1,7 +1,7 @@
#include "SourceGroupSettingsCxxCodeblocks.h"
#include "ProjectSettings.h"
#include "ConfigManager.h"
#include "ProjectSettings.h"
SourceGroupSettingsCxxCodeblocks::SourceGroupSettingsCxxCodeblocks(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettingsCxx(id, SOURCE_GROUP_CXX_CODEBLOCKS, projectSettings)
@@ -1,5 +1,7 @@
#include "SourceGroupSettingsPythonEmpty.h"
#include "FilePath.h"
#include "ProjectSettings.h"
SourceGroupSettingsPythonEmpty::SourceGroupSettingsPythonEmpty(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettings(id, SOURCE_GROUP_PYTHON_EMPTY, projectSettings)
@@ -20,6 +22,8 @@ void SourceGroupSettingsPythonEmpty::load(std::shared_ptr<const ConfigManager> c
SourceGroupSettingsWithExcludeFilters::load(config, key);
SourceGroupSettingsWithSourcePaths::load(config, key);
SourceGroupSettingsWithSourceExtensions::load(config, key);
setEnvironmentDirectoryPath(config->getValueOrDefault(key + "/python_environment_directory_path", FilePath(L"")));
}
void SourceGroupSettingsPythonEmpty::save(std::shared_ptr<ConfigManager> config)
@@ -31,21 +35,39 @@ void SourceGroupSettingsPythonEmpty::save(std::shared_ptr<ConfigManager> config)
SourceGroupSettingsWithExcludeFilters::save(config, key);
SourceGroupSettingsWithSourcePaths::save(config, key);
SourceGroupSettingsWithSourceExtensions::save(config, key);
config->setValue(key + "/python_environment_directory_path", getEnvironmentDirectoryPath().wstr());
}
bool SourceGroupSettingsPythonEmpty::equals(std::shared_ptr<SourceGroupSettings> other) const
{
std::shared_ptr<SourceGroupSettingsPythonEmpty> otherJava = std::dynamic_pointer_cast<SourceGroupSettingsPythonEmpty>(other);
std::shared_ptr<SourceGroupSettingsPythonEmpty> otherPython = std::dynamic_pointer_cast<SourceGroupSettingsPythonEmpty>(other);
return (
otherJava &&
otherPython &&
SourceGroupSettings::equals(other) &&
SourceGroupSettingsWithExcludeFilters::equals(otherJava) &&
SourceGroupSettingsWithSourcePaths::equals(otherJava) &&
SourceGroupSettingsWithSourceExtensions::equals(otherJava)
SourceGroupSettingsWithExcludeFilters::equals(otherPython) &&
SourceGroupSettingsWithSourcePaths::equals(otherPython) &&
SourceGroupSettingsWithSourceExtensions::equals(otherPython) &&
m_environmentDirectoryPath == otherPython->m_environmentDirectoryPath
);
}
FilePath SourceGroupSettingsPythonEmpty::getEnvironmentDirectoryPath() const
{
return m_environmentDirectoryPath;
}
FilePath SourceGroupSettingsPythonEmpty::getEnvironmentDirectoryPathExpandedAndAbsolute() const
{
return m_projectSettings->makePathExpandedAndAbsolute(getEnvironmentDirectoryPath());
}
void SourceGroupSettingsPythonEmpty::setEnvironmentDirectoryPath(const FilePath& environmentDirectoryPath)
{
m_environmentDirectoryPath = environmentDirectoryPath;
}
std::vector<std::wstring> SourceGroupSettingsPythonEmpty::getDefaultSourceExtensions() const
{
return {
@@ -1,6 +1,7 @@
#ifndef SOURCE_GROUP_SETTINGS_PYTHON_EMPTY_H
#define SOURCE_GROUP_SETTINGS_PYTHON_EMPTY_H
#include "FilePath.h"
#include "SourceGroupSettings.h"
#include "SourceGroupSettingsWithExcludeFilters.h"
#include "SourceGroupSettingsWithSourceExtensions.h"
@@ -22,9 +23,14 @@ public:
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
FilePath getEnvironmentDirectoryPath() const;
FilePath getEnvironmentDirectoryPathExpandedAndAbsolute() const;
void setEnvironmentDirectoryPath(const FilePath& environmentDirectoryPath);
private:
std::vector<std::wstring> getDefaultSourceExtensions() const override;
FilePath m_environmentDirectoryPath;
};
#endif // SOURCE_GROUP_SETTINGS_PYTHON_EMPTY_H