From 1fe860e4011fe0aff12b1b785b92c1d75a6d2fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 22 Mar 2015 12:13:36 +0100 Subject: [PATCH 1/2] fixed sorting in sibblings comics while reading remotely --- YACReaderLibrary/db_helper.cpp | 15 ++++++++++----- YACReaderLibrary/db_helper.h | 1 + .../server/controllers/comiccontroller.cpp | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/YACReaderLibrary/db_helper.cpp b/YACReaderLibrary/db_helper.cpp index 94b038d2..c442af91 100644 --- a/YACReaderLibrary/db_helper.cpp +++ b/YACReaderLibrary/db_helper.cpp @@ -43,15 +43,20 @@ QList DBHelper::getFolderSubfoldersFromLibrary(qulonglong library return list; } QList DBHelper::getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId) +{ + return DBHelper::getFolderComicsFromLibrary(libraryId, folderId, false); +} + +QList 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 list = DBHelper::getComicsFromParent(folderId,db,false); + QList 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) { diff --git a/YACReaderLibrary/db_helper.h b/YACReaderLibrary/db_helper.h index 14ca3598..b104b48f 100644 --- a/YACReaderLibrary/db_helper.h +++ b/YACReaderLibrary/db_helper.h @@ -22,6 +22,7 @@ public: static YACReaderLibraries getLibraries(); static QList getFolderSubfoldersFromLibrary(qulonglong libraryId, qulonglong folderId); static QList getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId); + static QList getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId, bool sort); static qulonglong getParentFromComicFolderId(qulonglong libraryId, qulonglong id); static ComicDB getComicInfo(qulonglong libraryId, qulonglong id); static QList getSiblings(qulonglong libraryId, qulonglong parentId); diff --git a/YACReaderLibrary/server/controllers/comiccontroller.cpp b/YACReaderLibrary/server/controllers/comiccontroller.cpp index c943ec84..7f6468f1 100644 --- a/YACReaderLibrary/server/controllers/comiccontroller.cpp +++ b/YACReaderLibrary/server/controllers/comiccontroller.cpp @@ -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 siblings = DBHelper::getFolderComicsFromLibrary(libraryId, comic.parentId); + QList siblings = DBHelper::getFolderComicsFromLibrary(libraryId, comic.parentId, true); bool found = false; int i; for(i = 0; i < siblings.length(); i++) From d798c62fa3b45f0cf572fe41db1ede1d434a67df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 22 Mar 2015 12:17:46 +0100 Subject: [PATCH 2/2] added natural sorting to ip sorting in server config dialog, the heuristic should be fine now --- YACReaderLibrary/server_config_dialog.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/YACReaderLibrary/server_config_dialog.cpp b/YACReaderLibrary/server_config_dialog.cpp index a44a5271..3e971668 100644 --- a/YACReaderLibrary/server_config_dialog.cpp +++ b/YACReaderLibrary/server_config_dialog.cpp @@ -13,12 +13,16 @@ #include "startup.h" #include "yacreader_global.h" +#include "qnaturalsorting.h" + #include +//192.168 (most comon local subnet for ips are always put first) +//IPs are sorted using natoral sorting bool ipComparator(const QString & ip1, const QString & ip2) { if(ip1.startsWith("192.168") && ip2.startsWith("192.168")) - return ip1 < ip2; + return naturalSortLessThanCI(ip1, ip2); if(ip1.startsWith("192.168")) return true; @@ -26,7 +30,7 @@ bool ipComparator(const QString & ip1, const QString & ip2) if(ip2.startsWith("192.168")) return false; - return ip1 < ip2; + return naturalSortLessThanCI(ip1, ip2); } #ifndef Q_OS_WIN32