Fixed an issue where detection of folder-only views was not working.

This commit is contained in:
Leon Styhre 2020-08-07 23:33:05 +02:00
parent 15ea7a9acd
commit 3ca9f5478a
2 changed files with 14 additions and 6 deletions

View file

@ -428,7 +428,7 @@ void FileData::removeChild(FileData* file)
void FileData::sort(ComparisonFunction& comparator, bool ascending) void FileData::sort(ComparisonFunction& comparator, bool ascending)
{ {
mFirstLetterIndex.clear(); mFirstLetterIndex.clear();
mOnlyFolders = false; mOnlyFolders = true;
bool foldersOnTop = Settings::getInstance()->getBool("FoldersOnTop"); bool foldersOnTop = Settings::getInstance()->getBool("FoldersOnTop");
std::vector<FileData*> mChildrenFolders; std::vector<FileData*> mChildrenFolders;
std::vector<FileData*> mChildrenOthers; std::vector<FileData*> mChildrenOthers;
@ -478,6 +478,9 @@ void FileData::sort(ComparisonFunction& comparator, bool ascending)
} }
for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++) { for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++) {
if ((*it)->getType() != FOLDER)
mOnlyFolders = false;
if (!(foldersOnTop && (*it)->getType() == FOLDER)) { if (!(foldersOnTop && (*it)->getType() == FOLDER)) {
// Build mFirstLetterIndex. // Build mFirstLetterIndex.
const char firstChar = toupper((*it)->getSortName().front()); const char firstChar = toupper((*it)->getSortName().front());
@ -490,7 +493,7 @@ void FileData::sort(ComparisonFunction& comparator, bool ascending)
// If there are only folders in the gamelist, then it makes sense to still // If there are only folders in the gamelist, then it makes sense to still
// generate a letter index. // generate a letter index.
if (mChildrenOthers.size() == 0 && mChildrenFolders.size() > 0) { if (mOnlyFolders) {
for (unsigned int i = 0; i < mChildrenFolders.size(); i++) { for (unsigned int i = 0; i < mChildrenFolders.size(); i++) {
const char firstChar = toupper(mChildrenFolders[i]->getSortName().front()); const char firstChar = toupper(mChildrenFolders[i]->getSortName().front());
mFirstLetterIndex.push_back(std::string(1, firstChar)); mFirstLetterIndex.push_back(std::string(1, firstChar));
@ -507,7 +510,7 @@ void FileData::sort(ComparisonFunction& comparator, bool ascending)
void FileData::sortFavoritesOnTop(ComparisonFunction& comparator, bool ascending) void FileData::sortFavoritesOnTop(ComparisonFunction& comparator, bool ascending)
{ {
mFirstLetterIndex.clear(); mFirstLetterIndex.clear();
mOnlyFolders = false; mOnlyFolders = true;
std::vector<FileData*> mChildrenFolders; std::vector<FileData*> mChildrenFolders;
std::vector<FileData*> mChildrenFavorites; std::vector<FileData*> mChildrenFavorites;
std::vector<FileData*> mChildrenOthers; std::vector<FileData*> mChildrenOthers;
@ -534,6 +537,9 @@ void FileData::sortFavoritesOnTop(ComparisonFunction& comparator, bool ascending
const char firstChar = toupper(mChildren[i]->getSortName().front()); const char firstChar = toupper(mChildren[i]->getSortName().front());
mFirstLetterIndex.push_back(std::string(1, firstChar)); mFirstLetterIndex.push_back(std::string(1, firstChar));
} }
if (mChildren[i]->getType() != FOLDER)
mOnlyFolders = false;
} }
// If there are only favorites in the gamelist, it makes sense to still generate // If there are only favorites in the gamelist, it makes sense to still generate
@ -553,13 +559,11 @@ void FileData::sortFavoritesOnTop(ComparisonFunction& comparator, bool ascending
} }
// If there are only folders in the gamelist, then it also makes sense to generate // If there are only folders in the gamelist, then it also makes sense to generate
// a letter index. // a letter index.
else if (mChildrenOthers.size() == 0 && mChildrenFavorites.size() == 0 && else if (mOnlyFolders) {
mChildrenFolders.size() > 0) {
for (unsigned int i = 0; i < mChildrenFolders.size(); i++) { for (unsigned int i = 0; i < mChildrenFolders.size(); i++) {
const char firstChar = toupper(mChildrenFolders[i]->getSortName().front()); const char firstChar = toupper(mChildrenFolders[i]->getSortName().front());
mFirstLetterIndex.push_back(std::string(1, firstChar)); mFirstLetterIndex.push_back(std::string(1, firstChar));
} }
mOnlyFolders = true;
} }
// Sort and make each entry unique in mFirstLetterIndex. // Sort and make each entry unique in mFirstLetterIndex.

View file

@ -403,6 +403,10 @@ void GuiMetaDataEd::fetchDone(const ScraperSearchResult& result)
mMediaFilesUpdated = result.savedNewMedia; mMediaFilesUpdated = result.savedNewMedia;
// Curently disabled as I'm not sure if this is more annoying than helpful.
// // Select the Save button.
// mButtons->moveCursor(Vector2i(1, 0));
// Check if any values were manually changed before starting the scraping. // Check if any values were manually changed before starting the scraping.
// If so, it's these values we should compare against when scraping, not // If so, it's these values we should compare against when scraping, not
// the values previously saved for the game. // the values previously saved for the game.