logic: Fixed saving project name to ProjectSettings also sets project location to '/'
This commit is contained in:
@@ -46,7 +46,7 @@ ProjectSettings::ProjectSettings(const FilePath& projectFilePath)
|
|||||||
|
|
||||||
ProjectSettings::ProjectSettings(std::string projectName, const FilePath& projectFileLocation)
|
ProjectSettings::ProjectSettings(std::string projectName, const FilePath& projectFileLocation)
|
||||||
{
|
{
|
||||||
setFilePath(FilePath(projectFileLocation.str() + "/" + projectName + PROJECT_FILE_EXTENSION));
|
setProjectFilePath(projectName, projectFileLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectSettings::~ProjectSettings()
|
ProjectSettings::~ProjectSettings()
|
||||||
@@ -105,26 +105,26 @@ bool ProjectSettings::reload()
|
|||||||
return Settings::load(getFilePath());
|
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
|
std::string ProjectSettings::getProjectName() const
|
||||||
{
|
{
|
||||||
return getFilePath().withoutExtension().fileName();
|
return getFilePath().withoutExtension().fileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettings::setProjectName(const std::string& name)
|
|
||||||
{
|
|
||||||
setFilePath(FilePath(getProjectFileLocation().str() + "/" + name + PROJECT_FILE_EXTENSION));
|
|
||||||
}
|
|
||||||
|
|
||||||
FilePath ProjectSettings::getProjectFileLocation() const
|
FilePath ProjectSettings::getProjectFileLocation() const
|
||||||
{
|
{
|
||||||
return getFilePath().parentDirectory();
|
return getFilePath().parentDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettings::setProjectFileLocation(const FilePath& location)
|
|
||||||
{
|
|
||||||
setFilePath(FilePath(location.str() + "/" + getProjectName() + PROJECT_FILE_EXTENSION));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ProjectSettings::getDescription() const
|
std::string ProjectSettings::getDescription() const
|
||||||
{
|
{
|
||||||
return getValue<std::string>("description", "");
|
return getValue<std::string>("description", "");
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ public:
|
|||||||
|
|
||||||
bool reload();
|
bool reload();
|
||||||
|
|
||||||
std::string getProjectName() const;
|
FilePath getProjectFilePath() const;
|
||||||
void setProjectName(const std::string& name);
|
void setProjectFilePath(std::string projectName, const FilePath& projectFileLocation);
|
||||||
|
|
||||||
|
std::string getProjectName() const;
|
||||||
FilePath getProjectFileLocation() const;
|
FilePath getProjectFileLocation() const;
|
||||||
void setProjectFileLocation(const FilePath& location);
|
|
||||||
|
|
||||||
std::string getDescription() const;
|
std::string getDescription() const;
|
||||||
|
|
||||||
|
|||||||
@@ -67,14 +67,9 @@ void QtProjectWizzard::newProjectFromCDB(const FilePath& filePath, const std::ve
|
|||||||
m_projectSettings = std::make_shared<ProjectSettings>();
|
m_projectSettings = std::make_shared<ProjectSettings>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_projectSettings->getProjectName().size())
|
if (m_projectSettings->getProjectFilePath().empty())
|
||||||
{
|
{
|
||||||
m_projectSettings->setProjectName(filePath.withoutExtension().fileName());
|
m_projectSettings->setProjectFilePath(filePath.withoutExtension().fileName(), filePath.parentDirectory());
|
||||||
}
|
|
||||||
|
|
||||||
if (m_projectSettings->getProjectFileLocation().empty())
|
|
||||||
{
|
|
||||||
m_projectSettings->setProjectFileLocation(filePath.parentDirectory());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_contentWidget)
|
if (!m_contentWidget)
|
||||||
|
|||||||
@@ -62,8 +62,10 @@ void QtProjectWizzardContentProjectData::load()
|
|||||||
|
|
||||||
void QtProjectWizzardContentProjectData::save()
|
void QtProjectWizzardContentProjectData::save()
|
||||||
{
|
{
|
||||||
m_projectSettings->setProjectName(m_projectName->text().toStdString());
|
m_projectSettings->setProjectFilePath(
|
||||||
m_projectSettings->setProjectFileLocation(FilePath(m_projectFileLocation->getText().toStdString()));
|
m_projectName->text().toStdString(),
|
||||||
|
FilePath(m_projectFileLocation->getText().toStdString())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtProjectWizzardContentProjectData::check()
|
bool QtProjectWizzardContentProjectData::check()
|
||||||
|
|||||||
@@ -66,6 +66,14 @@ public:
|
|||||||
TS_ASSERT(path.parentDirectory().isDirectory());
|
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()
|
void test_file_path_is_absolute()
|
||||||
{
|
{
|
||||||
FilePath path("data/FilePathTestSuite/a.cpp");
|
FilePath path("data/FilePathTestSuite/a.cpp");
|
||||||
|
|||||||
Reference in New Issue
Block a user