From 23deb889b90a3b9f77ed5ab1f26d8f1aa5e0eb4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20A=CC=81ngel=20San=20Marti=CC=81n=20Rodri=CC=81guez?= Date: Wed, 12 Oct 2022 22:17:22 +0200 Subject: [PATCH] Use always the first comic as the cover of a folder There is no way to show comics and folders together in YACReaderLibrary yet, so it looks confusing to use the cover from a sub-folder. --- YACReaderLibrary/db_helper.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/YACReaderLibrary/db_helper.cpp b/YACReaderLibrary/db_helper.cpp index 1323abad..d7f77c26 100644 --- a/YACReaderLibrary/db_helper.cpp +++ b/YACReaderLibrary/db_helper.cpp @@ -745,33 +745,27 @@ void DBHelper::propagateFolderUpdatesToParent(const Folder &folder, QSqlDatabase Folder DBHelper::updateChildrenInfo(qulonglong folderId, QSqlDatabase &db) { auto folder = loadFolder(folderId, db); - QList subitems; - QList subfolders = DBHelper::getFoldersFromParent(folderId, db, false); - QList comics = DBHelper::getComicsFromParent(folderId, db, false); + QList subfolders = DBHelper::getFoldersFromParent(folderId, db, true); + QList comics = DBHelper::getComicsFromParent(folderId, db, true); QList updatedSubfolders; for (auto sf : subfolders) { updatedSubfolders.append(new Folder(updateChildrenInfo(static_cast(sf)->id, db))); } - subitems.append(updatedSubfolders); - subitems.append(comics); - - std::sort(subitems.begin(), subitems.end(), naturalSortLessThanCILibraryItem); - QString coverHash = ""; - for (auto item : subitems) { - if (item->isDir()) { + + if (!comics.isEmpty()) { + auto c = static_cast(comics[0]); + coverHash = c->info.hash; + } else { + for (auto item : subfolders) { auto f = static_cast(item); auto firstChildHash = f->getFirstChildHash(); if (!firstChildHash.isEmpty()) { coverHash = firstChildHash; break; } - } else { - auto c = static_cast(item); - coverHash = c->info.hash; - break; } }