Commit 19dd4d1f authored by Craig Watson's avatar Craig Watson

Fixed documents being accidentally permanently deleted in some cases

When both a folder and items it contained were selected, and trashed,
the documents could sometimes be deleted twice and thus, permanently
deleted when one just intended to move them to the trash.
parent 2c5793b5
...@@ -803,7 +803,19 @@ void UBDocumentController::deleteSelectedItem() ...@@ -803,7 +803,19 @@ void UBDocumentController::deleteSelectedItem()
tr("Are you sure you want to remove all selected documents?"))) tr("Are you sure you want to remove all selected documents?")))
return; return;
QList<QTreeWidgetItem*> foldersToDelete;
foreach (QTreeWidgetItem * item, mCurrentSelection) { foreach (QTreeWidgetItem * item, mCurrentSelection) {
LastSelectedElementType type = itemType(item);
if (type == Document)
deleteTreeItem(item, false);
else if (type == Folder)
// Delete folders later, to avoid deleting a document twice
foldersToDelete << item;
}
foreach (QTreeWidgetItem * item, foldersToDelete) {
deleteTreeItem(item, false); deleteTreeItem(item, false);
} }
} }
...@@ -1824,3 +1836,16 @@ bool UBDocumentController::multipleSelection() ...@@ -1824,3 +1836,16 @@ bool UBDocumentController::multipleSelection()
QList<QTreeWidgetItem*> items = mDocumentUI->documentTreeWidget->selectedItems(); QList<QTreeWidgetItem*> items = mDocumentUI->documentTreeWidget->selectedItems();
return (items.size() > 1); return (items.size() > 1);
} }
UBDocumentController::LastSelectedElementType UBDocumentController::itemType(QTreeWidgetItem * item)
{
UBDocumentProxyTreeItem * document = dynamic_cast<UBDocumentProxyTreeItem*>(item);
if (document)
return Document;
UBDocumentGroupTreeItem * folder = dynamic_cast<UBDocumentGroupTreeItem*>(item);
if (folder)
return Folder;
return None;
}
...@@ -135,6 +135,7 @@ class UBDocumentController : public UBDocumentContainer ...@@ -135,6 +135,7 @@ class UBDocumentController : public UBDocumentContainer
bool multipleSelection(); bool multipleSelection();
bool isDocumentInTrash(UBDocumentProxyTreeItem * document); bool isDocumentInTrash(UBDocumentProxyTreeItem * document);
bool isCurrentSelectionInTrash(); bool isCurrentSelectionInTrash();
LastSelectedElementType itemType(QTreeWidgetItem * item);
private slots: private slots:
void documentZoomSliderValueChanged (int value); void documentZoomSliderValueChanged (int value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment