| 709 | } |
| 710 | |
| 711 | void PropertiesDialog::updateComics() |
| 712 | { |
| 713 | QString connectionName = ""; |
| 714 | { |
| 715 | QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath); |
| 716 | db.open(); |
| 717 | db.transaction(); |
| 718 | QList<ComicDB>::iterator itr; |
| 719 | QList<ComicDB>::iterator begin = sequentialEditing ? comics.begin() + currentComicIndex : comics.begin(); |
| 720 | QList<ComicDB>::iterator end = sequentialEditing ? comics.begin() + currentComicIndex + 1 : comics.end(); |
| 721 | for (itr = begin; itr != end; itr++) { |
| 722 | if (itr->info.edited) { |
| 723 | DBHelper::update(&(itr->info), db); |
| 724 | updated = true; |
| 725 | } |
| 726 | |
| 727 | if (!sequentialEditing && coverChanged) { |
| 728 | auto coverPath = LibraryPaths::coverPath(basePath, itr->info.hash); |
| 729 | |
| 730 | if (customCover.isNull()) { // reseted, we need to restore the default cover |
| 731 | itr->info.coverPage = QVariant(); |
| 732 | |
| 733 | InitialComicInfoExtractor ie(basePath + itr->path, coverPath, 1); |
| 734 | ie.extract(); |
| 735 | |
| 736 | if (ie.getOriginalCoverSize().second > 0) { |
| 737 | itr->info.originalCoverSize = QString("%1x%2").arg(ie.getOriginalCoverSize().first).arg(ie.getOriginalCoverSize().second); |
| 738 | itr->info.coverSizeRatio = static_cast<float>(ie.getOriginalCoverSize().first) / ie.getOriginalCoverSize().second; |
| 739 | } |
| 740 | |
| 741 | emit coverChangedSignal(*itr); |
| 742 | |
| 743 | DBHelper::update(&(itr->info), db); |
| 744 | updated = true; |
| 745 | } else { |
| 746 | itr->info.coverPage = QVariant(); |
| 747 | YACReader::saveCover(coverPath, customCover); |
| 748 | |
| 749 | auto width = customCover.width(); |
| 750 | auto height = customCover.height(); |
| 751 | itr->info.originalCoverSize = QString("%1x%2").arg(width).arg(height); |
| 752 | itr->info.coverSizeRatio = static_cast<float>(width) / height; |
| 753 | |
| 754 | DBHelper::update(&(itr->info), db); |
| 755 | updated = true; |
| 756 | |
| 757 | emit coverChangedSignal(*itr); |
| 758 | } |
| 759 | } |
| 760 | } |
| 761 | db.commit(); |
| 762 | connectionName = db.connectionName(); |
| 763 | } |
| 764 | QSqlDatabase::removeDatabase(connectionName); |
| 765 | } |
| 766 | |
| 767 | void PropertiesDialog::setMultipleCover() |
| 768 | { |
nothing calls this directly
no test coverage detected