mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Add a flag to getReadingListFullContent so it can load all the fields
This commit is contained in:
parent
7bb450408c
commit
f9285bd099
@ -359,7 +359,7 @@ QList<ReadingList> DBHelper::getReadingLists(qulonglong libraryId)
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ComicDB> DBHelper::getReadingListFullContent(qulonglong libraryId, qulonglong readingListId)
|
QList<ComicDB> DBHelper::getReadingListFullContent(qulonglong libraryId, qulonglong readingListId, bool getFullComicInfoFields)
|
||||||
{
|
{
|
||||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||||
QList<ComicDB> list;
|
QList<ComicDB> list;
|
||||||
@ -382,26 +382,52 @@ QList<ComicDB> DBHelper::getReadingListFullContent(qulonglong libraryId, qulongl
|
|||||||
|
|
||||||
foreach (qulonglong id, ids) {
|
foreach (qulonglong id, ids) {
|
||||||
QSqlQuery selectQuery(db);
|
QSqlQuery selectQuery(db);
|
||||||
selectQuery.prepare("SELECT c.id,c.parentId,c.fileName,ci.title,ci.currentPage,ci.numPages,ci.hash,ci.read,ci.coverSizeRatio "
|
|
||||||
"FROM comic c INNER JOIN comic_info ci ON (c.comicInfoId = ci.id) "
|
QString params;
|
||||||
"INNER JOIN comic_reading_list crl ON (c.id == crl.comic_id) "
|
if (getFullComicInfoFields) {
|
||||||
"WHERE crl.reading_list_id = :parentReadingList "
|
params = "*";
|
||||||
"ORDER BY crl.ordering");
|
} else {
|
||||||
|
params = "c.id,c.parentId,c.fileName,c.path,ci.title,ci.currentPage,ci.numPages,ci.hash,ci.read,ci.coverSizeRatio";
|
||||||
|
}
|
||||||
|
|
||||||
|
selectQuery.prepare("SELECT " + params + " "
|
||||||
|
"FROM comic c INNER JOIN comic_info ci ON (c.comicInfoId = ci.id) "
|
||||||
|
"INNER JOIN comic_reading_list crl ON (c.id == crl.comic_id) "
|
||||||
|
"WHERE crl.reading_list_id = :parentReadingList "
|
||||||
|
"ORDER BY crl.ordering");
|
||||||
selectQuery.bindValue(":parentReadingList", id);
|
selectQuery.bindValue(":parentReadingList", id);
|
||||||
selectQuery.exec();
|
selectQuery.exec();
|
||||||
|
|
||||||
|
auto record = selectQuery.record();
|
||||||
|
|
||||||
|
int idComicIndex = record.indexOf("id");
|
||||||
|
int parentIdIndex = record.indexOf("parentId");
|
||||||
|
int fileName = record.indexOf("fileName");
|
||||||
|
int path = record.indexOf("path");
|
||||||
|
|
||||||
while (selectQuery.next()) {
|
while (selectQuery.next()) {
|
||||||
ComicDB comic;
|
ComicDB comic;
|
||||||
|
|
||||||
comic.id = selectQuery.value(0).toULongLong();
|
if (getFullComicInfoFields) {
|
||||||
comic.parentId = selectQuery.value(1).toULongLong();
|
comic.id = selectQuery.value(idComicIndex).toULongLong();
|
||||||
comic.name = selectQuery.value(2).toString();
|
comic.parentId = selectQuery.value(parentIdIndex).toULongLong();
|
||||||
comic.info.title = selectQuery.value(3).toString();
|
comic.name = selectQuery.value(fileName).toString();
|
||||||
comic.info.currentPage = selectQuery.value(4).toInt();
|
comic.path = selectQuery.value(path).toString();
|
||||||
comic.info.numPages = selectQuery.value(5).toInt();
|
|
||||||
comic.info.hash = selectQuery.value(6).toString();
|
comic.info = getComicInfoFromQuery(selectQuery, "comicInfoId");
|
||||||
comic.info.read = selectQuery.value(7).toBool();
|
} else {
|
||||||
comic.info.coverSizeRatio = selectQuery.value(8).toFloat();
|
comic.id = selectQuery.value(0).toULongLong();
|
||||||
|
comic.parentId = selectQuery.value(1).toULongLong();
|
||||||
|
comic.name = selectQuery.value(2).toString();
|
||||||
|
comic.path = selectQuery.value(3).toString();
|
||||||
|
|
||||||
|
comic.info.title = selectQuery.value(4).toString();
|
||||||
|
comic.info.currentPage = selectQuery.value(5).toInt();
|
||||||
|
comic.info.numPages = selectQuery.value(6).toInt();
|
||||||
|
comic.info.hash = selectQuery.value(7).toString();
|
||||||
|
comic.info.read = selectQuery.value(8).toBool();
|
||||||
|
comic.info.coverSizeRatio = selectQuery.value(9).toFloat();
|
||||||
|
}
|
||||||
|
|
||||||
list.append(comic);
|
list.append(comic);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
static QList<ComicDB> getFavorites(qulonglong libraryId);
|
static QList<ComicDB> getFavorites(qulonglong libraryId);
|
||||||
static QList<ComicDB> getReading(qulonglong libraryId);
|
static QList<ComicDB> getReading(qulonglong libraryId);
|
||||||
static QList<ReadingList> getReadingLists(qulonglong libraryId);
|
static QList<ReadingList> getReadingLists(qulonglong libraryId);
|
||||||
static QList<ComicDB> getReadingListFullContent(qulonglong libraryId, qulonglong readingListId);
|
static QList<ComicDB> getReadingListFullContent(qulonglong libraryId, qulonglong readingListId, bool getFullComicInfoFields = false);
|
||||||
|
|
||||||
//objects management
|
//objects management
|
||||||
//deletes
|
//deletes
|
||||||
|
Loading…
Reference in New Issue
Block a user