From c13a48190d3cb264f927a3038dd71870fecc9a22 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Sun, 3 Feb 2019 15:33:30 -0500 Subject: [PATCH] Sub-folder sorting Patches were sorted correctly as were categories, but in order to enable sub-folders I construct an explicit child list in categories. I do that before the patch sort and traverse it at menu build time. That category list requires a sort to display correctly. Fixes #481 --- src/common/SurgeStorage.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/common/SurgeStorage.cpp b/src/common/SurgeStorage.cpp index 62d9fece15e..57d22ad41db 100644 --- a/src/common/SurgeStorage.cpp +++ b/src/common/SurgeStorage.cpp @@ -350,6 +350,7 @@ void SurgeStorage::refreshPatchlistAddDir(bool userDir, string subdir) ** scanning for names; setting the 'root' to everything without a slash ** and finding the parent in the name map for everything with a slash */ + std::map nameToLocalIndex; int idx=0; for (auto &pc : local_patch_category) @@ -368,6 +369,23 @@ void SurgeStorage::refreshPatchlistAddDir(bool userDir, string subdir) } } + /* + ** We need to sort the local patch category child to make sure subfolders remain + ** sorted when displayed using the child data structure in the menu view. + */ + + auto catCompare = + [this](const PatchCategory &c1, const PatchCategory &c2) -> bool + { + return _stricmp(c1.name.c_str(),c2.name.c_str()) < 0; + }; + for (auto &pc : local_patch_category) + { + std::sort(pc.children.begin(), pc.children.end(), catCompare); + } + + + /* ** Then copy our local patch category onto the member and be done */