mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-07 20:21:24 -06:00
Merge pull request #1750 from OpenSpace/issue/1739
Fix for issue #1739 to prevent filtering of paths in asset directories in profile editor
This commit is contained in:
@@ -34,10 +34,6 @@ public:
|
||||
*
|
||||
* \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
|
||||
* these directories will be included.
|
||||
* \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
|
||||
@@ -45,8 +41,7 @@ public:
|
||||
* used to represent checked ('1'), uncheck ('0') or doesn't
|
||||
* exist in filesystem ('x') states.
|
||||
*/
|
||||
FileSystemAccess(std::string fileExtension,
|
||||
std::vector<std::string> approvedPaths, bool hideFileExtensions,
|
||||
FileSystemAccess(std::string fileExtension, bool hideFileExtensions,
|
||||
bool useCheckboxes);
|
||||
|
||||
/**
|
||||
@@ -54,7 +49,8 @@ public:
|
||||
*
|
||||
* \param dir The directory from which to start the search from
|
||||
*/
|
||||
std::string useQtFileSystemModelToTraverseDir(std::string dir, bool usersAssets = false);
|
||||
std::string useQtFileSystemModelToTraverseDir(std::string dir,
|
||||
bool usersAssets = false);
|
||||
|
||||
private:
|
||||
void parseChildDirElements(QFileInfo item, std::string space, int level,
|
||||
@@ -62,7 +58,6 @@ private:
|
||||
bool userAssets);
|
||||
void parseChildFile(std::string res, bool& hasDirHeaderBeenAdded,
|
||||
std::vector<std::string>& dirNames, std::vector<std::string>& output);
|
||||
bool isApprovedPath(std::string path);
|
||||
|
||||
QFileSystemModel _filesystemModel;
|
||||
QDir::Filters _fileFilterOptions = QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot;
|
||||
|
||||
@@ -25,15 +25,14 @@
|
||||
#include "filesystemaccess.h"
|
||||
|
||||
FileSystemAccess::FileSystemAccess(std::string fileExtension,
|
||||
std::vector<std::string> approvedPaths,
|
||||
bool hideFileExtensions, bool useCheckboxes)
|
||||
: _fileExtension(std::move(fileExtension))
|
||||
, _approvedPaths(std::move(approvedPaths))
|
||||
, _hideFileExtensions(hideFileExtensions)
|
||||
, _useCheckboxes(useCheckboxes)
|
||||
{}
|
||||
|
||||
std::string FileSystemAccess::useQtFileSystemModelToTraverseDir(std::string dir, bool userAssets) {
|
||||
std::string FileSystemAccess::useQtFileSystemModelToTraverseDir(std::string dir,
|
||||
bool userAssets) {
|
||||
_filesystemModel.setRootPath(QString::fromStdString(dir));
|
||||
QModelIndex index = _filesystemModel.index(_filesystemModel.rootPath());
|
||||
QFileInfo fileInfo = _filesystemModel.fileInfo(index);
|
||||
@@ -48,8 +47,10 @@ std::string FileSystemAccess::useQtFileSystemModelToTraverseDir(std::string dir,
|
||||
}
|
||||
|
||||
void FileSystemAccess::parseChildDirElements(QFileInfo fileInfo, std::string space,
|
||||
int level, std::vector<std::string>& dirNames,
|
||||
std::vector<std::string>& output, bool userAssets)
|
||||
int level,
|
||||
std::vector<std::string>& dirNames,
|
||||
std::vector<std::string>& output,
|
||||
bool userAssets)
|
||||
{
|
||||
QDir dir(fileInfo.filePath());
|
||||
bool hasDirHeaderBeenAdded = false;
|
||||
@@ -62,10 +63,8 @@ void FileSystemAccess::parseChildDirElements(QFileInfo fileInfo, std::string spa
|
||||
res = "${USER_ASSETS}/" + res;
|
||||
}
|
||||
if (fi.isDir()) {
|
||||
if (level != 0 || (level == 0 && (isApprovedPath(res) || userAssets))) {
|
||||
dirNames.push_back(res);
|
||||
parseChildDirElements(fi, (space + " "), level + 1, dirNames, output, userAssets);
|
||||
}
|
||||
dirNames.push_back(res);
|
||||
parseChildDirElements(fi, (space + " "), level + 1, dirNames, output, userAssets);
|
||||
}
|
||||
else {
|
||||
parseChildFile(res, hasDirHeaderBeenAdded, dirNames, output);
|
||||
@@ -77,19 +76,6 @@ 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;
|
||||
}
|
||||
}
|
||||
return approvedMatch;
|
||||
}
|
||||
|
||||
void FileSystemAccess::parseChildFile(std::string filename, bool& hasDirHeaderBeenAdded,
|
||||
std::vector<std::string>& dirNames,
|
||||
std::vector<std::string>& output)
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user