GUI: Rename methods in FileList and PathMatch
This commit is contained in:
parent
24bdd6d246
commit
c4bd70210c
|
@ -24,17 +24,17 @@
|
|||
#include "path.h"
|
||||
#include "pathmatch.h"
|
||||
|
||||
QStringList FileList::GetDefaultFilters()
|
||||
QStringList FileList::getDefaultFilters()
|
||||
{
|
||||
QStringList extensions;
|
||||
extensions << "*.cpp" << "*.cxx" << "*.cc" << "*.c" << "*.c++" << "*.txx" << "*.tpp";
|
||||
return extensions;
|
||||
}
|
||||
|
||||
bool FileList::FilterMatches(const QFileInfo &inf)
|
||||
bool FileList::filterMatches(const QFileInfo &inf)
|
||||
{
|
||||
if (inf.isFile()) {
|
||||
const QStringList filters = FileList::GetDefaultFilters();
|
||||
const QStringList filters = FileList::getDefaultFilters();
|
||||
QString ext("*.");
|
||||
ext += inf.suffix();
|
||||
if (filters.contains(ext, Qt::CaseInsensitive))
|
||||
|
@ -43,18 +43,18 @@ bool FileList::FilterMatches(const QFileInfo &inf)
|
|||
return false;
|
||||
}
|
||||
|
||||
void FileList::AddFile(const QString &filepath)
|
||||
void FileList::addFile(const QString &filepath)
|
||||
{
|
||||
QFileInfo inf(filepath);
|
||||
if (FilterMatches(inf))
|
||||
if (filterMatches(inf))
|
||||
mFileList << inf;
|
||||
}
|
||||
|
||||
void FileList::AddDirectory(const QString &directory, bool recursive)
|
||||
void FileList::addDirectory(const QString &directory, bool recursive)
|
||||
{
|
||||
QDir dir(directory);
|
||||
dir.setSorting(QDir::Name);
|
||||
const QStringList filters = FileList::GetDefaultFilters();
|
||||
const QStringList filters = FileList::getDefaultFilters();
|
||||
const QStringList origNameFilters = dir.nameFilters();
|
||||
dir.setNameFilters(filters);
|
||||
if (!recursive) {
|
||||
|
@ -72,24 +72,24 @@ void FileList::AddDirectory(const QString &directory, bool recursive)
|
|||
QFileInfo item;
|
||||
foreach (item, list) {
|
||||
const QString path = item.canonicalFilePath();
|
||||
AddDirectory(path, recursive);
|
||||
addDirectory(path, recursive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FileList::AddPathList(const QStringList &paths)
|
||||
void FileList::addPathList(const QStringList &paths)
|
||||
{
|
||||
QString path;
|
||||
foreach (path, paths) {
|
||||
QFileInfo inf(path);
|
||||
if (inf.isFile())
|
||||
AddFile(path);
|
||||
addFile(path);
|
||||
else
|
||||
AddDirectory(path, true);
|
||||
addDirectory(path, true);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList FileList::GetFileList() const
|
||||
QStringList FileList::getFileList() const
|
||||
{
|
||||
if (mExcludedPaths.empty()) {
|
||||
QStringList names;
|
||||
|
@ -99,11 +99,11 @@ QStringList FileList::GetFileList() const
|
|||
}
|
||||
return names;
|
||||
} else {
|
||||
return ApplyExcludeList();
|
||||
return applyExcludeList();
|
||||
}
|
||||
}
|
||||
|
||||
void FileList::AddExcludeList(const QStringList &paths)
|
||||
void FileList::addExcludeList(const QStringList &paths)
|
||||
{
|
||||
mExcludedPaths = paths;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ static std::vector<std::string> toStdStringList(const QStringList &stringList)
|
|||
return ret;
|
||||
}
|
||||
|
||||
QStringList FileList::ApplyExcludeList() const
|
||||
QStringList FileList::applyExcludeList() const
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const PathMatch pathMatch(toStdStringList(mExcludedPaths), true);
|
||||
|
@ -128,7 +128,7 @@ QStringList FileList::ApplyExcludeList() const
|
|||
QStringList paths;
|
||||
foreach (QFileInfo item, mFileList) {
|
||||
QString name = QDir::fromNativeSeparators(item.canonicalFilePath());
|
||||
if (!pathMatch.Match(name.toStdString()))
|
||||
if (!pathMatch.match(name.toStdString()))
|
||||
paths << name;
|
||||
}
|
||||
return paths;
|
||||
|
|
|
@ -41,38 +41,38 @@ public:
|
|||
* @brief Add filename to the list.
|
||||
* @param filepath Full path to the file.
|
||||
*/
|
||||
void AddFile(const QString &filepath);
|
||||
void addFile(const QString &filepath);
|
||||
|
||||
/**
|
||||
* @brief Add files in the directory to the list.
|
||||
* @param directory Full pathname to directory to add.
|
||||
* @param recursive If true also files in subdirectories are added.
|
||||
*/
|
||||
void AddDirectory(const QString &directory, bool recursive = false);
|
||||
void addDirectory(const QString &directory, bool recursive = false);
|
||||
|
||||
/**
|
||||
* @brief Add list of filenames and directories to the list.
|
||||
* @param paths List of paths to add.
|
||||
*/
|
||||
void AddPathList(const QStringList &paths);
|
||||
void addPathList(const QStringList &paths);
|
||||
|
||||
/**
|
||||
* @brief Return list of filenames (to check).
|
||||
* @return list of filenames to check.
|
||||
*/
|
||||
QStringList GetFileList() const;
|
||||
QStringList getFileList() const;
|
||||
|
||||
/**
|
||||
* @brief Add list of paths to exclusion list.
|
||||
* @param paths Paths to exclude.
|
||||
*/
|
||||
void AddExcludeList(const QStringList &paths);
|
||||
void addExcludeList(const QStringList &paths);
|
||||
|
||||
/**
|
||||
* @brief Return list of default filename extensions included.
|
||||
* @return list of default filename extensions included.
|
||||
*/
|
||||
static QStringList GetDefaultFilters();
|
||||
static QStringList getDefaultFilters();
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -80,7 +80,7 @@ protected:
|
|||
* @brief Test if filename matches the filename extensions filtering.
|
||||
* @return true if filename matches filtering.
|
||||
*/
|
||||
static bool FilterMatches(const QFileInfo &inf);
|
||||
static bool filterMatches(const QFileInfo &inf);
|
||||
|
||||
/**
|
||||
* @brief Get filtered list of paths.
|
||||
|
@ -89,7 +89,7 @@ protected:
|
|||
* exclude filters.
|
||||
* @return Filtered list of paths.
|
||||
*/
|
||||
QStringList ApplyExcludeList() const;
|
||||
QStringList applyExcludeList() const;
|
||||
|
||||
private:
|
||||
QFileInfoList mFileList;
|
||||
|
|
|
@ -407,13 +407,13 @@ void MainWindow::doCheckFiles(const QStringList &files)
|
|||
|
||||
mIsLogfileLoaded = false;
|
||||
FileList pathList;
|
||||
pathList.AddPathList(files);
|
||||
pathList.addPathList(files);
|
||||
if (mProject) {
|
||||
pathList.AddExcludeList(mProject->getProjectFile()->getExcludedPaths());
|
||||
pathList.addExcludeList(mProject->getProjectFile()->getExcludedPaths());
|
||||
} else {
|
||||
enableProjectActions(false);
|
||||
}
|
||||
QStringList fileNames = pathList.GetFileList();
|
||||
QStringList fileNames = pathList.getFileList();
|
||||
|
||||
mUI.mResults->Clear(true);
|
||||
mThread->ClearFiles();
|
||||
|
@ -503,7 +503,7 @@ QStringList MainWindow::selectFilesToCheck(QFileDialog::FileMode mode)
|
|||
tr("Select files to check"),
|
||||
GetPath(SETTINGS_LAST_CHECK_PATH),
|
||||
tr("C/C++ Source, Compile database, Visual Studio (%1 %2 *.sln *.vcxproj)")
|
||||
.arg(FileList::GetDefaultFilters().join(" "))
|
||||
.arg(FileList::getDefaultFilters().join(" "))
|
||||
.arg(compile_commands_json));
|
||||
if (selected.isEmpty())
|
||||
mCurrentDirectory.clear();
|
||||
|
@ -931,10 +931,10 @@ void MainWindow::reCheckSelected(QStringList files, bool all)
|
|||
|
||||
mCurrentDirectory = mUI.mResults->GetCheckDirectory();
|
||||
FileList pathList;
|
||||
pathList.AddPathList(files);
|
||||
pathList.addPathList(files);
|
||||
if (mProject)
|
||||
pathList.AddExcludeList(mProject->getProjectFile()->getExcludedPaths());
|
||||
QStringList fileNames = pathList.GetFileList();
|
||||
pathList.addExcludeList(mProject->getProjectFile()->getExcludedPaths());
|
||||
QStringList fileNames = pathList.getFileList();
|
||||
checkLockDownUI(); // lock UI while checking
|
||||
mUI.mResults->CheckingStarted(fileNames.size());
|
||||
mThread->SetCheckFiles(fileNames);
|
||||
|
|
|
@ -34,7 +34,7 @@ PathMatch::PathMatch(const std::vector<std::string> &excludedPaths, bool caseSen
|
|||
_workingDirectory.push_back(Path::getCurrentPath());
|
||||
}
|
||||
|
||||
bool PathMatch::Match(const std::string &path) const
|
||||
bool PathMatch::match(const std::string &path) const
|
||||
{
|
||||
if (path.empty())
|
||||
return false;
|
||||
|
@ -49,7 +49,7 @@ bool PathMatch::Match(const std::string &path) const
|
|||
// Filtering directory name
|
||||
if (endsWith(excludedPath,'/')) {
|
||||
if (!endsWith(findpath,'/'))
|
||||
findpath = RemoveFilename(findpath);
|
||||
findpath = removeFilename(findpath);
|
||||
|
||||
if (excludedPath.length() > findpath.length())
|
||||
continue;
|
||||
|
@ -78,7 +78,7 @@ bool PathMatch::Match(const std::string &path) const
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string PathMatch::RemoveFilename(const std::string &path)
|
||||
std::string PathMatch::removeFilename(const std::string &path)
|
||||
{
|
||||
const std::size_t ind = path.find_last_of('/');
|
||||
return path.substr(0, ind + 1);
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
* @param path Path to match.
|
||||
* @return true if any of the masks match the path, false otherwise.
|
||||
*/
|
||||
bool Match(const std::string &path) const;
|
||||
bool match(const std::string &path) const;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -55,7 +55,7 @@ protected:
|
|||
* @param path Path to edit.
|
||||
* @return path without filename part.
|
||||
*/
|
||||
static std::string RemoveFilename(const std::string &path);
|
||||
static std::string removeFilename(const std::string &path);
|
||||
|
||||
private:
|
||||
std::vector<std::string> _excludedPaths;
|
||||
|
|
Loading…
Reference in New Issue