Switched to asset gui using filesystemaccess constructor without path filtering

This commit is contained in:
GPayne
2021-09-19 20:46:53 -06:00
parent 5b69cf45f1
commit ea070fc1c4
4 changed files with 37 additions and 12 deletions
@@ -34,6 +34,22 @@ public:
*
* \param fileExtension string that defines the filter used to find files. Only
* files with this extension will be recognized (e.g. '.xml')
* \param hideFileExtensions if true then file extensions will be removed from the
* listed files in the output
* \param useCheckboxes if true then the text output format will contain a '0' as
* the first character in the line (this first character is
* used to represent checked ('1'), uncheck ('0') or doesn't
* exist in filesystem ('x') states.
*/
FileSystemAccess(std::string fileExtension, bool hideFileExtensions,
bool useCheckboxes);
/**
* Constructor for filesystemAccess class which will find files that are only in the
* provided approved paths
*
* \param fileExtension string that defines the filter used to find files. Only
* files with this extension will be recognized (e.g. '.xml')
* \param approvedPaths vector or strings containing directory names to be included
* in the search. These are directories at the base level of
* the starting point of the search. Any sub-directories within
@@ -67,6 +83,7 @@ private:
QFileSystemModel _filesystemModel;
QDir::Filters _fileFilterOptions = QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot;
std::string _fileExtension;
bool _useOnlyApprovedPaths = false;
std::vector<std::string> _approvedPaths;
bool _hideFileExtensions = true;
bool _useCheckboxes = false;
@@ -25,10 +25,18 @@
#include "filesystemaccess.h"
FileSystemAccess::FileSystemAccess(std::string fileExtension,
std::vector<std::string> approvedPaths,
bool hideFileExtensions, bool useCheckboxes)
: _fileExtension(std::move(fileExtension))
, _hideFileExtensions(hideFileExtensions)
, _useCheckboxes(useCheckboxes)
{}
FileSystemAccess::FileSystemAccess(std::string fileExtension,
std::vector<std::string> approvedPaths,
bool hideFileExtensions, bool useCheckboxes)
: _fileExtension(std::move(fileExtension))
, _approvedPaths(std::move(approvedPaths))
, _useOnlyApprovedPaths(true)
, _hideFileExtensions(hideFileExtensions)
, _useCheckboxes(useCheckboxes)
{}
@@ -78,16 +86,19 @@ void FileSystemAccess::parseChildDirElements(QFileInfo fileInfo, std::string spa
}
bool FileSystemAccess::isApprovedPath(std::string path) {
bool approvedMatch = false;
path.erase(0, path.find_first_not_of(" "));
for (const std::string& p : _approvedPaths) {
if (path.substr(0, p.length()).compare(p) == 0) {
approvedMatch = true;
break;
}
if (!_useOnlyApprovedPaths) {
return true;
}
else {
for (const std::string& p : _approvedPaths) {
if (path.substr(0, p.length()).compare(p) == 0) {
return true;
}
}
return false;
}
return approvedMatch;
}
void FileSystemAccess::parseChildFile(std::string filename, bool& hasDirHeaderBeenAdded,
@@ -149,9 +149,6 @@ void AssetTreeModel::importModelData(const std::string& assetBasePath,
const std::string& userAssetBasePath) {
FileSystemAccess assets(
".asset",
// @TODO (abock, 2021-03-24) We need some better solution for this; what is the
// problem of just including all subfolders instead?
{ "scene", "global", "customization", "dashboard", "examples", "util" },
true,
true
);