Sort HaldCLUT directories (fixes #4123)
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include "filmsimulation.h"
|
#include "filmsimulation.h"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@@ -56,8 +59,6 @@ bool notifySlowParseDir (const std::chrono::system_clock::time_point& startedAt)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::vector<Glib::ustring> Strings;
|
|
||||||
|
|
||||||
FilmSimulation::FilmSimulation()
|
FilmSimulation::FilmSimulation()
|
||||||
: FoldableToolPanel( this, "filmsimulation", M("TP_FILMSIMULATION_LABEL"), false, true )
|
: FoldableToolPanel( this, "filmsimulation", M("TP_FILMSIMULATION_LABEL"), false, true )
|
||||||
{
|
{
|
||||||
@@ -222,6 +223,21 @@ int ClutComboBox::parseDir (const Glib::ustring& path)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto sorted_dir_dirs = [](const Glib::ustring& path) -> std::map<std::string, std::string>
|
||||||
|
{
|
||||||
|
std::map<std::string, std::string> res;
|
||||||
|
|
||||||
|
for (const auto& dir : Glib::Dir(path)) {
|
||||||
|
const std::string full_path = Glib::build_filename(path, dir);
|
||||||
|
|
||||||
|
if (Glib::file_test(full_path, Glib::FILE_TEST_IS_DIR)) {
|
||||||
|
res.emplace(dir, full_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
const auto startedAt = std::chrono::system_clock::now();
|
const auto startedAt = std::chrono::system_clock::now();
|
||||||
|
|
||||||
// Build menu of limited directory structure using breadth-first search
|
// Build menu of limited directory structure using breadth-first search
|
||||||
@@ -235,25 +251,16 @@ int ClutComboBox::parseDir (const Glib::ustring& path)
|
|||||||
currDirs.emplace_back(path, Gtk::TreeModel::Row());
|
currDirs.emplace_back(path, Gtk::TreeModel::Row());
|
||||||
|
|
||||||
while (!currDirs.empty()) {
|
while (!currDirs.empty()) {
|
||||||
|
|
||||||
for (auto& dir : currDirs) {
|
for (auto& dir : currDirs) {
|
||||||
|
|
||||||
const auto& path = dir.first;
|
const auto& path = dir.first;
|
||||||
const auto& row = dir.second;
|
const auto& row = dir.second;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const auto& entry : Glib::Dir (path)) {
|
for (const auto& entry : sorted_dir_dirs(path)) {
|
||||||
|
|
||||||
const auto entryPath = Glib::build_filename (path, entry);
|
|
||||||
|
|
||||||
if (!Glib::file_test (entryPath, Glib::FILE_TEST_IS_DIR)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto newRow = row ? *m_model->append(row.children()) : *m_model->append();
|
auto newRow = row ? *m_model->append(row.children()) : *m_model->append();
|
||||||
newRow[m_columns.label] = entry;
|
newRow[m_columns.label] = entry.first;
|
||||||
|
|
||||||
nextDirs.emplace_back (entryPath, newRow);
|
nextDirs.emplace_back(entry.second, newRow);
|
||||||
}
|
}
|
||||||
} catch (Glib::Exception&) {}
|
} catch (Glib::Exception&) {}
|
||||||
|
|
||||||
@@ -271,12 +278,11 @@ int ClutComboBox::parseDir (const Glib::ustring& path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fill menu structure with CLUT files
|
// Fill menu structure with CLUT files
|
||||||
Strings entries;
|
std::set<Glib::ustring> entries;
|
||||||
|
|
||||||
auto fileCount = 0;
|
unsigned long fileCount = 0;
|
||||||
|
|
||||||
for (const auto& dir : dirs) {
|
for (const auto& dir : dirs) {
|
||||||
|
|
||||||
const auto& path = dir.first;
|
const auto& path = dir.first;
|
||||||
const auto& row = dir.second;
|
const auto& row = dir.second;
|
||||||
|
|
||||||
@@ -284,22 +290,20 @@ int ClutComboBox::parseDir (const Glib::ustring& path)
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
for (const auto& entry : Glib::Dir(path)) {
|
for (const auto& entry : Glib::Dir(path)) {
|
||||||
|
|
||||||
const auto entryPath = Glib::build_filename(path, entry);
|
const auto entryPath = Glib::build_filename(path, entry);
|
||||||
|
|
||||||
if (!Glib::file_test(entryPath, Glib::FILE_TEST_IS_REGULAR)) {
|
if (!Glib::file_test(entryPath, Glib::FILE_TEST_IS_REGULAR)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.push_back (entryPath);
|
entries.insert(entryPath);
|
||||||
}
|
}
|
||||||
} catch (Glib::Exception&) {}
|
} catch (Glib::Exception&) {}
|
||||||
|
|
||||||
std::sort (entries.begin (), entries.end ());
|
|
||||||
|
|
||||||
for (const auto& entry : entries) {
|
for (const auto& entry : entries) {
|
||||||
|
Glib::ustring name;
|
||||||
Glib::ustring name, extension, profileName;
|
Glib::ustring extension;
|
||||||
|
Glib::ustring profileName;
|
||||||
HaldCLUT::splitClutFilename (entry, name, extension, profileName);
|
HaldCLUT::splitClutFilename (entry, name, extension, profileName);
|
||||||
|
|
||||||
extension = extension.casefold();
|
extension = extension.casefold();
|
||||||
|
Reference in New Issue
Block a user