logic: implemented usage of FilePathFilters for excluded paths

* removed check in settings for existing paths of exclude filters
This commit is contained in:
mlangkabel
2018-03-12 08:51:38 +01:00
parent 31c9f9fecc
commit 6acfe0688f
44 changed files with 572 additions and 221 deletions
@@ -33,7 +33,7 @@ void QtProjectWizzardContentCDBSource::load()
m_filePaths.clear();
const FilePath projectPath = m_settings->getProjectDirectoryPath();
std::vector<FilePath> excludePaths = m_settings->getExcludePathsExpandedAndAbsolute();
const std::vector<FilePathFilter> excludeFilters = m_settings->getExcludeFiltersExpandedAndAbsolute();
if (std::shared_ptr<SourceGroupSettingsCxxCdb> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(m_settings))
{
@@ -44,19 +44,21 @@ void QtProjectWizzardContentCDBSource::load()
for (FilePath& path : filePaths)
{
bool excluded = false;
for (const FilePath& p : excludePaths)
{
if (p == path || p.contains(path))
bool excluded = false;
for (const FilePathFilter& filter : excludeFilters)
{
excluded = true;
break;
if (filter.isMatching(path))
{
excluded = true;
break;
}
}
}
if (excluded)
{
continue;
if (excluded)
{
continue;
}
}
if (projectPath.exists())
@@ -260,7 +260,7 @@ std::vector<FilePath> QtProjectWizzardContentPathSourceMaven::getFilePaths() con
FileManager fileManager;
fileManager.update(
sourceDirectories,
m_settings->getExcludePathsExpandedAndAbsolute(),
m_settings->getExcludeFiltersExpandedAndAbsolute(),
m_settings->getSourceExtensions()
);
@@ -391,7 +391,7 @@ std::vector<FilePath> QtProjectWizzardContentPathSourceGradle::getFilePaths() co
FileManager fileManager;
fileManager.update(
sourceDirectories,
m_settings->getExcludePathsExpandedAndAbsolute(),
m_settings->getExcludeFiltersExpandedAndAbsolute(),
m_settings->getSourceExtensions()
);
@@ -27,11 +27,12 @@
#include "utility/utilityString.h"
QtProjectWizzardContentPaths::QtProjectWizzardContentPaths(
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window, bool checkMissingPaths
)
: QtProjectWizzardContent(window)
, m_settings(settings)
, m_makePathsRelativeToProjectFileLocation(true)
, m_checkMissingPaths(checkMissingPaths)
{
}
@@ -70,56 +71,61 @@ void QtProjectWizzardContentPaths::populate(QGridLayout* layout, int& row)
bool QtProjectWizzardContentPaths::check()
{
QString missingPaths;
std::vector<FilePath> existingPaths;
for (const FilePath& path : m_list->getList())
if (m_checkMissingPaths)
{
std::vector<FilePath> expandedPaths(1, path);
if (m_settings)
{
expandedPaths = m_settings->makePathsExpandedAndAbsolute(expandedPaths);
}
QString missingPaths;
std::vector<FilePath> existingPaths;
size_t existingCount = 0;
for (const FilePath& expandedPath : expandedPaths)
for (const FilePath& path : m_list->getList())
{
if (!expandedPath.exists())
std::vector<FilePath> expandedPaths(1, path);
if (m_settings)
{
missingPaths.append(QString::fromStdWString(expandedPath.wstr() + L"\n"));
expandedPaths = m_settings->makePathsExpandedAndAbsolute(expandedPaths);
}
else
size_t existingCount = 0;
for (const FilePath& expandedPath : expandedPaths)
{
existingCount++;
if (!expandedPath.exists())
{
missingPaths.append(QString::fromStdWString(expandedPath.wstr() + L"\n"));
}
else
{
existingCount++;
}
}
if (!expandedPaths.empty() && expandedPaths.size() == existingCount)
{
existingPaths.push_back(path);
}
}
if (!expandedPaths.empty() && expandedPaths.size() == existingCount)
if (!missingPaths.isEmpty())
{
existingPaths.push_back(path);
QMessageBox msgBox;
msgBox.setText(
QString(
"Some provided paths do not exist at \"%1\". Do you want to remove them before continuing?"
).arg(m_titleString)
);
msgBox.setDetailedText(missingPaths);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes)
{
m_list->setList(existingPaths);
save();
}
else if (ret == QMessageBox::Cancel)
{
return false;
}
}
}
if (!missingPaths.isEmpty())
{
QMessageBox msgBox;
msgBox.setText(QString("Some provided paths do not exist at \"%1\". Do you want to remove them "
"before continuing?").arg(m_titleString));
msgBox.setDetailedText(missingPaths);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes)
{
m_list->setList(existingPaths);
save();
}
else if (ret == QMessageBox::Cancel)
{
return false;
}
}
return true;
}
@@ -217,7 +223,7 @@ std::vector<FilePath> QtProjectWizzardContentPathsSource::getFilePaths() const
FileManager fileManager;
fileManager.update(
m_settings->getSourcePathsExpandedAndAbsolute(),
m_settings->getExcludePathsExpandedAndAbsolute(),
m_settings->getExcludeFiltersExpandedAndAbsolute(),
m_settings->getSourceExtensions()
);
@@ -400,7 +406,7 @@ void QtProjectWizzardContentPathsCDBHeader::savedFilesDialog()
QtProjectWizzardContentPathsExclude::QtProjectWizzardContentPathsExclude(
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPaths(settings, window)
: QtProjectWizzardContentPaths(settings, window, false)
{
setTitleString("Excluded Files & Directories");
setHelpString(
@@ -412,12 +418,12 @@ QtProjectWizzardContentPathsExclude::QtProjectWizzardContentPathsExclude(
void QtProjectWizzardContentPathsExclude::load()
{
m_list->setList(m_settings->getExcludePaths());
m_list->setStringList(m_settings->getExcludeFilterStrings());
}
void QtProjectWizzardContentPathsExclude::save()
{
m_settings->setExcludePaths(m_list->getList());
m_settings->setExcludeFilterStrings(m_list->getStringList());
}
@@ -542,7 +548,7 @@ void QtProjectWizzardContentPathsHeaderSearch::validateIncludesButtonClicked()
FileManager fileManager;
fileManager.update(
m_settings->getSourcePathsExpandedAndAbsolute(),
m_settings->getExcludePathsExpandedAndAbsolute(),
m_settings->getExcludeFiltersExpandedAndAbsolute(),
m_settings->getSourceExtensions()
);
sourceFilePaths = fileManager.getAllSourceFilePaths();
@@ -605,7 +611,7 @@ void QtProjectWizzardContentPathsHeaderSearch::finishedSelectDetectIncludesRootP
FileManager fileManager;
fileManager.update(
m_settings->getSourcePathsExpandedAndAbsolute(),
m_settings->getExcludePathsExpandedAndAbsolute(),
m_settings->getExcludeFiltersExpandedAndAbsolute(),
m_settings->getSourceExtensions()
);
sourceFilePaths = fileManager.getAllSourceFilePaths();
@@ -24,7 +24,7 @@ signals:
void showSourceFiles();
public:
QtProjectWizzardContentPaths(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
QtProjectWizzardContentPaths(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window, bool checkMissingPaths = true);
// QtSettingsWindow implementation
virtual void populate(QGridLayout* layout, int& row) override;
@@ -50,6 +50,7 @@ private slots:
void detectionClicked();
private:
const bool m_checkMissingPaths;
QString m_titleString;
QString m_helpString;