From d97853498040dda49bd696cf48eacea3c536e89d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fauconnier?= <fc86@outlook.fr>
Date: Fri, 28 Sep 2018 17:58:05 +0200
Subject: [PATCH] removed a second message box on deletion

---
 src/document/UBDocumentController.cpp | 35 +++++++++++++--------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp
index 02953c4d..ab82c8cb 100644
--- a/src/document/UBDocumentController.cpp
+++ b/src/document/UBDocumentController.cpp
@@ -1449,6 +1449,9 @@ void UBDocumentTreeView::dropEvent(QDropEvent *event)
 
     if(targetIsInTrash)
     {
+        if (!UBApplication::mainWindow->yesNoQuestion(tr("Remove Item"), tr("Are you sure you want to remove the selected item(s) ?")))
+            return;
+
         UBApplication::documentController->moveIndexesToTrash(dropIndex, docModel);
     }else{
         docModel->moveIndexes(dropIndex, targetIndex);
@@ -3146,29 +3149,25 @@ void UBDocumentController::deletePages(QList<QGraphicsItem *> itemsToDelete)
 
             }
         }
+        UBDocumentContainer::deletePages(sceneIndexes);
+        emit UBApplication::boardController->documentThumbnailsUpdated(this);
 
-        if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Page"), tr("Are you sure you want to remove %n page(s) from the selected document '%1'?", "", sceneIndexes.count()).arg(proxy->metaData(UBSettings::documentName).toString())))
-        {
-            UBDocumentContainer::deletePages(sceneIndexes);
-            emit UBApplication::boardController->documentThumbnailsUpdated(this);
-
-            proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
-            UBMetadataDcSubsetAdaptor::persist(proxy);
+        proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
+        UBMetadataDcSubsetAdaptor::persist(proxy);
 
-            int minIndex = proxy->pageCount() - 1;
-            foreach (int i, sceneIndexes)
-                 minIndex = qMin(i, minIndex);
+        int minIndex = proxy->pageCount() - 1;
+        foreach (int i, sceneIndexes)
+             minIndex = qMin(i, minIndex);
 
-            if (mBoardController->activeSceneIndex() > minIndex)
-            {
-                mBoardController->setActiveSceneIndex(minIndex);
-            }
+        if (mBoardController->activeSceneIndex() > minIndex)
+        {
+            mBoardController->setActiveSceneIndex(minIndex);
+        }
 
-            mDocumentUI->thumbnailWidget->selectItemAt(minIndex);
+        mDocumentUI->thumbnailWidget->selectItemAt(minIndex);
 
-            mBoardController->setActiveDocumentScene(minIndex);
-            mBoardController->reloadThumbnails();
-        }
+        mBoardController->setActiveDocumentScene(minIndex);
+        mBoardController->reloadThumbnails();
     }
 }