logic: fixed making paths relative for indexed header path detection

This commit is contained in:
mlangkabel
2018-06-01 15:11:01 +02:00
parent e43e604966
commit 12bf007caf
2 changed files with 19 additions and 14 deletions
@@ -246,11 +246,11 @@ void QtProjectWizzardContentPathCDB::pickedPath()
const FilePath projectPath = m_settings->getProjectDirectoryPath();
std::vector<FilePath> indexedHeaderPaths;
for (const FilePath path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromCDB(cdbSettings))
for (const FilePath& path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromCDB(cdbSettings))
{
if (projectPath.contains(path))
{
indexedHeaderPaths.push_back(path);
indexedHeaderPaths.push_back(path.getRelativeTo(projectPath));
}
}
cdbSettings->setIndexedHeaderPaths(indexedHeaderPaths);
@@ -389,6 +389,9 @@ QString QtProjectWizzardContentSonargraphProjectPath::getFileNamesDescription()
void QtProjectWizzardContentSonargraphProjectPath::pickedPath()
{
m_window->saveContent();
// TODO: update indexed headers
m_window->loadContent();
}
@@ -272,7 +272,6 @@ QString QtProjectWizzardContentPathsSource::getFileNamesDescription() const
std::vector<FilePath> QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromSonargraphProject(
std::shared_ptr<const SourceGroupSettingsCxxSonargraph> settings)
{
const FilePath projectPath = settings->getProjectDirectoryPath();
std::set<FilePath> indexedHeaderPaths;
{
const FilePath sonargraphProjectPath = settings->getSonargraphProjectPathExpandedAndAbsolute();
@@ -294,16 +293,12 @@ std::vector<FilePath> QtProjectWizzardContentIndexedHeaderPaths::getIndexedPaths
LOG_WARNING("Unable to fetch indexed header paths. The provided Sonargraph project path does not exist.");
}
}
return utility::convert<FilePath, FilePath>(
utility::getTopLevelPaths(indexedHeaderPaths),
[&](const FilePath& path) { return path.getRelativeTo(projectPath); }
);
return utility::getTopLevelPaths(indexedHeaderPaths);
}
std::vector<FilePath> QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromCDB(
std::shared_ptr<const SourceGroupSettingsCxxCdb> settings)
{
const FilePath projectPath = settings->getProjectDirectoryPath();
std::set<FilePath> indexedHeaderPaths;
{
const FilePath cdbPath = settings->getCompilationDatabasePathExpandedAndAbsolute();
@@ -327,10 +322,7 @@ std::vector<FilePath> QtProjectWizzardContentIndexedHeaderPaths::getIndexedPaths
}
}
return utility::convert<FilePath, FilePath>(
utility::getTopLevelPaths(indexedHeaderPaths),
[&](const FilePath& path) { return path.getRelativeTo(projectPath); }
);
return utility::getTopLevelPaths(indexedHeaderPaths);
}
QtProjectWizzardContentIndexedHeaderPaths::QtProjectWizzardContentIndexedHeaderPaths(
@@ -434,8 +426,13 @@ void QtProjectWizzardContentIndexedHeaderPaths::buttonClicked()
connect(m_filesDialog.get(), &QtSelectPathsDialog::finished, this, &QtProjectWizzardContentIndexedHeaderPaths::savedFilesDialog);
connect(m_filesDialog.get(), &QtSelectPathsDialog::canceled, this, &QtProjectWizzardContentIndexedHeaderPaths::closedFilesDialog);
const FilePath projectPath = sonargraphSettings->getProjectDirectoryPath();
dynamic_cast<QtSelectPathsDialog*>(m_filesDialog.get())->setPathsList(
getIndexedPathsDerivedFromSonargraphProject(sonargraphSettings),
utility::convert<FilePath, FilePath>(
getIndexedPathsDerivedFromSonargraphProject(sonargraphSettings),
[&](const FilePath& path) { return path.getRelativeTo(projectPath); }
),
sonargraphSettings->getIndexedHeaderPaths(),
m_settings->getProjectDirectoryPath()
);
@@ -461,8 +458,13 @@ void QtProjectWizzardContentIndexedHeaderPaths::buttonClicked()
connect(m_filesDialog.get(), &QtSelectPathsDialog::finished, this, &QtProjectWizzardContentIndexedHeaderPaths::savedFilesDialog);
connect(m_filesDialog.get(), &QtSelectPathsDialog::canceled, this, &QtProjectWizzardContentIndexedHeaderPaths::closedFilesDialog);
const FilePath projectPath = cdbSettings->getProjectDirectoryPath();
dynamic_cast<QtSelectPathsDialog*>(m_filesDialog.get())->setPathsList(
getIndexedPathsDerivedFromCDB(cdbSettings),
utility::convert<FilePath, FilePath>(
getIndexedPathsDerivedFromCDB(cdbSettings),
[&](const FilePath& path) { return path.getRelativeTo(projectPath); }
),
cdbSettings->getIndexedHeaderPaths(),
m_settings->getProjectDirectoryPath()
);