| 50 | } |
| 51 | |
| 52 | void UBDocument::deletePages(QList<int> indexes) |
| 53 | { |
| 54 | if (indexes.isEmpty()) |
| 55 | { |
| 56 | return; |
| 57 | } |
| 58 | |
| 59 | bool accepted{false}; |
| 60 | |
| 61 | if (indexes.size() > 1) |
| 62 | { |
| 63 | accepted = UBApplication::mainWindow->yesNoQuestion( |
| 64 | UBDocumentController::tr("Moving %1 pages of the document \"%2\" to trash") |
| 65 | .arg(QString::number(indexes.size()), mProxy->name()), |
| 66 | UBDocumentController::tr("You are about to move %1 pages of the document \"%2\" to trash. Are you sure ?") |
| 67 | .arg(QString::number(indexes.size()), mProxy->name()), |
| 68 | QPixmap(":/images/trash-document-page.png")); |
| 69 | } |
| 70 | else |
| 71 | { |
| 72 | accepted = UBApplication::mainWindow->yesNoQuestion( |
| 73 | UBDocumentController::tr("Remove page %1").arg(indexes.at(0) + 1), |
| 74 | UBDocumentController::tr("You are about to remove page %1 of the document \"%2\". Are you sure ?") |
| 75 | .arg(indexes.at(0) + 1) |
| 76 | .arg(mProxy->name()), |
| 77 | QPixmap(":/images/trash-document-page.png")); |
| 78 | } |
| 79 | |
| 80 | if (!accepted) |
| 81 | { |
| 82 | return; |
| 83 | } |
| 84 | |
| 85 | std::sort(indexes.begin(), indexes.end()); |
| 86 | UBPersistenceManager::persistenceManager()->deleteDocumentScenes(mProxy, indexes); |
| 87 | |
| 88 | for (int i = indexes.size() - 1; i >= 0; --i) |
| 89 | { |
| 90 | mThumbnailScene->deleteThumbnail(indexes.at(i), false); |
| 91 | emit UBPersistenceManager::persistenceManager()->documentSceneDeleted(mProxy, indexes.at(i)); |
| 92 | } |
| 93 | |
| 94 | mThumbnailScene->renumberThumbnails(indexes.first()); |
| 95 | mThumbnailScene->arrangeThumbnails(indexes.first()); |
| 96 | |
| 97 | QDateTime now = QDateTime::currentDateTime(); |
| 98 | mProxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(now)); |
| 99 | } |
| 100 | |
| 101 | void UBDocument::duplicatePage(int index) |
| 102 | { |
no test coverage detected