| 254 | } |
| 255 | |
| 256 | QList<ComicDB> DBHelper::getLabelComics(qulonglong libraryId, qulonglong labelId) |
| 257 | { |
| 258 | QString libraryPath = DBHelper::getLibraries().getPath(libraryId); |
| 259 | |
| 260 | QList<ComicDB> list; |
| 261 | QString connectionName = ""; |
| 262 | |
| 263 | { |
| 264 | QSqlDatabase db = DataBaseManagement::loadDatabase(LibraryPaths::libraryDataPath(libraryPath)); |
| 265 | QSqlQuery selectQuery(db); |
| 266 | selectQuery.prepare("SELECT c.id,c.fileName,ci.title,ci.currentPage,ci.numPages,ci.hash,ci.read,ci.coverSizeRatio,ci.number " |
| 267 | "FROM comic c INNER JOIN comic_info ci ON (c.comicInfoId = ci.id) " |
| 268 | "INNER JOIN comic_label cl ON (c.id == cl.comic_id) " |
| 269 | "WHERE cl.label_id = :parentLabelId " |
| 270 | "ORDER BY cl.ordering"); |
| 271 | selectQuery.bindValue(":parentLabelId", labelId); |
| 272 | selectQuery.exec(); |
| 273 | |
| 274 | auto record = selectQuery.record(); |
| 275 | int id = record.indexOf("id"); |
| 276 | int fileName = record.indexOf("fileName"); |
| 277 | int title = record.indexOf("title"); |
| 278 | int currentPage = record.indexOf("currentPage"); |
| 279 | int numPages = record.indexOf("numPages"); |
| 280 | int hash = record.indexOf("hash"); |
| 281 | int read = record.indexOf("read"); |
| 282 | int coverSizeRatio = record.indexOf("coverSizeRatio"); |
| 283 | int number = record.indexOf("number"); |
| 284 | |
| 285 | while (selectQuery.next()) { |
| 286 | ComicDB comic; |
| 287 | |
| 288 | comic.id = selectQuery.value(id).toULongLong(); |
| 289 | comic.parentId = labelId; |
| 290 | comic.name = selectQuery.value(fileName).toString(); |
| 291 | comic.info.title = selectQuery.value(title).toString(); |
| 292 | comic.info.currentPage = selectQuery.value(currentPage).toInt(); |
| 293 | comic.info.numPages = selectQuery.value(numPages).toInt(); |
| 294 | comic.info.hash = selectQuery.value(hash).toString(); |
| 295 | comic.info.read = selectQuery.value(read).toBool(); |
| 296 | comic.info.coverSizeRatio = selectQuery.value(coverSizeRatio).toFloat(); |
| 297 | comic.info.number = selectQuery.value(number); |
| 298 | |
| 299 | list.append(comic); |
| 300 | } |
| 301 | connectionName = db.connectionName(); |
| 302 | } |
| 303 | QSqlDatabase::removeDatabase(connectionName); |
| 304 | |
| 305 | return list; |
| 306 | } |
| 307 | |
| 308 | QList<ComicDB> DBHelper::getFavorites(qulonglong libraryId) |
| 309 | { |