logic: Fixed saving project name to ProjectSettings also sets project location to '/'

This commit is contained in:
Eberhard Graether
2017-06-19 23:38:39 +02:00
parent 05c2878eec
commit 652a55b4fb
5 changed files with 28 additions and 23 deletions
+11 -11
View File
@@ -46,7 +46,7 @@ ProjectSettings::ProjectSettings(const FilePath& projectFilePath)
ProjectSettings::ProjectSettings(std::string projectName, const FilePath& projectFileLocation)
{
setFilePath(FilePath(projectFileLocation.str() + "/" + projectName + PROJECT_FILE_EXTENSION));
setProjectFilePath(projectName, projectFileLocation);
}
ProjectSettings::~ProjectSettings()
@@ -105,26 +105,26 @@ bool ProjectSettings::reload()
return Settings::load(getFilePath());
}
FilePath ProjectSettings::getProjectFilePath() const
{
return getFilePath();
}
void ProjectSettings::setProjectFilePath(std::string projectName, const FilePath& projectFileLocation)
{
setFilePath(FilePath(projectFileLocation.str() + "/" + projectName + PROJECT_FILE_EXTENSION));
}
std::string ProjectSettings::getProjectName() const
{
return getFilePath().withoutExtension().fileName();
}
void ProjectSettings::setProjectName(const std::string& name)
{
setFilePath(FilePath(getProjectFileLocation().str() + "/" + name + PROJECT_FILE_EXTENSION));
}
FilePath ProjectSettings::getProjectFileLocation() const
{
return getFilePath().parentDirectory();
}
void ProjectSettings::setProjectFileLocation(const FilePath& location)
{
setFilePath(FilePath(location.str() + "/" + getProjectName() + PROJECT_FILE_EXTENSION));
}
std::string ProjectSettings::getDescription() const
{
return getValue<std::string>("description", "");
+3 -3
View File
@@ -29,11 +29,11 @@ public:
bool reload();
std::string getProjectName() const;
void setProjectName(const std::string& name);
FilePath getProjectFilePath() const;
void setProjectFilePath(std::string projectName, const FilePath& projectFileLocation);
std::string getProjectName() const;
FilePath getProjectFileLocation() const;
void setProjectFileLocation(const FilePath& location);
std::string getDescription() const;
@@ -67,14 +67,9 @@ void QtProjectWizzard::newProjectFromCDB(const FilePath& filePath, const std::ve
m_projectSettings = std::make_shared<ProjectSettings>();
}
if (!m_projectSettings->getProjectName().size())
if (m_projectSettings->getProjectFilePath().empty())
{
m_projectSettings->setProjectName(filePath.withoutExtension().fileName());
}
if (m_projectSettings->getProjectFileLocation().empty())
{
m_projectSettings->setProjectFileLocation(filePath.parentDirectory());
m_projectSettings->setProjectFilePath(filePath.withoutExtension().fileName(), filePath.parentDirectory());
}
if (!m_contentWidget)
@@ -62,8 +62,10 @@ void QtProjectWizzardContentProjectData::load()
void QtProjectWizzardContentProjectData::save()
{
m_projectSettings->setProjectName(m_projectName->text().toStdString());
m_projectSettings->setProjectFileLocation(FilePath(m_projectFileLocation->getText().toStdString()));
m_projectSettings->setProjectFilePath(
m_projectName->text().toStdString(),
FilePath(m_projectFileLocation->getText().toStdString())
);
}
bool QtProjectWizzardContentProjectData::check()
+8
View File
@@ -66,6 +66,14 @@ public:
TS_ASSERT(path.parentDirectory().isDirectory());
}
void test_empty_file_path_has_empty_parent_directory()
{
FilePath path;
TS_ASSERT(path.empty());
TS_ASSERT(path.parentDirectory().empty());
}
void test_file_path_is_absolute()
{
FilePath path("data/FilePathTestSuite/a.cpp");