mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
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.
This commit is contained in:
parent
df9e2ea7e1
commit
23deb889b9
@ -745,33 +745,27 @@ void DBHelper::propagateFolderUpdatesToParent(const Folder &folder, QSqlDatabase
|
|||||||
Folder DBHelper::updateChildrenInfo(qulonglong folderId, QSqlDatabase &db)
|
Folder DBHelper::updateChildrenInfo(qulonglong folderId, QSqlDatabase &db)
|
||||||
{
|
{
|
||||||
auto folder = loadFolder(folderId, db);
|
auto folder = loadFolder(folderId, db);
|
||||||
QList<LibraryItem *> subitems;
|
QList<LibraryItem *> subfolders = DBHelper::getFoldersFromParent(folderId, db, true);
|
||||||
QList<LibraryItem *> subfolders = DBHelper::getFoldersFromParent(folderId, db, false);
|
QList<LibraryItem *> comics = DBHelper::getComicsFromParent(folderId, db, true);
|
||||||
QList<LibraryItem *> comics = DBHelper::getComicsFromParent(folderId, db, false);
|
|
||||||
|
|
||||||
QList<LibraryItem *> updatedSubfolders;
|
QList<LibraryItem *> updatedSubfolders;
|
||||||
for (auto sf : subfolders) {
|
for (auto sf : subfolders) {
|
||||||
updatedSubfolders.append(new Folder(updateChildrenInfo(static_cast<Folder *>(sf)->id, db)));
|
updatedSubfolders.append(new Folder(updateChildrenInfo(static_cast<Folder *>(sf)->id, db)));
|
||||||
}
|
}
|
||||||
|
|
||||||
subitems.append(updatedSubfolders);
|
|
||||||
subitems.append(comics);
|
|
||||||
|
|
||||||
std::sort(subitems.begin(), subitems.end(), naturalSortLessThanCILibraryItem);
|
|
||||||
|
|
||||||
QString coverHash = "";
|
QString coverHash = "";
|
||||||
for (auto item : subitems) {
|
|
||||||
if (item->isDir()) {
|
if (!comics.isEmpty()) {
|
||||||
|
auto c = static_cast<ComicDB *>(comics[0]);
|
||||||
|
coverHash = c->info.hash;
|
||||||
|
} else {
|
||||||
|
for (auto item : subfolders) {
|
||||||
auto f = static_cast<Folder *>(item);
|
auto f = static_cast<Folder *>(item);
|
||||||
auto firstChildHash = f->getFirstChildHash();
|
auto firstChildHash = f->getFirstChildHash();
|
||||||
if (!firstChildHash.isEmpty()) {
|
if (!firstChildHash.isEmpty()) {
|
||||||
coverHash = firstChildHash;
|
coverHash = firstChildHash;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
auto c = static_cast<ComicDB *>(item);
|
|
||||||
coverHash = c->info.hash;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user