mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
added a new db helper method for knowing the number of elements in a folder
This commit is contained in:
parent
1009b84363
commit
e9210bb366
@ -58,6 +58,38 @@ QList<LibraryItem *> DBHelper::getFolderComicsFromLibrary(qulonglong libraryId,
|
||||
QSqlDatabase::removeDatabase(libraryPath);
|
||||
return list;
|
||||
}
|
||||
|
||||
quint32 DBHelper::getNumChildrenFromFolder(qulonglong libraryId, qulonglong folderId)
|
||||
{
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||
|
||||
quint32 result = 0;
|
||||
|
||||
{
|
||||
QSqlQuery selectQuery(db);
|
||||
selectQuery.prepare("SELECT count(*) FROM folder WHERE parentId = :parentId and id <> 1");
|
||||
selectQuery.bindValue(":parentId", folderId);
|
||||
selectQuery.exec();
|
||||
|
||||
result += selectQuery.record().value(0).toULongLong();
|
||||
}
|
||||
|
||||
{
|
||||
QSqlQuery selectQuery(db);
|
||||
selectQuery.prepare("SELECT count(*) FROM comic c WHERE c.parentId = :parentId");
|
||||
selectQuery.bindValue(":parentId", folderId);
|
||||
selectQuery.exec();
|
||||
|
||||
result += selectQuery.record().value(0).toULongLong();
|
||||
}
|
||||
|
||||
db.close();
|
||||
QSqlDatabase::removeDatabase(libraryPath);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
qulonglong DBHelper::getParentFromComicFolderId(qulonglong libraryId, qulonglong id)
|
||||
{
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||
|
@ -23,6 +23,7 @@ public:
|
||||
static QList<LibraryItem *> getFolderSubfoldersFromLibrary(qulonglong libraryId, qulonglong folderId);
|
||||
static QList<LibraryItem *> getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId);
|
||||
static QList<LibraryItem *> getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId, bool sort);
|
||||
static quint32 getNumChildrenFromFolder(qulonglong libraryId, qulonglong folderId);
|
||||
static qulonglong getParentFromComicFolderId(qulonglong libraryId, qulonglong id);
|
||||
static ComicDB getComicInfo(qulonglong libraryId, qulonglong id);
|
||||
static QList<ComicDB> getSiblings(qulonglong libraryId, qulonglong parentId);
|
||||
|
Loading…
Reference in New Issue
Block a user