| 413 | } |
| 414 | |
| 415 | QList<ReadingList> DBHelper::getReadingLists(qulonglong libraryId) |
| 416 | { |
| 417 | QString libraryPath = DBHelper::getLibraries().getPath(libraryId); |
| 418 | QString connectionName = ""; |
| 419 | QList<ReadingList> list; |
| 420 | |
| 421 | { |
| 422 | QSqlDatabase db = DataBaseManagement::loadDatabase(LibraryPaths::libraryDataPath(libraryPath)); |
| 423 | |
| 424 | QSqlQuery selectQuery("SELECT * from reading_list WHERE parentId IS NULL ORDER BY name DESC", db); |
| 425 | |
| 426 | selectQuery.exec(); |
| 427 | |
| 428 | QSqlRecord record = selectQuery.record(); |
| 429 | |
| 430 | int name = record.indexOf("name"); |
| 431 | int id = record.indexOf("id"); |
| 432 | int ordering = record.indexOf("ordering"); |
| 433 | |
| 434 | while (selectQuery.next()) { |
| 435 | ReadingList item(selectQuery.value(name).toString(), selectQuery.value(id).toLongLong(), selectQuery.value(ordering).toInt()); |
| 436 | |
| 437 | if (list.isEmpty()) { |
| 438 | list.append(item); |
| 439 | } else { |
| 440 | int i = 0; |
| 441 | while (i < list.length() && naturalSortLessThanCI(list.at(i).getName(), item.getName())) |
| 442 | i++; |
| 443 | list.insert(i, item); |
| 444 | } |
| 445 | } |
| 446 | connectionName = db.connectionName(); |
| 447 | } |
| 448 | // TODO ? |
| 449 | QSqlDatabase::removeDatabase(connectionName); |
| 450 | |
| 451 | return list; |
| 452 | } |
| 453 | |
| 454 | QList<ComicDB> DBHelper::getReadingListFullContent(qulonglong libraryId, qulonglong readingListId, bool getFullComicInfoFields) |
| 455 | { |