sort file lists before showing user. closes #1559 (#1943)

This commit is contained in:
Micah Acinapura
2022-03-24 10:24:12 -04:00
committed by GitHub
parent 594d512845
commit 7c7a6e5cff
2 changed files with 31 additions and 6 deletions
@@ -354,13 +354,18 @@ void LauncherWindow::populateProfilesList(std::string preset) {
++_userAssetCount;
// Add all the files with the .profile extension to the dropdown
std::vector<fs::directory_entry> profiles;
for (const fs::directory_entry& p : fs::directory_iterator(_userProfilePath)) {
if (p.path().extension() != ".profile") {
continue;
}
_profileBox->addItem(QString::fromStdString(p.path().stem().string()));
profiles.push_back(p);
++_userAssetCount;
}
std::sort(profiles.begin(), profiles.end());
for (const fs::directory_entry& p : profiles) {
_profileBox->addItem(QString::fromStdString(p.path().stem().string()));
}
_profileBox->addItem(QString::fromStdString("--- OpenSpace Profiles ---"));
model = qobject_cast<const QStandardItemModel*>(_profileBox->model());
@@ -368,11 +373,17 @@ void LauncherWindow::populateProfilesList(std::string preset) {
++_userAssetCount;
// Add all the files with the .profile extension to the dropdown
for (const fs::directory_entry& p : fs::directory_iterator(_profilePath)) {
if (p.path().extension() != ".profile") {
profiles.clear();
for (const fs::directory_entry& path : fs::directory_iterator(_profilePath)) {
if (path.path().extension() != ".profile") {
continue;
}
_profileBox->addItem(QString::fromStdString(p.path().stem().string()));
profiles.push_back(path);
}
std::sort(profiles.begin(), profiles.end());
//add sorted items to list
for (const fs::directory_entry& profile : profiles) {
_profileBox->addItem(QString::fromStdString(profile.path().stem().string()));
}
// Try to find the requested profile and set it as the current one
@@ -414,8 +425,15 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) {
bool hasXmlConfig = false;
// Add all the files with the .xml or .json extension to the dropdown
//sort files
std::vector<fs::directory_entry> files;
for (const fs::directory_entry& p : fs::directory_iterator(_userConfigPath)) {
files.push_back(p);
}
std::sort(files.begin(), files.end());
// Add all the files with the .xml or .json extension to the dropdown
for (const fs::directory_entry& p : files) {
bool isConfigFile = handleConfigurationFile(*_windowConfigBox, p);
if (isConfigFile) {
++_userConfigCount;
@@ -428,8 +446,14 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) {
model->item(_userConfigCount)->setEnabled(false);
if (std::filesystem::exists(_configPath)) {
// Add all the files with the .xml or .json extension to the dropdown
//sort files
files.clear();
for (const fs::directory_entry& p : fs::directory_iterator(_configPath)) {
files.push_back(p);
}
std::sort(files.begin(), files.end());
// Add all the files with the .xml or .json extension to the dropdown
for (const fs::directory_entry& p : files) {
handleConfigurationFile(*_windowConfigBox, p);
hasXmlConfig |= p.path().extension() == ".xml";
}
+1
View File
@@ -2155,6 +2155,7 @@ std::vector<std::string> SessionRecording::playbackList() const {
}
}
}
std::sort(fileList.begin(), fileList.end());
return fileList;
}