mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Add function to get comics from a folder properly sorted
This commit is contained in:
parent
e71e97f2fe
commit
811c3fcfe4
@ -33,6 +33,7 @@ YACReaderLibraries DBHelper::getLibraries()
|
|||||||
libraries.load();
|
libraries.load();
|
||||||
return libraries;
|
return libraries;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<LibraryItem *> DBHelper::getFolderSubfoldersFromLibrary(qulonglong libraryId, qulonglong folderId)
|
QList<LibraryItem *> DBHelper::getFolderSubfoldersFromLibrary(qulonglong libraryId, qulonglong folderId)
|
||||||
{
|
{
|
||||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||||
@ -47,11 +48,34 @@ QList<LibraryItem *> DBHelper::getFolderSubfoldersFromLibrary(qulonglong library
|
|||||||
QSqlDatabase::removeDatabase(connectionName);
|
QSqlDatabase::removeDatabase(connectionName);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<LibraryItem *> DBHelper::getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId)
|
QList<LibraryItem *> DBHelper::getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId)
|
||||||
{
|
{
|
||||||
return DBHelper::getFolderComicsFromLibrary(libraryId, folderId, false);
|
return DBHelper::getFolderComicsFromLibrary(libraryId, folderId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<LibraryItem *> DBHelper::getFolderComicsFromLibraryForReading(qulonglong libraryId, qulonglong folderId)
|
||||||
|
{
|
||||||
|
auto list = DBHelper::getFolderComicsFromLibrary(libraryId, folderId, false);
|
||||||
|
|
||||||
|
std::sort(list.begin(), list.end(), [](LibraryItem *i1, LibraryItem *i2) {
|
||||||
|
auto c1 = static_cast<ComicDB *>(i1);
|
||||||
|
auto c2 = static_cast<ComicDB *>(i2);
|
||||||
|
|
||||||
|
if (c1->info.number.isNull() && c2->info.number.isNull()) {
|
||||||
|
return naturalSortLessThanCI(c1->name, c2->name);
|
||||||
|
} else {
|
||||||
|
if (c1->info.number.isNull() == false && c2->info.number.isNull() == false) {
|
||||||
|
return c1->info.number.toInt() < c2->info.number.toInt();
|
||||||
|
} else {
|
||||||
|
return c2->info.number.isNull();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
QList<LibraryItem *> DBHelper::getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId, bool sort)
|
QList<LibraryItem *> DBHelper::getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId, bool sort)
|
||||||
{
|
{
|
||||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||||
|
@ -25,6 +25,7 @@ public:
|
|||||||
static QList<LibraryItem *> getFolderSubfoldersFromLibrary(qulonglong libraryId, qulonglong folderId);
|
static QList<LibraryItem *> getFolderSubfoldersFromLibrary(qulonglong libraryId, qulonglong folderId);
|
||||||
static QList<LibraryItem *> getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId);
|
static QList<LibraryItem *> getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId);
|
||||||
static QList<LibraryItem *> getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId, bool sort);
|
static QList<LibraryItem *> getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId, bool sort);
|
||||||
|
static QList<LibraryItem *> getFolderComicsFromLibraryForReading(qulonglong libraryId, qulonglong folderId);
|
||||||
static quint32 getNumChildrenFromFolder(qulonglong libraryId, qulonglong folderId);
|
static quint32 getNumChildrenFromFolder(qulonglong libraryId, qulonglong folderId);
|
||||||
static qulonglong getParentFromComicFolderId(qulonglong libraryId, qulonglong id);
|
static qulonglong getParentFromComicFolderId(qulonglong libraryId, qulonglong id);
|
||||||
static ComicDB getComicInfo(qulonglong libraryId, qulonglong id);
|
static ComicDB getComicInfo(qulonglong libraryId, qulonglong id);
|
||||||
|
Loading…
Reference in New Issue
Block a user