diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index 59473f6a..6af01d96 100644 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -541,7 +541,7 @@ void UBDocumentController::duplicateSelectedItem() } } -void UBDocumentController::moveDocumentToTrash(UBDocumentGroupTreeItem* groupTi, UBDocumentProxyTreeItem *proxyTi) +void UBDocumentController::selectADocumentOnTrashingSelectedOne(UBDocumentGroupTreeItem* groupTi,UBDocumentProxyTreeItem *proxyTi) { int index = proxyTi->parent()->indexOfChild(proxyTi); index --; @@ -597,6 +597,12 @@ void UBDocumentController::moveDocumentToTrash(UBDocumentGroupTreeItem* groupTi, else proxyTi->parent()->setSelected(true); } +} + +void UBDocumentController::moveDocumentToTrash(UBDocumentGroupTreeItem* groupTi, UBDocumentProxyTreeItem *proxyTi) +{ + + selectADocumentOnTrashingSelectedOne(groupTi,proxyTi); QString oldGroupName = proxyTi->proxy()->metaData(UBSettings::documentGroupName).toString(); proxyTi->proxy()->setMetaData(UBSettings::documentGroupName, UBSettings::trashedDocumentGroupNamePrefix + oldGroupName); @@ -738,8 +744,12 @@ void UBDocumentController::deleteSelectedItem() for (int i = 0; i < groupTi->childCount(); i++) { UBDocumentProxyTreeItem* proxyTi = dynamic_cast(groupTi->child(i)); - if (proxyTi && proxyTi->proxy()) + if (proxyTi && proxyTi->proxy()){ + if(proxyTi->proxy() == mBoardController->selectedDocument()){ + selectADocumentOnTrashingSelectedOne(dynamic_cast(mDocumentUI->documentTreeWidget),proxyTi); + } toBeDeleted << proxyTi; + } } showMessage(tr("Emptying trash")); diff --git a/src/document/UBDocumentController.h b/src/document/UBDocumentController.h index 7da849be..786d2829 100644 --- a/src/document/UBDocumentController.h +++ b/src/document/UBDocumentController.h @@ -121,6 +121,8 @@ class UBDocumentController : public UBDocumentContainer bool mToolsPalettePositionned; UBDocumentGroupTreeItem* mTrashTi; + void selectADocumentOnTrashingSelectedOne(UBDocumentGroupTreeItem* groupTi,UBDocumentProxyTreeItem *proxyTi); + void moveDocumentToTrash(UBDocumentGroupTreeItem* groupTi, UBDocumentProxyTreeItem *proxyTi); void moveFolderToTrash(UBDocumentGroupTreeItem* groupTi); QString mDocumentTrashGroupName;