fixed sorting in sibblings comics while reading remotely

This commit is contained in:
Luis Ángel San Martín 2015-03-22 12:13:36 +01:00
parent 416e71efd7
commit 1fe860e401
3 changed files with 12 additions and 6 deletions

View File

@ -43,15 +43,20 @@ QList<LibraryItem *> DBHelper::getFolderSubfoldersFromLibrary(qulonglong library
return list;
}
QList<LibraryItem *> DBHelper::getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId)
{
return DBHelper::getFolderComicsFromLibrary(libraryId, folderId, false);
}
QList<LibraryItem *> DBHelper::getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId, bool sort)
{
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
QList<LibraryItem *> list = DBHelper::getComicsFromParent(folderId,db,false);
QList<LibraryItem *> list = DBHelper::getComicsFromParent(folderId,db,sort);
db.close();
QSqlDatabase::removeDatabase(libraryPath);
return list;
db.close();
QSqlDatabase::removeDatabase(libraryPath);
return list;
}
qulonglong DBHelper::getParentFromComicFolderId(qulonglong libraryId, qulonglong id)
{

View File

@ -22,6 +22,7 @@ public:
static YACReaderLibraries getLibraries();
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 qulonglong getParentFromComicFolderId(qulonglong libraryId, qulonglong id);
static ComicDB getComicInfo(qulonglong libraryId, qulonglong id);
static QList<ComicDB> getSiblings(qulonglong libraryId, qulonglong parentId);

View File

@ -82,7 +82,7 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
response.writeText(QString("libraryId:%1\r\n").arg(libraryId));
if(remoteComic) //send previous and next comics id
{
QList<LibraryItem *> siblings = DBHelper::getFolderComicsFromLibrary(libraryId, comic.parentId);
QList<LibraryItem *> siblings = DBHelper::getFolderComicsFromLibrary(libraryId, comic.parentId, true);
bool found = false;
int i;
for(i = 0; i < siblings.length(); i++)